Subversion Repositories Kolibri OS

Rev

Rev 6099 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6099 Rev 6536
1
/* unified sys/types.h: 
1
/* unified sys/types.h: 
2
   start with sef's sysvi386 version.
2
   start with sef's sysvi386 version.
3
   merge go32 version -- a few ifdefs.
3
   merge go32 version -- a few ifdefs.
4
   h8300hms, h8300xray, and sysvnecv70 disagree on the following types:
4
   h8300hms, h8300xray, and sysvnecv70 disagree on the following types:
5
 
5
 
6
   typedef int gid_t;
6
   typedef int gid_t;
7
   typedef int uid_t;
7
   typedef int uid_t;
8
   typedef int dev_t;
8
   typedef int dev_t;
9
   typedef int ino_t;
9
   typedef int ino_t;
10
   typedef int mode_t;
10
   typedef int mode_t;
11
   typedef int caddr_t;
11
   typedef int caddr_t;
12
 
12
 
13
   however, these aren't "reasonable" values, the sysvi386 ones make far 
13
   however, these aren't "reasonable" values, the sysvi386 ones make far 
14
   more sense, and should work sufficiently well (in particular, h8300 
14
   more sense, and should work sufficiently well (in particular, h8300 
15
   doesn't have a stat, and the necv70 doesn't matter.) -- eichin
15
   doesn't have a stat, and the necv70 doesn't matter.) -- eichin
16
 */
16
 */
17
 
17
 
18
#ifndef _SYS_TYPES_H
18
#ifndef _SYS_TYPES_H
19
 
19
 
20
#include <_ansi.h>
20
#include <_ansi.h>
21
# include 
21
#include 
22
 
-
 
23
#ifndef __INTTYPES_DEFINED__
-
 
24
#define __INTTYPES_DEFINED__
-
 
25
 
-
 
26
#include 
22
#include 
27
 
-
 
28
#if defined(__rtems__) || defined(__XMK__)
-
 
29
/*
23
 
30
 *  The following section is RTEMS specific and is needed to more
24
/* BSD types permitted by POSIX and always exposed as in Glibc.  Only provided
31
 *  closely match the types defined in the BSD sys/types.h.
-
 
32
 *  This is needed to let the RTEMS/BSD TCP/IP stack compile.
-
 
33
 */
-
 
34
 
25
   for backward compatibility with BSD code.  The uintN_t standard types should
35
/* deprecated */
26
   be preferred in new code. */
36
#if ___int8_t_defined
27
#if ___int8_t_defined
37
typedef __uint8_t	u_int8_t;
28
typedef __uint8_t	u_int8_t;
38
#endif
29
#endif
39
#if ___int16_t_defined
30
#if ___int16_t_defined
40
typedef __uint16_t	u_int16_t;
31
typedef __uint16_t	u_int16_t;
41
#endif 
32
#endif 
42
#if ___int32_t_defined
33
#if ___int32_t_defined
43
typedef __uint32_t	u_int32_t;
34
typedef __uint32_t	u_int32_t;
44
#endif
35
#endif
45
 
-
 
46
#if ___int64_t_defined
36
#if ___int64_t_defined
47
typedef __uint64_t	u_int64_t;
37
typedef __uint64_t	u_int64_t;
-
 
38
#endif
-
 
39
 
-
 
40
#if defined(__rtems__) || defined(__XMK__)
-
 
41
/*
-
 
42
 *  The following section is RTEMS specific and is needed to more
-
 
43
 *  closely match the types defined in the BSD sys/types.h.
-
 
44
 *  This is needed to let the RTEMS/BSD TCP/IP stack compile.
-
 
45
 */
48
 
46
 
-
 
47
/* deprecated */
49
/* deprecated */
48
#if ___int64_t_defined
50
typedef	__uint64_t	u_quad_t;
49
typedef	__uint64_t	u_quad_t;
51
typedef	__int64_t	quad_t;
50
typedef	__int64_t	quad_t;
52
typedef	quad_t *	qaddr_t;
51
typedef	quad_t *	qaddr_t;
53
#endif
52
#endif
54
 
-
 
55
#endif
-
 
56
 
53
 
57
#endif /* ! __INTTYPES_DEFINED */
54
#endif /* __rtems__ || __XMK__ */
58
 
55
 
59
#ifndef __need_inttypes
56
#ifndef __need_inttypes
60
 
57
 
61
#define _SYS_TYPES_H
58
#define _SYS_TYPES_H
62
#include 
59
#include 
63
#include 
60
#include 
64
 
61
 
65
#ifdef __i386__
62
#ifdef __i386__
66
#if defined (GO32) || defined (__MSDOS__)
63
#if defined (GO32) || defined (__MSDOS__)
67
#define __MS_types__
64
#define __MS_types__
68
#endif
65
#endif
69
#endif
66
#endif
70
 
67
 
71
# include 
68
# include 
72
# include 
69
# include 
73
 
70
 
74
/* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
71
/* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
75
   changes, we assume sizeof short and long never change and have all types
72
   changes, we assume sizeof short and long never change and have all types
76
   used to define struct stat use them and not int where possible.
73
   used to define struct stat use them and not int where possible.
77
   Where not possible, _ST_INTxx are used.  It would be preferable to not have
74
   Where not possible, _ST_INTxx are used.  It would be preferable to not have
78
   such assumptions, but until the extra fluff is necessary, it's avoided.
75
   such assumptions, but until the extra fluff is necessary, it's avoided.
79
   No 64 bit targets use stat yet.  What to do about them is postponed
76
   No 64 bit targets use stat yet.  What to do about them is postponed
80
   until necessary.  */
77
   until necessary.  */
81
#ifdef __GNUC__
78
#ifdef __GNUC__
82
#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
79
#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
83
#else
80
#else
84
#define _ST_INT32
81
#define _ST_INT32
85
#endif
82
#endif
86
 
83
 
87
# if	__BSD_VISIBLE
84
#if __BSD_VISIBLE
88
 
-
 
-
 
85
#include 
89
#  define	physadr		physadr_t
86
#  define	physadr		physadr_t
90
#  define	quad		quad_t
87
#  define	quad		quad_t
-
 
88
#endif
-
 
89
 
91
 
90
#if __MISC_VISIBLE
92
#ifndef _BSDTYPES_DEFINED
91
#ifndef _BSDTYPES_DEFINED
93
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
92
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
94
#ifndef __u_char_defined
93
#ifndef __u_char_defined
95
typedef	unsigned char	u_char;
94
typedef	unsigned char	u_char;
96
#define __u_char_defined
95
#define __u_char_defined
97
#endif
96
#endif
98
#ifndef __u_short_defined
97
#ifndef __u_short_defined
99
typedef	unsigned short	u_short;
98
typedef	unsigned short	u_short;
100
#define __u_short_defined
99
#define __u_short_defined
101
#endif
100
#endif
102
#ifndef __u_int_defined
101
#ifndef __u_int_defined
103
typedef	unsigned int	u_int;
102
typedef	unsigned int	u_int;
104
#define __u_int_defined
103
#define __u_int_defined
105
#endif
104
#endif
106
#ifndef __u_long_defined
105
#ifndef __u_long_defined
107
typedef	unsigned long	u_long;
106
typedef	unsigned long	u_long;
108
#define __u_long_defined
107
#define __u_long_defined
109
#endif
108
#endif
110
#define _BSDTYPES_DEFINED
109
#define _BSDTYPES_DEFINED
111
#endif
110
#endif
-
 
111
#endif	/*__BSD_VISIBLE || __CYGWIN__ */
-
 
112
 
112
 
113
#if __MISC_VISIBLE
113
typedef	unsigned short	ushort;		/* System V compatibility */
114
typedef	unsigned short	ushort;		/* System V compatibility */
114
typedef	unsigned int	uint;		/* System V compatibility */
115
typedef	unsigned int	uint;		/* System V compatibility */
115
typedef	unsigned long	ulong;		/* System V compatibility */
116
typedef	unsigned long	ulong;		/* System V compatibility */
116
# endif	/*__BSD_VISIBLE */
117
#endif
117
 
118
 
118
#ifndef __clock_t_defined
119
#ifndef __clock_t_defined
119
typedef _CLOCK_T_ clock_t;
120
typedef _CLOCK_T_ clock_t;
120
#define __clock_t_defined
121
#define __clock_t_defined
121
#endif
122
#endif
122
 
123
 
123
#ifndef __time_t_defined
124
#ifndef __time_t_defined
124
typedef _TIME_T_ time_t;
125
typedef _TIME_T_ time_t;
125
#define __time_t_defined
126
#define __time_t_defined
126
#endif
127
#endif
127
 
128
 
128
#ifndef __daddr_t_defined
129
#ifndef __daddr_t_defined
129
typedef	long	daddr_t;
130
typedef	long	daddr_t;
130
#define __daddr_t_defined
131
#define __daddr_t_defined
131
#endif
132
#endif
132
#ifndef __caddr_t_defined
133
#ifndef __caddr_t_defined
133
typedef	char *	caddr_t;
134
typedef	char *	caddr_t;
134
#define __caddr_t_defined
135
#define __caddr_t_defined
135
#endif
136
#endif
136
 
137
 
137
#ifndef __CYGWIN__
138
#ifndef __CYGWIN__
138
#if defined(__MS_types__) || defined(__rtems__) || \
139
#if defined(__MS_types__) || defined(__rtems__) || \
139
    defined(__sparc__) || defined(__SPU__)
140
    defined(__sparc__) || defined(__SPU__)
140
typedef	unsigned long	ino_t;
141
typedef	unsigned long	ino_t;
141
#else
142
#else
142
typedef	unsigned short	ino_t;
143
typedef	unsigned short	ino_t;
143
#endif
144
#endif
144
#endif /*__CYGWIN__*/
145
#endif /*__CYGWIN__*/
145
 
146
 
146
#ifdef __MS_types__
147
#ifdef __MS_types__
147
typedef unsigned long vm_offset_t;
148
typedef unsigned long vm_offset_t;
148
typedef unsigned long vm_size_t;
149
typedef unsigned long vm_size_t;
149
 
150
 
150
#define __BIT_TYPES_DEFINED__
151
#define __BIT_TYPES_DEFINED__
151
 
152
 
152
typedef signed char int8_t;
153
typedef signed char int8_t;
153
typedef unsigned char u_int8_t;
154
typedef unsigned char u_int8_t;
154
typedef short int16_t;
155
typedef short int16_t;
155
typedef unsigned short u_int16_t;
156
typedef unsigned short u_int16_t;
156
typedef int int32_t;
157
typedef int int32_t;
157
typedef unsigned int u_int32_t;
158
typedef unsigned int u_int32_t;
158
typedef long long int64_t;
159
typedef long long int64_t;
159
typedef unsigned long long u_int64_t;
160
typedef unsigned long long u_int64_t;
160
typedef int32_t register_t;
161
typedef int32_t register_t;
161
#endif /* __MS_types__ */
162
#endif /* __MS_types__ */
162
 
163
 
163
/*
164
/*
164
 * All these should be machine specific - right now they are all broken.
165
 * All these should be machine specific - right now they are all broken.
165
 * However, for all of Cygnus' embedded targets, we want them to all be
166
 * However, for all of Cygnus' embedded targets, we want them to all be
166
 * the same.  Otherwise things like sizeof (struct stat) might depend on
167
 * the same.  Otherwise things like sizeof (struct stat) might depend on
167
 * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
168
 * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
168
 */
169
 */
169
 
170
 
170
#ifndef __CYGWIN__	/* which defines these types in it's own types.h. */
171
#ifndef __CYGWIN__	/* which defines these types in it's own types.h. */
171
typedef _off_t	off_t;
172
typedef _off_t	off_t;
172
typedef __dev_t dev_t;
173
typedef __dev_t dev_t;
173
typedef __uid_t uid_t;
174
typedef __uid_t uid_t;
174
typedef __gid_t gid_t;
175
typedef __gid_t gid_t;
175
#endif
176
#endif
176
 
177
 
177
#if defined(__XMK__)
178
#if defined(__XMK__)
178
typedef signed char pid_t;
179
typedef signed char pid_t;
179
#else
180
#else
180
typedef int pid_t;
181
typedef int pid_t;
181
#endif
182
#endif
182
 
183
 
183
#if defined(__rtems__)
184
#if defined(__rtems__)
184
typedef _mode_t mode_t;
185
typedef _mode_t mode_t;
185
#endif
186
#endif
186
 
187
 
187
#ifndef __CYGWIN__
188
#ifndef __CYGWIN__
188
typedef	long key_t;
189
typedef	long key_t;
189
#endif
190
#endif
-
 
191
 
-
 
192
#ifndef _SSIZE_T_DECLARED
190
typedef _ssize_t ssize_t;
193
typedef _ssize_t ssize_t;
-
 
194
#define	_SSIZE_T_DECLARED
-
 
195
#endif
191
 
196
 
192
#if !defined(__CYGWIN__) && !defined(__rtems__)
197
#if !defined(__CYGWIN__) && !defined(__rtems__)
193
#ifdef __MS_types__
198
#ifdef __MS_types__
194
typedef	char *	addr_t;
199
typedef	char *	addr_t;
195
typedef int mode_t;
200
typedef int mode_t;
196
#else
201
#else
197
#if defined (__sparc__) && !defined (__sparc_v9__)
202
#if defined (__sparc__) && !defined (__sparc_v9__)
198
#ifdef __svr4__
203
#ifdef __svr4__
199
typedef unsigned long mode_t;
204
typedef unsigned long mode_t;
200
#else
205
#else
201
typedef unsigned short mode_t;
206
typedef unsigned short mode_t;
202
#endif
207
#endif
203
#else
208
#else
204
typedef unsigned int mode_t _ST_INT32;
209
typedef unsigned int mode_t _ST_INT32;
205
#endif
210
#endif
206
#endif /* ! __MS_types__ */
211
#endif /* ! __MS_types__ */
207
#endif /*__CYGWIN__*/
212
#endif /*__CYGWIN__*/
208
 
213
 
209
typedef unsigned short nlink_t;
214
typedef unsigned short nlink_t;
210
 
215
 
211
#undef __MS_types__
216
#undef __MS_types__
212
#undef _ST_INT32
217
#undef _ST_INT32
213
 
218
 
214
 
219
 
215
#ifndef __clockid_t_defined
220
#ifndef __clockid_t_defined
216
typedef _CLOCKID_T_ clockid_t;
221
typedef _CLOCKID_T_ clockid_t;
217
#define __clockid_t_defined
222
#define __clockid_t_defined
218
#endif
223
#endif
219
 
224
 
220
#ifndef __timer_t_defined
225
#ifndef __timer_t_defined
221
typedef _TIMER_T_ timer_t;
226
typedef _TIMER_T_ timer_t;
222
#define __timer_t_defined
227
#define __timer_t_defined
223
#endif
228
#endif
224
 
229
 
225
typedef unsigned long useconds_t;
230
typedef unsigned long useconds_t;
226
 
231
 
227
#ifndef _SUSECONDS_T_DECLARED
232
#ifndef _SUSECONDS_T_DECLARED
228
typedef	__suseconds_t	suseconds_t;
233
typedef	__suseconds_t	suseconds_t;
229
#define	_SUSECONDS_T_DECLARED
234
#define	_SUSECONDS_T_DECLARED
230
#endif
235
#endif
231
 
236
 
232
typedef	__int64_t	sbintime_t;
237
typedef	__int64_t	sbintime_t;
233
 
238
 
234
#include 
239
#include 
235
 
240
 
236
 
241
 
237
/* Cygwin will probably never have full posix compliance due to little things
242
/* Cygwin will probably never have full posix compliance due to little things
238
 * like an inability to set the stackaddress. Cygwin is also using void *  
243
 * like an inability to set the stackaddress. Cygwin is also using void *  
239
 * pointers rather than structs to ensure maximum binary compatability with
244
 * pointers rather than structs to ensure maximum binary compatability with
240
 * previous releases.
245
 * previous releases.
241
 * This means that we don't use the types defined here, but rather in
246
 * This means that we don't use the types defined here, but rather in
242
 * 
247
 * 
243
 */
248
 */
244
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
249
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
245
 
250
 
246
#include 
251
#include 
247
 
252
 
248
/*
253
/*
249
 *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
254
 *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
250
 */
255
 */
251
 
256
 
252
#if defined(__XMK__)
257
#if defined(__XMK__)
253
typedef unsigned int pthread_t;          /* identify a thread */
258
typedef unsigned int pthread_t;          /* identify a thread */
254
#else
259
#else
255
typedef __uint32_t pthread_t;            /* identify a thread */
260
typedef __uint32_t pthread_t;            /* identify a thread */
256
#endif
261
#endif
257
 
262
 
258
/* P1003.1c/D10, p. 118-119 */
263
/* P1003.1c/D10, p. 118-119 */
259
#define PTHREAD_SCOPE_PROCESS 0
264
#define PTHREAD_SCOPE_PROCESS 0
260
#define PTHREAD_SCOPE_SYSTEM  1
265
#define PTHREAD_SCOPE_SYSTEM  1
261
 
266
 
262
/* P1003.1c/D10, p. 111 */
267
/* P1003.1c/D10, p. 111 */
263
#define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
268
#define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
264
                                      /*   attributes are inherited from */
269
                                      /*   attributes are inherited from */
265
                                      /*   the calling thread. */
270
                                      /*   the calling thread. */
266
#define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
271
#define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
267
 
272
 
268
/* P1003.1c/D10, p. 141 */
273
/* P1003.1c/D10, p. 141 */
269
#define PTHREAD_CREATE_DETACHED 0
274
#define PTHREAD_CREATE_DETACHED 0
270
#define PTHREAD_CREATE_JOINABLE  1
275
#define PTHREAD_CREATE_JOINABLE  1
271
 
276
 
272
#if defined(__rtems__)
277
#if defined(__rtems__)
273
  #include 
278
  #include 
274
#endif
279
#endif
275
 
280
 
276
#if defined(__XMK__)
281
#if defined(__XMK__)
277
typedef struct pthread_attr_s {
282
typedef struct pthread_attr_s {
278
  int contentionscope;
283
  int contentionscope;
279
  struct sched_param schedparam;
284
  struct sched_param schedparam;
280
  int  detachstate;
285
  int  detachstate;
281
  void *stackaddr;
286
  void *stackaddr;
282
  size_t stacksize;
287
  size_t stacksize;
283
} pthread_attr_t;
288
} pthread_attr_t;
284
 
289
 
285
#define PTHREAD_STACK_MIN       200
290
#define PTHREAD_STACK_MIN       200
286
 
291
 
287
#else /* !defined(__XMK__) */
292
#else /* !defined(__XMK__) */
288
typedef struct {
293
typedef struct {
289
  int is_initialized;
294
  int is_initialized;
290
  void *stackaddr;
295
  void *stackaddr;
291
  int stacksize;
296
  int stacksize;
292
  int contentionscope;
297
  int contentionscope;
293
  int inheritsched;
298
  int inheritsched;
294
  int schedpolicy;
299
  int schedpolicy;
295
  struct sched_param schedparam;
300
  struct sched_param schedparam;
296
#if defined(__rtems__)
301
#if defined(__rtems__)
297
  size_t guardsize;
302
  size_t guardsize;
298
#endif
303
#endif
299
 
304
 
300
  /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
305
  /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
301
#if defined(_POSIX_THREAD_CPUTIME)
306
#if defined(_POSIX_THREAD_CPUTIME)
302
  int  cputime_clock_allowed;  /* see time.h */
307
  int  cputime_clock_allowed;  /* see time.h */
303
#endif
308
#endif
304
  int  detachstate;
309
  int  detachstate;
305
#if defined(__rtems__)
310
#if defined(__rtems__)
306
  size_t affinitysetsize;
311
  size_t affinitysetsize;
307
  cpu_set_t *affinityset;
312
  cpu_set_t *affinityset;
308
  cpu_set_t affinitysetpreallocated;
313
  cpu_set_t affinitysetpreallocated;
309
#endif
314
#endif
310
} pthread_attr_t;
315
} pthread_attr_t;
311
 
316
 
312
#endif /* !defined(__XMK__) */
317
#endif /* !defined(__XMK__) */
313
 
318
 
314
#if defined(_POSIX_THREAD_PROCESS_SHARED)
319
#if defined(_POSIX_THREAD_PROCESS_SHARED)
315
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
320
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
316
 
321
 
317
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
322
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
318
#define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
323
#define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
319
                                  /*   the memory where the resource is */
324
                                  /*   the memory where the resource is */
320
                                  /*   located */
325
                                  /*   located */
321
#endif
326
#endif
322
 
327
 
323
#if defined(_POSIX_THREAD_PRIO_PROTECT)
328
#if defined(_POSIX_THREAD_PRIO_PROTECT)
324
/* Mutexes */
329
/* Mutexes */
325
 
330
 
326
/* Values for blocking protocol. */
331
/* Values for blocking protocol. */
327
 
332
 
328
#define PTHREAD_PRIO_NONE    0
333
#define PTHREAD_PRIO_NONE    0
329
#define PTHREAD_PRIO_INHERIT 1
334
#define PTHREAD_PRIO_INHERIT 1
330
#define PTHREAD_PRIO_PROTECT 2
335
#define PTHREAD_PRIO_PROTECT 2
331
#endif
336
#endif
332
 
337
 
333
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
338
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
334
 
339
 
335
/* Values for mutex type */
340
/* Values for mutex type */
336
 
341
 
337
/* The following defines are part of the X/Open System Interface (XSI). */
342
/* The following defines are part of the X/Open System Interface (XSI). */
338
 
343
 
339
/*
344
/*
340
 * This type of mutex does not detect deadlock. A thread attempting to
345
 * This type of mutex does not detect deadlock. A thread attempting to
341
 * relock this mutex without first unlocking it shall deadlock. Attempting
346
 * relock this mutex without first unlocking it shall deadlock. Attempting
342
 * to unlock a mutex locked by a different thread results in undefined
347
 * to unlock a mutex locked by a different thread results in undefined
343
 * behavior.  Attempting to unlock an unlocked mutex results in undefined
348
 * behavior.  Attempting to unlock an unlocked mutex results in undefined
344
 * behavior.
349
 * behavior.
345
 */
350
 */
346
#define PTHREAD_MUTEX_NORMAL     0
351
#define PTHREAD_MUTEX_NORMAL     0
347
 
352
 
348
/*
353
/*
349
 * A thread attempting to relock this mutex without first unlocking
354
 * A thread attempting to relock this mutex without first unlocking
350
 * it shall succeed in locking the mutex.  The relocking deadlock which
355
 * it shall succeed in locking the mutex.  The relocking deadlock which
351
 * can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
356
 * can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
352
 * this type of mutex.  Multiple locks of this mutex shall require the
357
 * this type of mutex.  Multiple locks of this mutex shall require the
353
 * same number of unlocks to release the mutex before another thread can
358
 * same number of unlocks to release the mutex before another thread can
354
 * acquire the mutex. A thread attempting to unlock a mutex which another
359
 * acquire the mutex. A thread attempting to unlock a mutex which another
355
 * thread has locked shall return with an error.  A thread attempting to
360
 * thread has locked shall return with an error.  A thread attempting to
356
 * unlock an unlocked mutex shall return with an error.
361
 * unlock an unlocked mutex shall return with an error.
357
 */
362
 */
358
#define PTHREAD_MUTEX_RECURSIVE  1
363
#define PTHREAD_MUTEX_RECURSIVE  1
359
 
364
 
360
/* 
365
/* 
361
 * This type of mutex provides error checking. A thread attempting
366
 * This type of mutex provides error checking. A thread attempting
362
 * to relock this mutex without first unlocking it shall return with an
367
 * to relock this mutex without first unlocking it shall return with an
363
 * error. A thread attempting to unlock a mutex which another thread has
368
 * error. A thread attempting to unlock a mutex which another thread has
364
 * locked shall return with an error. A thread attempting to unlock an
369
 * locked shall return with an error. A thread attempting to unlock an
365
 * unlocked mutex shall return with an error.
370
 * unlocked mutex shall return with an error.
366
 */
371
 */
367
#define PTHREAD_MUTEX_ERRORCHECK 2
372
#define PTHREAD_MUTEX_ERRORCHECK 2
368
 
373
 
369
/*
374
/*
370
 * Attempting to recursively lock a mutex of this type results
375
 * Attempting to recursively lock a mutex of this type results
371
 * in undefined behavior. Attempting to unlock a mutex of this type
376
 * in undefined behavior. Attempting to unlock a mutex of this type
372
 * which was not locked by the calling thread results in undefined
377
 * which was not locked by the calling thread results in undefined
373
 * behavior. Attempting to unlock a mutex of this type which is not locked
378
 * behavior. Attempting to unlock a mutex of this type which is not locked
374
 * results in undefined behavior. An implementation may map this mutex to
379
 * results in undefined behavior. An implementation may map this mutex to
375
 * one of the other mutex types.
380
 * one of the other mutex types.
376
 */
381
 */
377
#define PTHREAD_MUTEX_DEFAULT    3
382
#define PTHREAD_MUTEX_DEFAULT    3
378
 
383
 
379
#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
384
#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
380
 
385
 
381
#if defined(__XMK__)
386
#if defined(__XMK__)
382
typedef unsigned int pthread_mutex_t;    /* identify a mutex */
387
typedef unsigned int pthread_mutex_t;    /* identify a mutex */
383
 
388
 
384
typedef struct {
389
typedef struct {
385
  int type;
390
  int type;
386
} pthread_mutexattr_t;
391
} pthread_mutexattr_t;
387
 
392
 
388
#else /* !defined(__XMK__) */
393
#else /* !defined(__XMK__) */
389
typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
394
typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
390
 
395
 
391
typedef struct {
396
typedef struct {
392
  int   is_initialized;
397
  int   is_initialized;
393
#if defined(_POSIX_THREAD_PROCESS_SHARED)
398
#if defined(_POSIX_THREAD_PROCESS_SHARED)
394
  int   process_shared;  /* allow mutex to be shared amongst processes */
399
  int   process_shared;  /* allow mutex to be shared amongst processes */
395
#endif
400
#endif
396
#if defined(_POSIX_THREAD_PRIO_PROTECT)
401
#if defined(_POSIX_THREAD_PRIO_PROTECT)
397
  int   prio_ceiling;
402
  int   prio_ceiling;
398
  int   protocol;
403
  int   protocol;
399
#endif
404
#endif
400
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
405
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
401
  int type;
406
  int type;
402
#endif
407
#endif
403
  int   recursive;
408
  int   recursive;
404
} pthread_mutexattr_t;
409
} pthread_mutexattr_t;
405
#endif /* !defined(__XMK__) */
410
#endif /* !defined(__XMK__) */
406
 
411
 
407
/* Condition Variables */
412
/* Condition Variables */
408
 
413
 
409
typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
414
typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
410
 
415
 
411
typedef struct {
416
typedef struct {
412
  int   is_initialized;
417
  int   is_initialized;
-
 
418
  clock_t  clock;             /* specifiy clock for timeouts */
413
#if defined(_POSIX_THREAD_PROCESS_SHARED)
419
#if defined(_POSIX_THREAD_PROCESS_SHARED)
414
  int   process_shared;       /* allow this to be shared amongst processes */
420
  int   process_shared;       /* allow this to be shared amongst processes */
415
#endif
421
#endif
416
} pthread_condattr_t;         /* a condition attribute object */
422
} pthread_condattr_t;         /* a condition attribute object */
417
 
423
 
418
/* Keys */
424
/* Keys */
419
 
425
 
420
typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
426
typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
421
 
427
 
422
typedef struct {
428
typedef struct {
423
  int   is_initialized;  /* is this structure initialized? */
429
  int   is_initialized;  /* is this structure initialized? */
424
  int   init_executed;   /* has the initialization routine been run? */
430
  int   init_executed;   /* has the initialization routine been run? */
425
} pthread_once_t;       /* dynamic package initialization */
431
} pthread_once_t;       /* dynamic package initialization */
426
#else
432
#else
427
#if defined (__CYGWIN__)
433
#if defined (__CYGWIN__)
428
#include 
434
#include 
429
#endif
435
#endif
430
#endif /* defined(_POSIX_THREADS) */
436
#endif /* defined(_POSIX_THREADS) */
431
 
437
 
432
/* POSIX Barrier Types */
438
/* POSIX Barrier Types */
-
 
439
 
433
 
440
#if !defined(__CYGWIN__)
434
#if defined(_POSIX_BARRIERS)
441
#if defined(_POSIX_BARRIERS)
435
typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
442
typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
436
typedef struct {
443
typedef struct {
437
  int   is_initialized;  /* is this structure initialized? */
444
  int   is_initialized;  /* is this structure initialized? */
438
#if defined(_POSIX_THREAD_PROCESS_SHARED)
445
#if defined(_POSIX_THREAD_PROCESS_SHARED)
439
  int   process_shared;       /* allow this to be shared amongst processes */
446
  int   process_shared;       /* allow this to be shared amongst processes */
440
#endif
447
#endif
441
} pthread_barrierattr_t;
448
} pthread_barrierattr_t;
442
#endif /* defined(_POSIX_BARRIERS) */
449
#endif /* defined(_POSIX_BARRIERS) */
443
 
450
 
444
/* POSIX Spin Lock Types */
451
/* POSIX Spin Lock Types */
445
 
-
 
446
#if !defined (__CYGWIN__)
452
 
447
#if defined(_POSIX_SPIN_LOCKS)
453
#if defined(_POSIX_SPIN_LOCKS)
448
typedef __uint32_t pthread_spinlock_t;        /* POSIX Spin Lock Object */
454
typedef __uint32_t pthread_spinlock_t;        /* POSIX Spin Lock Object */
449
#endif /* defined(_POSIX_SPIN_LOCKS) */
455
#endif /* defined(_POSIX_SPIN_LOCKS) */
450
 
456
 
451
/* POSIX Reader/Writer Lock Types */
457
/* POSIX Reader/Writer Lock Types */
452
 
458
 
453
#if defined(_POSIX_READER_WRITER_LOCKS)
459
#if defined(_POSIX_READER_WRITER_LOCKS)
454
typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
460
typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
455
typedef struct {
461
typedef struct {
456
  int   is_initialized;       /* is this structure initialized? */
462
  int   is_initialized;       /* is this structure initialized? */
457
#if defined(_POSIX_THREAD_PROCESS_SHARED)
463
#if defined(_POSIX_THREAD_PROCESS_SHARED)
458
  int   process_shared;       /* allow this to be shared amongst processes */
464
  int   process_shared;       /* allow this to be shared amongst processes */
459
#endif
465
#endif
460
} pthread_rwlockattr_t;
466
} pthread_rwlockattr_t;
461
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
467
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
462
#endif /* __CYGWIN__ */
468
#endif /* __CYGWIN__ */
463
 
469
 
464
#endif  /* !__need_inttypes */
470
#endif  /* !__need_inttypes */
465
 
471
 
466
#undef __need_inttypes
472
#undef __need_inttypes
467
 
473
 
468
#endif	/* _SYS_TYPES_H */
474
#endif	/* _SYS_TYPES_H */