1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  24  *
  25  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  */
  28 
  29 #ifndef _THREAD_H
  30 #define _THREAD_H
  31 
  32 /*
  33  * thread.h:
  34  * definitions needed to use the thread interface except synchronization.
  35  * use <synch.h> for thread synchronization.
  36  */
  37 
  38 #ifndef _ASM
  39 #include <sys/signal.h>
  40 #include <sys/time.h>
  41 #include <synch.h>
  42 #endif  /* _ASM */
  43 
  44 #ifdef __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 #ifndef _ASM
  49 typedef unsigned int thread_t;
  50 typedef unsigned int thread_key_t;
  51 #endif /* _ASM */
  52 
  53 #ifndef _ASM
  54 
  55 extern int thr_create(void *, size_t, void *(*)(void *), void *, long,
  56                         thread_t *);
  57 extern int thr_join(thread_t, thread_t *, void **);
  58 extern int thr_setconcurrency(int);
  59 extern int thr_getconcurrency(void);
  60 extern void thr_exit(void *) __NORETURN;
  61 extern thread_t thr_self(void);
  62 
  63 /*
  64  * the definition of thr_sigsetmask() is not strict ansi-c since sigset_t is
  65  * not in the strict ansi-c name space. Hence, include the prototype for
  66  * thr_sigsetmask() only if strict ansi-c conformance is not turned on.
  67  */
  68 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
  69 extern int thr_sigsetmask(int, const sigset_t *, sigset_t *);
  70 #endif
  71 
  72 /*
  73  * the definition of thr_stksegment() is not strict ansi-c since stack_t is
  74  * not in the strict ansi-c name space. Hence, include the prototype for
  75  * thr_stksegment() only if strict ansi-c conformance is not turned on.
  76  */
  77 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
  78 extern int thr_stksegment(stack_t *);
  79 #endif
  80 
  81 extern int thr_main(void);
  82 extern int thr_kill(thread_t, int);
  83 extern int thr_suspend(thread_t);
  84 extern int thr_continue(thread_t);
  85 extern void thr_yield(void);
  86 extern int thr_setprio(thread_t, int);
  87 extern int thr_getprio(thread_t, int *);
  88 extern int thr_keycreate(thread_key_t *, void(*)(void *));
  89 extern int thr_keycreate_once(thread_key_t *, void(*)(void *));
  90 extern int thr_setspecific(thread_key_t, void *);
  91 extern int thr_getspecific(thread_key_t, void **);
  92 extern size_t thr_min_stack(void);
  93 
  94 #endif /* _ASM */
  95 
  96 #define THR_MIN_STACK   thr_min_stack()
  97 /*
  98  * thread flags (one word bit mask)
  99  */
 100 /*
 101  * POSIX.1c Note:
 102  * THR_BOUND is defined same as PTHREAD_SCOPE_SYSTEM in <pthread.h>
 103  * THR_DETACHED is defined same as PTHREAD_CREATE_DETACHED in <pthread.h>
 104  * Any changes in these definitions should be reflected in <pthread.h>
 105  */
 106 #define THR_BOUND               0x00000001      /* = PTHREAD_SCOPE_SYSTEM */
 107 #define THR_NEW_LWP             0x00000002
 108 #define THR_DETACHED            0x00000040      /* = PTHREAD_CREATE_DETACHED */
 109 #define THR_SUSPENDED           0x00000080
 110 #define THR_DAEMON              0x00000100
 111 
 112 /*
 113  * The key to be created by thr_keycreate_once()
 114  * must be statically initialized with THR_ONCE_KEY.
 115  * This must be the same as PTHREAD_ONCE_KEY_NP in <pthread.h>
 116  */
 117 #define THR_ONCE_KEY    (thread_key_t)(-1)
 118 
 119 /*
 120  * The available register states returned by thr_getstate().
 121  */
 122 #define TRS_VALID       0
 123 #define TRS_NONVOLATILE 1
 124 #define TRS_LWPID       2
 125 #define TRS_INVALID     3
 126 
 127 #ifdef __cplusplus
 128 }
 129 #endif
 130 
 131 #endif  /* _THREAD_H */