source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/pthread.h@ 1194

Last change on this file since 1194 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 33.7 KB
RevLine 
[1166]1/*
2 Copyright (c) 2011-2016 mingw-w64 project
3
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files (the "Software"),
6 to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and/or sell copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 DEALINGS IN THE SOFTWARE.
21*/
22
23/*
24 * Parts of this library are derived by:
25 *
26 * Posix Threads library for Microsoft Windows
27 *
28 * Use at own risk, there is no implied warranty to this code.
29 * It uses undocumented features of Microsoft Windows that can change
30 * at any time in the future.
31 *
32 * (C) 2010 Lockless Inc.
33 * All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without modification,
36 * are permitted provided that the following conditions are met:
37 *
38 *
39 * * Redistributions of source code must retain the above copyright notice,
40 * this list of conditions and the following disclaimer.
41 * * Redistributions in binary form must reproduce the above copyright notice,
42 * this list of conditions and the following disclaimer in the documentation
43 * and/or other materials provided with the distribution.
44 * * Neither the name of Lockless Inc. nor the names of its contributors may be
45 * used to endorse or promote products derived from this software without
46 * specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AN
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
51 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
52 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
53 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
55 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
56 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
57 * OF THE POSSIBILITY OF SUCH DAMAGE.
58 */
59#ifndef WIN_PTHREADS_H
60#define WIN_PTHREADS_H
61
62#include <stddef.h>
63#include <errno.h>
64#include <sys/types.h>
65
66#include <process.h>
67#include <limits.h>
68#include <signal.h>
69#include <time.h>
70
71#include <sys/timeb.h>
72
73#include "pthread_compat.h"
74
75#ifdef __cplusplus
76extern "C" {
77#endif
78
79#define __WINPTHREADS_VERSION_MAJOR 0
80#define __WINPTHREADS_VERSION_MINOR 5
81#define __WINPTHREADS_VERSION_PATCHLEVEL 0
82
83/* MSB 8-bit major version, 8-bit minor version, 16-bit patch level. */
84#define __WINPTHREADS_VERSION 0x00050000
85
86#if defined DLL_EXPORT
87#ifdef IN_WINPTHREAD
88#define WINPTHREAD_API __declspec(dllexport)
89#else
90#define WINPTHREAD_API __declspec(dllimport)
91#endif
92#else
93#define WINPTHREAD_API
94#endif
95
96/* #define WINPTHREAD_DBG 1 */
97
98/* Compatibility stuff: */
99#define RWLS_PER_THREAD 8
100
101/* Error-codes. */
102#ifndef ETIMEDOUT
103#define ETIMEDOUT 138
104#endif
105#ifndef ENOTSUP
106#define ENOTSUP 129
107#endif
108#ifndef EWOULDBLOCK
109#define EWOULDBLOCK 140
110#endif
111
112/* pthread specific defines. */
113
114#define PTHREAD_CANCEL_DISABLE 0
115#define PTHREAD_CANCEL_ENABLE 0x01
116
117#define PTHREAD_CANCEL_DEFERRED 0
118#define PTHREAD_CANCEL_ASYNCHRONOUS 0x02
119
120#define PTHREAD_CREATE_JOINABLE 0
121#define PTHREAD_CREATE_DETACHED 0x04
122
123#define PTHREAD_EXPLICIT_SCHED 0
124#define PTHREAD_INHERIT_SCHED 0x08
125
126#define PTHREAD_SCOPE_PROCESS 0
127#define PTHREAD_SCOPE_SYSTEM 0x10
128
129#define PTHREAD_DEFAULT_ATTR (PTHREAD_CANCEL_ENABLE)
130
131#define PTHREAD_CANCELED ((void *) (intptr_t) 0xDEADBEEF)
132
133#define _PTHREAD_NULL_THREAD ((pthread_t) 0)
134
135#define PTHREAD_ONCE_INIT 0
136
137#define PTHREAD_DESTRUCTOR_ITERATIONS 256
138#define PTHREAD_KEYS_MAX (1<<20)
139
140#define PTHREAD_MUTEX_NORMAL 0
141#define PTHREAD_MUTEX_ERRORCHECK 1
142#define PTHREAD_MUTEX_RECURSIVE 2
143#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
144
145#define PTHREAD_MUTEX_SHARED 1
146#define PTHREAD_MUTEX_PRIVATE 0
147
148#define PTHREAD_PRIO_NONE 0
149#define PTHREAD_PRIO_INHERIT 8
150#define PTHREAD_PRIO_PROTECT 16
151#define PTHREAD_PRIO_MULT 32
152#define PTHREAD_PROCESS_SHARED 1
153#define PTHREAD_PROCESS_PRIVATE 0
154
155#define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_NORMAL
156#define PTHREAD_MUTEX_TIMED_NP PTHREAD_MUTEX_FAST_NP
157#define PTHREAD_MUTEX_ADAPTIVE_NP PTHREAD_MUTEX_FAST_NP
158#define PTHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK
159#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
160
161void * WINPTHREAD_API pthread_timechange_handler_np(void * dummy);
162int WINPTHREAD_API pthread_delay_np (const struct timespec *interval);
163int WINPTHREAD_API pthread_num_processors_np(void);
164int WINPTHREAD_API pthread_set_num_processors_np(int n);
165
166#define PTHREAD_BARRIER_SERIAL_THREAD 1
167
168/* maximum number of times a read lock may be obtained */
169#define MAX_READ_LOCKS (INT_MAX - 1)
170
171/* No fork() in windows - so ignore this */
172#define pthread_atfork(F1,F2,F3) 0
173
174/* unsupported stuff: */
175#define pthread_mutex_getprioceiling(M, P) ENOTSUP
176#define pthread_mutex_setprioceiling(M, P) ENOTSUP
177#define pthread_getcpuclockid(T, C) ENOTSUP
178#define pthread_attr_getguardsize(A, S) ENOTSUP
179#define pthread_attr_setgaurdsize(A, S) ENOTSUP
180
181typedef long pthread_once_t;
182typedef unsigned pthread_mutexattr_t;
183typedef unsigned pthread_key_t;
184typedef void *pthread_barrierattr_t;
185typedef int pthread_condattr_t;
186typedef int pthread_rwlockattr_t;
187
188/*
189struct _pthread_v;
190
191typedef struct pthread_t {
192 struct _pthread_v *p;
193 int x;
194} pthread_t;
195*/
196
197typedef uintptr_t pthread_t;
198
199typedef struct _pthread_cleanup _pthread_cleanup;
200struct _pthread_cleanup
201{
202 void (*func)(void *);
203 void *arg;
204 _pthread_cleanup *next;
205};
206
207#define pthread_cleanup_push(F, A)\
208{\
209 const _pthread_cleanup _pthread_cup = {(F), (A), *pthread_getclean()};\
210 __sync_synchronize();\
211 *pthread_getclean() = (_pthread_cleanup *) &_pthread_cup;\
212 __sync_synchronize()
213
214/* Note that if async cancelling is used, then there is a race here */
215#define pthread_cleanup_pop(E)\
216 (*pthread_getclean() = _pthread_cup.next, ((E) ? (_pthread_cup.func((pthread_once_t *)_pthread_cup.arg)) : (void)0));}
217
218#ifndef SCHED_OTHER
219/* Some POSIX realtime extensions, mostly stubbed */
220#define SCHED_OTHER 0
221#define SCHED_FIFO 1
222#define SCHED_RR 2
223#define SCHED_MIN SCHED_OTHER
224#define SCHED_MAX SCHED_RR
225
226struct sched_param {
227 int sched_priority;
228};
229
230int WINPTHREAD_API sched_yield(void);
231int WINPTHREAD_API sched_get_priority_min(int pol);
232int WINPTHREAD_API sched_get_priority_max(int pol);
233int WINPTHREAD_API sched_getscheduler(pid_t pid);
234int WINPTHREAD_API sched_setscheduler(pid_t pid, int pol, const struct sched_param *param);
235
236#endif
237
238typedef struct pthread_attr_t pthread_attr_t;
239struct pthread_attr_t
240{
241 unsigned p_state;
242 void *stack;
243 size_t s_size;
244 struct sched_param param;
245};
246
247int WINPTHREAD_API pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param);
248int WINPTHREAD_API pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);
249int WINPTHREAD_API pthread_getschedparam(pthread_t thread, int *pol, struct sched_param *param);
250int WINPTHREAD_API pthread_setschedparam(pthread_t thread, int pol, const struct sched_param *param);
251int WINPTHREAD_API pthread_attr_setschedpolicy (pthread_attr_t *attr, int pol);
252int WINPTHREAD_API pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *pol);
253
254/* synchronization objects */
255typedef intptr_t pthread_spinlock_t;
256typedef intptr_t pthread_mutex_t;
257typedef intptr_t pthread_cond_t;
258typedef intptr_t pthread_rwlock_t;
259typedef void *pthread_barrier_t;
260
261#define PTHREAD_MUTEX_NORMAL 0
262#define PTHREAD_MUTEX_ERRORCHECK 1
263#define PTHREAD_MUTEX_RECURSIVE 2
264
265#define GENERIC_INITIALIZER -1
266#define GENERIC_ERRORCHECK_INITIALIZER -2
267#define GENERIC_RECURSIVE_INITIALIZER -3
268#define GENERIC_NORMAL_INITIALIZER -1
269#define PTHREAD_MUTEX_INITIALIZER (pthread_mutex_t)GENERIC_INITIALIZER
270#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER (pthread_mutex_t)GENERIC_RECURSIVE_INITIALIZER
271#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER (pthread_mutex_t)GENERIC_ERRORCHECK_INITIALIZER
272#define PTHREAD_NORMAL_MUTEX_INITIALIZER (pthread_mutex_t)GENERIC_NORMAL_INITIALIZER
273#define PTHREAD_DEFAULT_MUTEX_INITIALIZER PTHREAD_NORMAL_MUTEX_INITIALIZER
274#define PTHREAD_COND_INITIALIZER (pthread_cond_t)GENERIC_INITIALIZER
275#define PTHREAD_RWLOCK_INITIALIZER (pthread_rwlock_t)GENERIC_INITIALIZER
276#define PTHREAD_SPINLOCK_INITIALIZER (pthread_spinlock_t)GENERIC_INITIALIZER
277
278extern void WINPTHREAD_API (**_pthread_key_dest)(void *);
279int WINPTHREAD_API pthread_key_create(pthread_key_t *key, void (* dest)(void *));
280int WINPTHREAD_API pthread_key_delete(pthread_key_t key);
281void * WINPTHREAD_API pthread_getspecific(pthread_key_t key);
282int WINPTHREAD_API pthread_setspecific(pthread_key_t key, const void *value);
283
284pthread_t WINPTHREAD_API pthread_self(void);
285int WINPTHREAD_API pthread_once(pthread_once_t *o, void (*func)(void));
286void WINPTHREAD_API pthread_testcancel(void);
287int WINPTHREAD_API pthread_equal(pthread_t t1, pthread_t t2);
288void WINPTHREAD_API pthread_tls_init(void);
289void WINPTHREAD_API _pthread_cleanup_dest(pthread_t t);
290int WINPTHREAD_API pthread_get_concurrency(int *val);
291int WINPTHREAD_API pthread_set_concurrency(int val);
292void WINPTHREAD_API pthread_exit(void *res);
293void WINPTHREAD_API _pthread_invoke_cancel(void);
294int WINPTHREAD_API pthread_cancel(pthread_t t);
295int WINPTHREAD_API pthread_kill(pthread_t t, int sig);
296unsigned WINPTHREAD_API _pthread_get_state(const pthread_attr_t *attr, unsigned flag);
297int WINPTHREAD_API _pthread_set_state(pthread_attr_t *attr, unsigned flag, unsigned val);
298int WINPTHREAD_API pthread_setcancelstate(int state, int *oldstate);
299int WINPTHREAD_API pthread_setcanceltype(int type, int *oldtype);
300int WINPTHREAD_API pthread_create_wrapper(void *args);
301int WINPTHREAD_API pthread_create(pthread_t *th, const pthread_attr_t *attr, void *(* func)(void *), void *arg);
302int WINPTHREAD_API pthread_join(pthread_t t, void **res);
303int WINPTHREAD_API pthread_detach(pthread_t t);
304int WINPTHREAD_API pthread_setname_np(pthread_t thread, const char *name);
305int WINPTHREAD_API pthread_getname_np(pthread_t thread, char *name, size_t len);
306
307
308int WINPTHREAD_API pthread_rwlock_init(pthread_rwlock_t *rwlock_, const pthread_rwlockattr_t *attr);
309int WINPTHREAD_API pthread_rwlock_wrlock(pthread_rwlock_t *l);
310int WINPTHREAD_API pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *ts);
311int WINPTHREAD_API pthread_rwlock_rdlock(pthread_rwlock_t *l);
312int WINPTHREAD_API pthread_rwlock_timedrdlock(pthread_rwlock_t *l, const struct timespec *ts);
313int WINPTHREAD_API pthread_rwlock_unlock(pthread_rwlock_t *l);
314int WINPTHREAD_API pthread_rwlock_tryrdlock(pthread_rwlock_t *l);
315int WINPTHREAD_API pthread_rwlock_trywrlock(pthread_rwlock_t *l);
316int WINPTHREAD_API pthread_rwlock_destroy (pthread_rwlock_t *l);
317
318int WINPTHREAD_API pthread_cond_init(pthread_cond_t *cv, const pthread_condattr_t *a);
319int WINPTHREAD_API pthread_cond_destroy(pthread_cond_t *cv);
320int WINPTHREAD_API pthread_cond_signal (pthread_cond_t *cv);
321int WINPTHREAD_API pthread_cond_broadcast (pthread_cond_t *cv);
322int WINPTHREAD_API pthread_cond_wait (pthread_cond_t *cv, pthread_mutex_t *external_mutex);
323int WINPTHREAD_API pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *external_mutex, const struct timespec *t);
324int WINPTHREAD_API pthread_cond_timedwait_relative_np(pthread_cond_t *cv, pthread_mutex_t *external_mutex, const struct timespec *t);
325
326int WINPTHREAD_API pthread_mutex_lock(pthread_mutex_t *m);
327int WINPTHREAD_API pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts);
328int WINPTHREAD_API pthread_mutex_unlock(pthread_mutex_t *m);
329int WINPTHREAD_API pthread_mutex_trylock(pthread_mutex_t *m);
330int WINPTHREAD_API pthread_mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *a);
331int WINPTHREAD_API pthread_mutex_destroy(pthread_mutex_t *m);
332
333int WINPTHREAD_API pthread_barrier_destroy(pthread_barrier_t *b);
334int WINPTHREAD_API pthread_barrier_init(pthread_barrier_t *b, const void *attr, unsigned int count);
335int WINPTHREAD_API pthread_barrier_wait(pthread_barrier_t *b);
336
337int WINPTHREAD_API pthread_spin_init(pthread_spinlock_t *l, int pshared);
338int WINPTHREAD_API pthread_spin_destroy(pthread_spinlock_t *l);
339/* No-fair spinlock due to lack of knowledge of thread number. */
340int WINPTHREAD_API pthread_spin_lock(pthread_spinlock_t *l);
341int WINPTHREAD_API pthread_spin_trylock(pthread_spinlock_t *l);
342int WINPTHREAD_API pthread_spin_unlock(pthread_spinlock_t *l);
343
344int WINPTHREAD_API pthread_attr_init(pthread_attr_t *attr);
345int WINPTHREAD_API pthread_attr_destroy(pthread_attr_t *attr);
346int WINPTHREAD_API pthread_attr_setdetachstate(pthread_attr_t *a, int flag);
347int WINPTHREAD_API pthread_attr_getdetachstate(const pthread_attr_t *a, int *flag);
348int WINPTHREAD_API pthread_attr_setinheritsched(pthread_attr_t *a, int flag);
349int WINPTHREAD_API pthread_attr_getinheritsched(const pthread_attr_t *a, int *flag);
350int WINPTHREAD_API pthread_attr_setscope(pthread_attr_t *a, int flag);
351int WINPTHREAD_API pthread_attr_getscope(const pthread_attr_t *a, int *flag);
352int WINPTHREAD_API pthread_attr_getstack(const pthread_attr_t *attr, void **stack, size_t *size);
353int WINPTHREAD_API pthread_attr_setstack(pthread_attr_t *attr, void *stack, size_t size);
354int WINPTHREAD_API pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stack);
355int WINPTHREAD_API pthread_attr_setstackaddr(pthread_attr_t *attr, void *stack);
356int WINPTHREAD_API pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *size);
357int WINPTHREAD_API pthread_attr_setstacksize(pthread_attr_t *attr, size_t size);
358
359int WINPTHREAD_API pthread_mutexattr_init(pthread_mutexattr_t *a);
360int WINPTHREAD_API pthread_mutexattr_destroy(pthread_mutexattr_t *a);
361int WINPTHREAD_API pthread_mutexattr_gettype(const pthread_mutexattr_t *a, int *type);
362int WINPTHREAD_API pthread_mutexattr_settype(pthread_mutexattr_t *a, int type);
363int WINPTHREAD_API pthread_mutexattr_getpshared(const pthread_mutexattr_t *a, int *type);
364int WINPTHREAD_API pthread_mutexattr_setpshared(pthread_mutexattr_t * a, int type);
365int WINPTHREAD_API pthread_mutexattr_getprotocol(const pthread_mutexattr_t *a, int *type);
366int WINPTHREAD_API pthread_mutexattr_setprotocol(pthread_mutexattr_t *a, int type);
367int WINPTHREAD_API pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *a, int * prio);
368int WINPTHREAD_API pthread_mutexattr_setprioceiling(pthread_mutexattr_t *a, int prio);
369int WINPTHREAD_API pthread_getconcurrency(void);
370int WINPTHREAD_API pthread_setconcurrency(int new_level);
371
372int WINPTHREAD_API pthread_condattr_destroy(pthread_condattr_t *a);
373int WINPTHREAD_API pthread_condattr_init(pthread_condattr_t *a);
374int WINPTHREAD_API pthread_condattr_getpshared(const pthread_condattr_t *a, int *s);
375int WINPTHREAD_API pthread_condattr_setpshared(pthread_condattr_t *a, int s);
376
377#ifndef __clockid_t_defined
378typedef int clockid_t;
379#define __clockid_t_defined 1
380#endif /* __clockid_t_defined */
381
382int WINPTHREAD_API pthread_condattr_getclock (const pthread_condattr_t *attr,
383 clockid_t *clock_id);
384int WINPTHREAD_API pthread_condattr_setclock(pthread_condattr_t *attr,
385 clockid_t clock_id);
386int WINPTHREAD_API __pthread_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp);
387
388int WINPTHREAD_API pthread_barrierattr_init(void **attr);
389int WINPTHREAD_API pthread_barrierattr_destroy(void **attr);
390int WINPTHREAD_API pthread_barrierattr_setpshared(void **attr, int s);
391int WINPTHREAD_API pthread_barrierattr_getpshared(void **attr, int *s);
392
393/* Private extensions for analysis and internal use. */
394struct _pthread_cleanup ** WINPTHREAD_API pthread_getclean (void);
395void * WINPTHREAD_API pthread_gethandle (pthread_t t);
396void * WINPTHREAD_API pthread_getevent ();
397
398unsigned long long WINPTHREAD_API _pthread_rel_time_in_ms(const struct timespec *ts);
399unsigned long long WINPTHREAD_API _pthread_time_in_ms(void);
400unsigned long long WINPTHREAD_API _pthread_time_in_ms_from_timespec(const struct timespec *ts);
401int WINPTHREAD_API _pthread_tryjoin (pthread_t t, void **res);
402int WINPTHREAD_API pthread_rwlockattr_destroy(pthread_rwlockattr_t *a);
403int WINPTHREAD_API pthread_rwlockattr_getpshared(pthread_rwlockattr_t *a, int *s);
404int WINPTHREAD_API pthread_rwlockattr_init(pthread_rwlockattr_t *a);
405int WINPTHREAD_API pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int s);
406
407#ifndef SIG_BLOCK
408#define SIG_BLOCK 0
409#endif
410#ifndef SIG_UNBLOCK
411#define SIG_UNBLOCK 1
412#endif
413#ifndef SIG_SETMASK
414#define SIG_SETMASK 2
415#endif
416
417#include <pthread_unistd.h>
418
419#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
420#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS
421
422#undef _POSIX_THREAD_KEYS_MAX
423#define _POSIX_THREAD_KEYS_MAX PTHREAD_KEYS_MAX
424
425#undef PTHREAD_THREADS_MAX
426#define PTHREAD_THREADS_MAX 2019
427
428#undef _POSIX_SEM_NSEMS_MAX
429#define _POSIX_SEM_NSEMS_MAX 256
430
431#undef SEM_NSEMS_MAX
432#define SEM_NSEMS_MAX 1024
433
434/* Wrap cancellation points. */
435#ifdef __WINPTRHEAD_ENABLE_WRAP_API
436#define accept(...) (pthread_testcancel(), accept(__VA_ARGS__))
437#define aio_suspend(...) (pthread_testcancel(), aio_suspend(__VA_ARGS__))
438#define clock_nanosleep(...) (pthread_testcancel(), clock_nanosleep(__VA_ARGS__))
439#define close(...) (pthread_testcancel(), close(__VA_ARGS__))
440#define connect(...) (pthread_testcancel(), connect(__VA_ARGS__))
441#define creat(...) (pthread_testcancel(), creat(__VA_ARGS__))
442#define fcntl(...) (pthread_testcancel(), fcntl(__VA_ARGS__))
443#define fdatasync(...) (pthread_testcancel(), fdatasync(__VA_ARGS__))
444#define fsync(...) (pthread_testcancel(), fsync(__VA_ARGS__))
445#define getmsg(...) (pthread_testcancel(), getmsg(__VA_ARGS__))
446#define getpmsg(...) (pthread_testcancel(), getpmsg(__VA_ARGS__))
447#define lockf(...) (pthread_testcancel(), lockf(__VA_ARGS__))
448#define mg_receive(...) (pthread_testcancel(), mg_receive(__VA_ARGS__))
449#define mg_send(...) (pthread_testcancel(), mg_send(__VA_ARGS__))
450#define mg_timedreceive(...) (pthread_testcancel(), mg_timedreceive(__VA_ARGS__))
451#define mg_timessend(...) (pthread_testcancel(), mg_timedsend(__VA_ARGS__))
452#define msgrcv(...) (pthread_testcancel(), msgrecv(__VA_ARGS__))
453#define msgsnd(...) (pthread_testcancel(), msgsnd(__VA_ARGS__))
454#define msync(...) (pthread_testcancel(), msync(__VA_ARGS__))
455#define nanosleep(...) (pthread_testcancel(), nanosleep(__VA_ARGS__))
456#define open(...) (pthread_testcancel(), open(__VA_ARGS__))
457#define pause(...) (pthread_testcancel(), pause(__VA_ARGS__))
458#define poll(...) (pthread_testcancel(), poll(__VA_ARGS__))
459#define pread(...) (pthread_testcancel(), pread(__VA_ARGS__))
460#define pselect(...) (pthread_testcancel(), pselect(__VA_ARGS__))
461#define putmsg(...) (pthread_testcancel(), putmsg(__VA_ARGS__))
462#define putpmsg(...) (pthread_testcancel(), putpmsg(__VA_ARGS__))
463#define pwrite(...) (pthread_testcancel(), pwrite(__VA_ARGS__))
464#define read(...) (pthread_testcancel(), read(__VA_ARGS__))
465#define readv(...) (pthread_testcancel(), readv(__VA_ARGS__))
466#define recv(...) (pthread_testcancel(), recv(__VA_ARGS__))
467#define recvfrom(...) (pthread_testcancel(), recvfrom(__VA_ARGS__))
468#define recvmsg(...) (pthread_testcancel(), recvmsg(__VA_ARGS__))
469#define select(...) (pthread_testcancel(), select(__VA_ARGS__))
470#define sem_timedwait(...) (pthread_testcancel(), sem_timedwait(__VA_ARGS__))
471#define sem_wait(...) (pthread_testcancel(), sem_wait(__VA_ARGS__))
472#define send(...) (pthread_testcancel(), send(__VA_ARGS__))
473#define sendmsg(...) (pthread_testcancel(), sendmsg(__VA_ARGS__))
474#define sendto(...) (pthread_testcancel(), sendto(__VA_ARGS__))
475#define sigpause(...) (pthread_testcancel(), sigpause(__VA_ARGS__))
476#define sigsuspend(...) (pthread_testcancel(), sigsuspend(__VA_ARGS__))
477#define sigwait(...) (pthread_testcancel(), sigwait(__VA_ARGS__))
478#define sigwaitinfo(...) (pthread_testcancel(), sigwaitinfo(__VA_ARGS__))
479#define sleep(...) (pthread_testcancel(), sleep(__VA_ARGS__))
480//#define Sleep(...) (pthread_testcancel(), Sleep(__VA_ARGS__))
481#define system(...) (pthread_testcancel(), system(__VA_ARGS__))
482#define access(...) (pthread_testcancel(), access(__VA_ARGS__))
483#define asctime(...) (pthread_testcancel(), asctime(__VA_ARGS__))
484#define catclose(...) (pthread_testcancel(), catclose(__VA_ARGS__))
485#define catgets(...) (pthread_testcancel(), catgets(__VA_ARGS__))
486#define catopen(...) (pthread_testcancel(), catopen(__VA_ARGS__))
487#define closedir(...) (pthread_testcancel(), closedir(__VA_ARGS__))
488#define closelog(...) (pthread_testcancel(), closelog(__VA_ARGS__))
489#define ctermid(...) (pthread_testcancel(), ctermid(__VA_ARGS__))
490#define ctime(...) (pthread_testcancel(), ctime(__VA_ARGS__))
491#define dbm_close(...) (pthread_testcancel(), dbm_close(__VA_ARGS__))
492#define dbm_delete(...) (pthread_testcancel(), dbm_delete(__VA_ARGS__))
493#define dbm_fetch(...) (pthread_testcancel(), dbm_fetch(__VA_ARGS__))
494#define dbm_nextkey(...) (pthread_testcancel(), dbm_nextkey(__VA_ARGS__))
495#define dbm_open(...) (pthread_testcancel(), dbm_open(__VA_ARGS__))
496#define dbm_store(...) (pthread_testcancel(), dbm_store(__VA_ARGS__))
497#define dlclose(...) (pthread_testcancel(), dlclose(__VA_ARGS__))
498#define dlopen(...) (pthread_testcancel(), dlopen(__VA_ARGS__))
499#define endgrent(...) (pthread_testcancel(), endgrent(__VA_ARGS__))
500#define endhostent(...) (pthread_testcancel(), endhostent(__VA_ARGS__))
501#define endnetent(...) (pthread_testcancel(), endnetent(__VA_ARGS__))
502#define endprotoent(...) (pthread_testcancel(), endprotoend(__VA_ARGS__))
503#define endpwent(...) (pthread_testcancel(), endpwent(__VA_ARGS__))
504#define endservent(...) (pthread_testcancel(), endservent(__VA_ARGS__))
505#define endutxent(...) (pthread_testcancel(), endutxent(__VA_ARGS__))
506#define fclose(...) (pthread_testcancel(), fclose(__VA_ARGS__))
507#define fflush(...) (pthread_testcancel(), fflush(__VA_ARGS__))
508#define fgetc(...) (pthread_testcancel(), fgetc(__VA_ARGS__))
509#define fgetpos(...) (pthread_testcancel(), fgetpos(__VA_ARGS__))
510#define fgets(...) (pthread_testcancel(), fgets(__VA_ARGS__))
511#define fgetwc(...) (pthread_testcancel(), fgetwc(__VA_ARGS__))
512#define fgetws(...) (pthread_testcancel(), fgetws(__VA_ARGS__))
513#define fmtmsg(...) (pthread_testcancel(), fmtmsg(__VA_ARGS__))
514#define fopen(...) (pthread_testcancel(), fopen(__VA_ARGS__))
515#define fpathconf(...) (pthread_testcancel(), fpathconf(__VA_ARGS__))
516#define fprintf(...) (pthread_testcancel(), fprintf(__VA_ARGS__))
517#define fputc(...) (pthread_testcancel(), fputc(__VA_ARGS__))
518#define fputs(...) (pthread_testcancel(), fputs(__VA_ARGS__))
519#define fputwc(...) (pthread_testcancel(), fputwc(__VA_ARGS__))
520#define fputws(...) (pthread_testcancel(), fputws(__VA_ARGS__))
521#define fread(...) (pthread_testcancel(), fread(__VA_ARGS__))
522#define freopen(...) (pthread_testcancel(), freopen(__VA_ARGS__))
523#define fscanf(...) (pthread_testcancel(), fscanf(__VA_ARGS__))
524#define fseek(...) (pthread_testcancel(), fseek(__VA_ARGS__))
525#define fseeko(...) (pthread_testcancel(), fseeko(__VA_ARGS__))
526#define fsetpos(...) (pthread_testcancel(), fsetpos(__VA_ARGS__))
527#define fstat(...) (pthread_testcancel(), fstat(__VA_ARGS__))
528#define ftell(...) (pthread_testcancel(), ftell(__VA_ARGS__))
529#define ftello(...) (pthread_testcancel(), ftello(__VA_ARGS__))
530#define ftw(...) (pthread_testcancel(), ftw(__VA_ARGS__))
531#define fwprintf(...) (pthread_testcancel(), fwprintf(__VA_ARGS__))
532#define fwrite(...) (pthread_testcancel(), fwrite(__VA_ARGS__))
533#define fwscanf(...) (pthread_testcancel(), fwscanf(__VA_ARGS__))
534#define getaddrinfo(...) (pthread_testcancel(), getaddrinfo(__VA_ARGS__))
535#define getc(...) (pthread_testcancel(), getc(__VA_ARGS__))
536#define getc_unlocked(...) (pthread_testcancel(), getc_unlocked(__VA_ARGS__))
537#define getchar(...) (pthread_testcancel(), getchar(__VA_ARGS__))
538#define getchar_unlocked(...) (pthread_testcancel(), getchar_unlocked(__VA_ARGS__))
539#define getcwd(...) (pthread_testcancel(), getcwd(__VA_ARGS__))
540#define getdate(...) (pthread_testcancel(), getdate(__VA_ARGS__))
541#define getgrent(...) (pthread_testcancel(), getgrent(__VA_ARGS__))
542#define getgrgid(...) (pthread_testcancel(), getgrgid(__VA_ARGS__))
543#define getgrgid_r(...) (pthread_testcancel(), getgrgid_r(__VA_ARGS__))
544#define gergrnam(...) (pthread_testcancel(), getgrnam(__VA_ARGS__))
545#define getgrnam_r(...) (pthread_testcancel(), getgrnam_r(__VA_ARGS__))
546#define gethostbyaddr(...) (pthread_testcancel(), gethostbyaddr(__VA_ARGS__))
547#define gethostbyname(...) (pthread_testcancel(), gethostbyname(__VA_ARGS__))
548#define gethostent(...) (pthread_testcancel(), gethostent(__VA_ARGS__))
549#define gethostid(...) (pthread_testcancel(), gethostid(__VA_ARGS__))
550#define gethostname(...) (pthread_testcancel(), gethostname(__VA_ARGS__))
551#define getlogin(...) (pthread_testcancel(), getlogin(__VA_ARGS__))
552#define getlogin_r(...) (pthread_testcancel(), getlogin_r(__VA_ARGS__))
553#define getnameinfo(...) (pthread_testcancel(), getnameinfo(__VA_ARGS__))
554#define getnetbyaddr(...) (pthread_testcancel(), getnetbyaddr(__VA_ARGS__))
555#define getnetbyname(...) (pthread_testcancel(), getnetbyname(__VA_ARGS__))
556#define getnetent(...) (pthread_testcancel(), getnetent(__VA_ARGS__))
557#define getopt(...) (pthread_testcancel(), getopt(__VA_ARGS__))
558#define getprotobyname(...) (pthread_testcancel(), getprotobyname(__VA_ARGS__))
559#define getprotobynumber(...) (pthread_testcancel(), getprotobynumber(__VA_ARGS__))
560#define getprotoent(...) (pthread_testcancel(), getprotoent(__VA_ARGS__))
561#define getpwent(...) (pthread_testcancel(), getpwent(__VA_ARGS__))
562#define getpwnam(...) (pthread_testcancel(), getpwnam(__VA_ARGS__))
563#define getpwnam_r(...) (pthread_testcancel(), getpwnam_r(__VA_ARGS__))
564#define getpwuid(...) (pthread_testcancel(), getpwuid(__VA_ARGS__))
565#define getpwuid_r(...) (pthread_testcancel(), getpwuid_r(__VA_ARGS__))
566#define gets(...) (pthread_testcancel(), gets(__VA_ARGS__))
567#define getservbyname(...) (pthread_testcancel(), getservbyname(__VA_ARGS__))
568#define getservbyport(...) (pthread_testcancel(), getservbyport(__VA_ARGS__))
569#define getservent(...) (pthread_testcancel(), getservent(__VA_ARGS__))
570#define getutxent(...) (pthread_testcancel(), getutxent(__VA_ARGS__))
571#define getutxid(...) (pthread_testcancel(), getutxid(__VA_ARGS__))
572#define getutxline(...) (pthread_testcancel(), getutxline(__VA_ARGS__))
573#undef getwc
574#define getwc(...) (pthread_testcancel(), getwc(__VA_ARGS__))
575#undef getwchar
576#define getwchar(...) (pthread_testcancel(), getwchar(__VA_ARGS__))
577#define getwd(...) (pthread_testcancel(), getwd(__VA_ARGS__))
578#define glob(...) (pthread_testcancel(), glob(__VA_ARGS__))
579#define iconv_close(...) (pthread_testcancel(), iconv_close(__VA_ARGS__))
580#define iconv_open(...) (pthread_testcancel(), iconv_open(__VA_ARGS__))
581#define ioctl(...) (pthread_testcancel(), ioctl(__VA_ARGS__))
582#define link(...) (pthread_testcancel(), link(__VA_ARGS__))
583#define localtime(...) (pthread_testcancel(), localtime(__VA_ARGS__))
584#define lseek(...) (pthread_testcancel(), lseek(__VA_ARGS__))
585#define lstat(...) (pthread_testcancel(), lstat(__VA_ARGS__))
586#define mkstemp(...) (pthread_testcancel(), mkstemp(__VA_ARGS__))
587#define nftw(...) (pthread_testcancel(), nftw(__VA_ARGS__))
588#define opendir(...) (pthread_testcancel(), opendir(__VA_ARGS__))
589#define openlog(...) (pthread_testcancel(), openlog(__VA_ARGS__))
590#define pathconf(...) (pthread_testcancel(), pathconf(__VA_ARGS__))
591#define pclose(...) (pthread_testcancel(), pclose(__VA_ARGS__))
592#define perror(...) (pthread_testcancel(), perror(__VA_ARGS__))
593#define popen(...) (pthread_testcancel(), popen(__VA_ARGS__))
594#define posix_fadvise(...) (pthread_testcancel(), posix_fadvise(__VA_ARGS__))
595#define posix_fallocate(...) (pthread_testcancel(), posix_fallocate(__VA_ARGS__))
596#define posix_madvise(...) (pthread_testcancel(), posix_madvise(__VA_ARGS__))
597#define posix_openpt(...) (pthread_testcancel(), posix_openpt(__VA_ARGS__))
598#define posix_spawn(...) (pthread_testcancel(), posix_spawn(__VA_ARGS__))
599#define posix_spawnp(...) (pthread_testcancel(), posix_spawnp(__VA_ARGS__))
600#define posix_trace_clear(...) (pthread_testcancel(), posix_trace_clear(__VA_ARGS__))
601#define posix_trace_close(...) (pthread_testcancel(), posix_trace_close(__VA_ARGS__))
602#define posix_trace_create(...) (pthread_testcancel(), posix_trace_create(__VA_ARGS__))
603#define posix_trace_create_withlog(...) (pthread_testcancel(), posix_trace_create_withlog(__VA_ARGS__))
604#define posix_trace_eventtypelist_getne(...) (pthread_testcancel(), posix_trace_eventtypelist_getne(__VA_ARGS__))
605#define posix_trace_eventtypelist_rewin(...) (pthread_testcancel(), posix_trace_eventtypelist_rewin(__VA_ARGS__))
606#define posix_trace_flush(...) (pthread_testcancel(), posix_trace_flush(__VA_ARGS__))
607#define posix_trace_get_attr(...) (pthread_testcancel(), posix_trace_get_attr(__VA_ARGS__))
608#define posix_trace_get_filter(...) (pthread_testcancel(), posix_trace_get_filter(__VA_ARGS__))
609#define posix_trace_get_status(...) (pthread_testcancel(), posix_trace_get_status(__VA_ARGS__))
610#define posix_trace_getnext_event(...) (pthread_testcancel(), posix_trace_getnext_event(__VA_ARGS__))
611#define posix_trace_open(...) (pthread_testcancel(), posix_trace_open(__VA_ARGS__))
612#define posix_trace_rewind(...) (pthread_testcancel(), posix_trace_rewind(__VA_ARGS__))
613#define posix_trace_setfilter(...) (pthread_testcancel(), posix_trace_setfilter(__VA_ARGS__))
614#define posix_trace_shutdown(...) (pthread_testcancel(), posix_trace_shutdown(__VA_ARGS__))
615#define posix_trace_timedgetnext_event(...) (pthread_testcancel(), posix_trace_timedgetnext_event(__VA_ARGS__))
616#define posix_typed_mem_open(...) (pthread_testcancel(), posix_typed_mem_open(__VA_ARGS__))
617#define printf(...) (pthread_testcancel(), printf(__VA_ARGS__))
618#define putc(...) (pthread_testcancel(), putc(__VA_ARGS__))
619#define putc_unlocked(...) (pthread_testcancel(), putc_unlocked(__VA_ARGS__))
620#define putchar(...) (pthread_testcancel(), putchar(__VA_ARGS__))
621#define putchar_unlocked(...) (pthread_testcancel(), putchar_unlocked(__VA_ARGS__))
622#define puts(...) (pthread_testcancel(), puts(__VA_ARGS__))
623#define pututxline(...) (pthread_testcancel(), pututxline(__VA_ARGS__))
624#undef putwc
625#define putwc(...) (pthread_testcancel(), putwc(__VA_ARGS__))
626#undef putwchar
627#define putwchar(...) (pthread_testcancel(), putwchar(__VA_ARGS__))
628#define readdir(...) (pthread_testcancel(), readdir(__VA_ARSG__))
629#define readdir_r(...) (pthread_testcancel(), readdir_r(__VA_ARGS__))
630#define remove(...) (pthread_testcancel(), remove(__VA_ARGS__))
631#define rename(...) (pthread_testcancel(), rename(__VA_ARGS__))
632#define rewind(...) (pthread_testcancel(), rewind(__VA_ARGS__))
633#define rewinddir(...) (pthread_testcancel(), rewinddir(__VA_ARGS__))
634#define scanf(...) (pthread_testcancel(), scanf(__VA_ARGS__))
635#define seekdir(...) (pthread_testcancel(), seekdir(__VA_ARGS__))
636#define semop(...) (pthread_testcancel(), semop(__VA_ARGS__))
637#define setgrent(...) (pthread_testcancel(), setgrent(__VA_ARGS__))
638#define sethostent(...) (pthread_testcancel(), sethostemt(__VA_ARGS__))
639#define setnetent(...) (pthread_testcancel(), setnetent(__VA_ARGS__))
640#define setprotoent(...) (pthread_testcancel(), setprotoent(__VA_ARGS__))
641#define setpwent(...) (pthread_testcancel(), setpwent(__VA_ARGS__))
642#define setservent(...) (pthread_testcancel(), setservent(__VA_ARGS__))
643#define setutxent(...) (pthread_testcancel(), setutxent(__VA_ARGS__))
644#define stat(...) (pthread_testcancel(), stat(__VA_ARGS__))
645#define strerror(...) (pthread_testcancel(), strerror(__VA_ARGS__))
646#define strerror_r(...) (pthread_testcancel(), strerror_r(__VA_ARGS__))
647#define strftime(...) (pthread_testcancel(), strftime(__VA_ARGS__))
648#define symlink(...) (pthread_testcancel(), symlink(__VA_ARGS__))
649#define sync(...) (pthread_testcancel(), sync(__VA_ARGS__))
650#define syslog(...) (pthread_testcancel(), syslog(__VA_ARGS__))
651#define tmpfile(...) (pthread_testcancel(), tmpfile(__VA_ARGS__))
652#define tmpnam(...) (pthread_testcancel(), tmpnam(__VA_ARGS__))
653#define ttyname(...) (pthread_testcancel(), ttyname(__VA_ARGS__))
654#define ttyname_r(...) (pthread_testcancel(), ttyname_r(__VA_ARGS__))
655#define tzset(...) (pthread_testcancel(), tzset(__VA_ARGS__))
656#define ungetc(...) (pthread_testcancel(), ungetc(__VA_ARGS__))
657#define ungetwc(...) (pthread_testcancel(), ungetwc(__VA_ARGS__))
658#define unlink(...) (pthread_testcancel(), unlink(__VA_ARGS__))
659#define vfprintf(...) (pthread_testcancel(), vfprintf(__VA_ARGS__))
660#define vfwprintf(...) (pthread_testcancel(), vfwprintf(__VA_ARGS__))
661#define vprintf(...) (pthread_testcancel(), vprintf(__VA_ARGS__))
662#define vwprintf(...) (pthread_testcancel(), vwprintf(__VA_ARGS__))
663#define wcsftime(...) (pthread_testcancel(), wcsftime(__VA_ARGS__))
664#define wordexp(...) (pthread_testcancel(), wordexp(__VA_ARGS__))
665#define wprintf(...) (pthread_testcancel(), wprintf(__VA_ARGS__))
666#define wscanf(...) (pthread_testcancel(), wscanf(__VA_ARGS__))
667#endif
668
669/* We deal here with a gcc issue for posix threading on Windows.
670 We would need to change here gcc's gthr-posix.h header, but this
671 got rejected. So we deal it within this header. */
672#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
673#undef _GTHREAD_USE_MUTEX_INIT_FUNC
674#endif
675#define _GTHREAD_USE_MUTEX_INIT_FUNC 1
676
677#ifdef __cplusplus
678}
679#endif
680
681#endif /* WIN_PTHREADS_H */
Note: See TracBrowser for help on using the repository browser.