xref: /onnv-gate/usr/src/lib/libldap4/include/lthread.h (revision 3857:21b9b714e4ab)
1 /*
2  *
3  * Portions Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
4  * Use is subject to license terms.
5  *
6  */
7 
8 #pragma ident	"%Z%%M%	%I%	%E% SMI"
9 
10 /* lthread.h - ldap threads header file */
11 
12 #ifndef _LTHREAD_H
13 #define _LTHREAD_H
14 
15 #if defined( THREAD_SUNOS4_LWP )
16 /***********************************
17  *                                 *
18  * thread definitions for sunos4   *
19  *                                 *
20  ***********************************/
21 
22 #define _THREAD
23 
24 #include <lwp/lwp.h>
25 #include <lwp/stackdep.h>
26 
27 typedef void	*(*VFP)();
28 
29 /* thread attributes and thread type */
30 typedef int		pthread_attr_t;
31 typedef thread_t	pthread_t;
32 
33 /* default attr states */
34 #define pthread_mutexattr_default	NULL
35 #define pthread_condattr_default	NULL
36 
37 /* thread state - joinable or not */
38 #define PTHREAD_CREATE_JOINABLE	0
39 #define PTHREAD_CREATE_DETACHED	1
40 /* thread scope - who is in scheduling pool */
41 #define PTHREAD_SCOPE_PROCESS	0
42 #define PTHREAD_SCOPE_SYSTEM	1
43 
44 /* mutex attributes and mutex type */
45 typedef int	pthread_mutexattr_t;
46 typedef mon_t	pthread_mutex_t;
47 
48 /* condition variable attributes and condition variable type */
49 typedef int	pthread_condattr_t;
50 typedef struct lwpcv {
51 	int		lcv_created;
52 	cv_t		lcv_cv;
53 } pthread_cond_t;
54 
55 /* mutex and condition variable scope - process or system */
56 #define PTHREAD_SHARE_PRIVATE	0
57 #define PTHREAD_SHARE_PROCESS	1
58 
59 #else /* end sunos4 */
60 
61 #if defined( THREAD_SUNOS5_LWP )
62 /***********************************
63  *                                 *
64  * thread definitions for sunos5   *
65  *                                 *
66  ***********************************/
67 
68 #define _THREAD
69 
70 #include <thread.h>
71 #include <synch.h>
72 
73 typedef void	*(*VFP)();
74 
75 /* sunos5 threads are preemptive */
76 #define PTHREAD_PREEMPTIVE	1
77 
78 #ifndef _PTHREAD_H
79 
80 /* thread attributes and thread type */
81 typedef int		pthread_attr_t;
82 typedef thread_t	pthread_t;
83 
84 /* thread state - joinable or not */
85 #define PTHREAD_CREATE_JOINABLE 0
86 #define PTHREAD_CREATE_DETACHED THR_DETACHED
87 /* thread scope - who is in scheduling pool */
88 #define PTHREAD_SCOPE_PROCESS   0
89 #define PTHREAD_SCOPE_SYSTEM    THR_BOUND
90 
91 /* mutex attributes and mutex type */
92 typedef int	pthread_mutexattr_t;
93 typedef mutex_t	pthread_mutex_t;
94 
95 /* condition variable attributes and condition variable type */
96 typedef int     pthread_condattr_t;
97 typedef cond_t	pthread_cond_t;
98 
99 #endif /* _PTHREAD_H */
100 
101 /* default attr states */
102 #define pthread_mutexattr_default	NULL
103 #define pthread_condattr_default	NULL
104 
105 /* mutex and condition variable scope - process or system */
106 #define PTHREAD_SHARE_PRIVATE   USYNC_THREAD
107 #define PTHREAD_SHARE_PROCESS   USYNC_PROCESS
108 
109 #else /* end sunos5 */
110 
111 #if defined( THREAD_MIT_PTHREADS )
112 /***********************************
113  *                                 *
114  * definitions for mit pthreads    *
115  *                                 *
116  ***********************************/
117 
118 #define _THREAD
119 
120 #include <pthread.h>
121 
122 #else /* end mit pthreads */
123 
124 #if defined( THREAD_DCE_PTHREADS )
125 /***********************************
126  *                                 *
127  * definitions for dce pthreads    *
128  *                                 *
129  ***********************************/
130 
131 #define _THREAD
132 
133 #include <pthread.h>
134 
135 /* dce threads are preemptive */
136 #define PTHREAD_PREEMPTIVE	1
137 
138 #define pthread_attr_init( a )		pthread_attr_create( a )
139 #define pthread_attr_destroy( a )	pthread_attr_delete( a )
140 #define pthread_attr_setdetachstate( a, b ) \
141 					pthread_attr_setdetach_np( a, b )
142 
143 #endif /* dce pthreads */
144 #endif /* mit pthreads */
145 #endif /* sunos5 */
146 #endif /* sunos4 */
147 
148 #ifndef _THREAD
149 
150 /***********************************
151  *                                 *
152  * thread definitions for no       *
153  * underlying library support      *
154  *                                 *
155  ***********************************/
156 
157 typedef void	*(*VFP)();
158 
159 /* thread attributes and thread type */
160 typedef int	pthread_attr_t;
161 typedef int	pthread_t;
162 
163 /* default attr states */
164 #define pthread_mutexattr_default	NULL
165 #define pthread_condattr_default	NULL
166 
167 /* thread state - joinable or not */
168 #define PTHREAD_CREATE_JOINABLE 0
169 #define PTHREAD_CREATE_DETACHED 0
170 /* thread scope - who is in scheduling pool */
171 #define PTHREAD_SCOPE_PROCESS   0
172 #define PTHREAD_SCOPE_SYSTEM    0
173 
174 /* mutex attributes and mutex type */
175 typedef int	pthread_mutexattr_t;
176 typedef int	pthread_mutex_t;
177 
178 /* mutex and condition variable scope - process or system */
179 #define PTHREAD_SHARE_PRIVATE   0
180 #define PTHREAD_SHARE_PROCESS   0
181 
182 /* condition variable attributes and condition variable type */
183 typedef int     pthread_condattr_t;
184 typedef int	pthread_cond_t;
185 
186 #endif /* no threads support */
187 #endif /* _LTHREAD_H */
188