xref: /titanic_41/usr/src/head/thread.h (revision 9512fe850e98fdd448c638ca63fdd92a8a510255)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_THREAD_H
28 #define	_THREAD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
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 #ifdef __STDC__
55 
56 extern int thr_create(void *, size_t, void *(*)(void *), void *, long,
57 			thread_t *);
58 extern int thr_join(thread_t, thread_t *, void **);
59 extern int thr_setconcurrency(int);
60 extern int thr_getconcurrency(void);
61 extern void thr_exit(void *) __NORETURN;
62 extern thread_t thr_self(void);
63 
64 /*
65  * the definition of thr_sigsetmask() is not strict ansi-c since sigset_t is
66  * not in the strict ansi-c name space. Hence, include the prototype for
67  * thr_sigsetmask() only if strict ansi-c conformance is not turned on.
68  */
69 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
70 extern int thr_sigsetmask(int, const sigset_t *, sigset_t *);
71 #endif
72 
73 /*
74  * the definition of thr_stksegment() is not strict ansi-c since stack_t is
75  * not in the strict ansi-c name space. Hence, include the prototype for
76  * thr_stksegment() only if strict ansi-c conformance is not turned on.
77  */
78 #if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
79 extern int thr_stksegment(stack_t *);
80 #endif
81 
82 extern int thr_main(void);
83 extern int thr_kill(thread_t, int);
84 extern int thr_suspend(thread_t);
85 extern int thr_continue(thread_t);
86 extern void thr_yield(void);
87 extern int thr_setprio(thread_t, int);
88 extern int thr_getprio(thread_t, int *);
89 extern int thr_keycreate(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 #else /* __STDC */
95 
96 extern int thr_create();
97 extern int thr_join();
98 extern int thr_setconcurrency();
99 extern int thr_getconcurrency();
100 extern void thr_exit();
101 extern thread_t	thr_self();
102 extern int thr_sigsetmask();
103 extern int thr_stksegment();
104 extern int thr_main();
105 extern int thr_kill();
106 extern int thr_suspend();
107 extern int thr_continue();
108 extern void thr_yield();
109 extern int thr_setprio();
110 extern int thr_getprio();
111 extern int thr_keycreate();
112 extern int thr_setspecific();
113 extern int thr_getspecific();
114 extern size_t thr_min_stack();
115 
116 #endif /* __STDC */
117 #endif /* _ASM */
118 
119 #define	THR_MIN_STACK	thr_min_stack()
120 /*
121  * thread flags (one word bit mask)
122  */
123 /*
124  * POSIX.1c Note:
125  * THR_BOUND is defined same as PTHREAD_SCOPE_SYSTEM in <pthread.h>
126  * THR_DETACHED is defined same as PTHREAD_CREATE_DETACHED in <pthread.h>
127  * Any changes in these definitions should be reflected in <pthread.h>
128  */
129 #define	THR_BOUND		0x00000001	/* = PTHREAD_SCOPE_SYSTEM */
130 #define	THR_NEW_LWP		0x00000002
131 #define	THR_DETACHED		0x00000040	/* = PTHREAD_CREATE_DETACHED */
132 #define	THR_SUSPENDED		0x00000080
133 #define	THR_DAEMON		0x00000100
134 
135 /*
136  * The available register states returned by thr_getstate().
137  */
138 #define	TRS_VALID	0
139 #define	TRS_NONVOLATILE	1
140 #define	TRS_LWPID	2
141 #define	TRS_INVALID	3
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif	/* _THREAD_H */
148