pthread.h
0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010:
0011:
0012:
0013:
0014:
0015:
0016:
0017:
0018:
0019:
0020: #ifndef _PTHREAD_H
0021: #define _PTHREAD_H 1
0022:
0023: #include <features.h>
0024: #include <endian.h>
0025: #include <sched.h>
0026: #include <time.h>
0027:
0028: #include <bits/pthreadtypes.h>
0029: #include <bits/setjmp.h>
0030: #include <bits/wordsize.h>
0031:
0032:
0033:
0034: enum
0035: {
0036: PTHREAD_CREATE_JOINABLE,
0037: #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
0038: PTHREAD_CREATE_DETACHED
0039: #define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
0040: };
0041:
0042:
0043:
0044: enum
0045: {
0046: PTHREAD_MUTEX_TIMED_NP,
0047: PTHREAD_MUTEX_RECURSIVE_NP,
0048: PTHREAD_MUTEX_ERRORCHECK_NP,
0049: PTHREAD_MUTEX_ADAPTIVE_NP
0050: #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
0051: ,
0052: PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
0053: PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
0054: PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
0055: PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
0056: #endif
0057: #ifdef __USE_GNU
0058:
0059: , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
0060: #endif
0061: };
0062:
0063:
0064: #ifdef __USE_XOPEN2K
0065:
0066: enum
0067: {
0068: PTHREAD_MUTEX_STALLED,
0069: PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
0070: PTHREAD_MUTEX_ROBUST,
0071: PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
0072: };
0073: #endif
0074:
0075:
0076: #ifdef __USE_UNIX98
0077:
0078: enum
0079: {
0080: PTHREAD_PRIO_NONE,
0081: PTHREAD_PRIO_INHERIT,
0082: PTHREAD_PRIO_PROTECT
0083: };
0084: #endif
0085:
0086:
0087:
0088: #if __WORDSIZE == 64
0089: # define PTHREAD_MUTEX_INITIALIZER \
0090: { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }
0091: # ifdef __USE_GNU
0092: # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
0093: { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0, 0 } } }
0094: # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
0095: { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0, 0 } } }
0096: # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
0097: { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0, 0 } } }
0098: # endif
0099: #else
0100: # define PTHREAD_MUTEX_INITIALIZER \
0101: { { 0, 0, 0, 0, 0, { 0 } } }
0102: # ifdef __USE_GNU
0103: # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
0104: { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0 } } }
0105: # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
0106: { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0 } } }
0107: # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
0108: { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0 } } }
0109: # endif
0110: #endif
0111:
0112:
0113:
0114: #if defined __USE_UNIX98 || defined __USE_XOPEN2K
0115: enum
0116: {
0117: PTHREAD_RWLOCK_PREFER_READER_NP,
0118: PTHREAD_RWLOCK_PREFER_WRITER_NP,
0119: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
0120: PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
0121: };
0122:
0123:
0124: # define PTHREAD_RWLOCK_INITIALIZER \
0125: { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
0126: # ifdef __USE_GNU
0127: # if __WORDSIZE == 64
0128: # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
0129: { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0130: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
0131: # else
0132: # if __BYTE_ORDER == __LITTLE_ENDIAN
0133: # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
0134: { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
0135: 0, 0, 0, 0 } }
0136: # else
0137: # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
0138: { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
0139: 0 } }
0140: # endif
0141: # endif
0142: # endif
0143: #endif
0144:
0145:
0146:
0147: enum
0148: {
0149: PTHREAD_INHERIT_SCHED,
0150: #define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
0151: PTHREAD_EXPLICIT_SCHED
0152: #define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
0153: };
0154:
0155:
0156:
0157: enum
0158: {
0159: PTHREAD_SCOPE_SYSTEM,
0160: #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
0161: PTHREAD_SCOPE_PROCESS
0162: #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
0163: };
0164:
0165:
0166:
0167: enum
0168: {
0169: PTHREAD_PROCESS_PRIVATE,
0170: #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
0171: PTHREAD_PROCESS_SHARED
0172: #define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
0173: };
0174:
0175:
0176:
0177:
0178: #define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
0179:
0180:
0181:
0182: struct _pthread_cleanup_buffer
0183: {
0184: void (*__routine) (void *);
0185: void *__arg;
0186: int __canceltype;
0187: struct _pthread_cleanup_buffer *__prev;
0188: };
0189:
0190:
0191: enum
0192: {
0193: PTHREAD_CANCEL_ENABLE,
0194: #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
0195: PTHREAD_CANCEL_DISABLE
0196: #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
0197: };
0198: enum
0199: {
0200: PTHREAD_CANCEL_DEFERRED,
0201: #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
0202: PTHREAD_CANCEL_ASYNCHRONOUS
0203: #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
0204: };
0205: #define PTHREAD_CANCELED ((void *) -1)
0206:
0207:
0208:
0209: #define PTHREAD_ONCE_INIT 0
0210:
0211:
0212: #ifdef __USE_XOPEN2K
0213:
0214:
0215:
0216: # define PTHREAD_BARRIER_SERIAL_THREAD -1
0217: #endif
0218:
0219:
0220: __BEGIN_DECLS
0221:
0222:
0223:
0224:
0225: extern int pthread_create (pthread_t *__restrict __newthread,
0226: __const pthread_attr_t *__restrict __attr,
0227: void *(*__start_routine) (void *),
0228: void *__restrict __arg) __THROWNL __nonnull ((1, 3));
0229:
0230:
0231:
0232:
0233:
0234: extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
0235:
0236:
0237:
0238:
0239:
0240:
0241:
0242: extern int pthread_join (pthread_t __th, void **__thread_return);
0243:
0244: #ifdef __USE_GNU
0245:
0246:
0247: extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
0248:
0249:
0250:
0251:
0252:
0253:
0254:
0255: extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
0256: __const struct timespec *__abstime);
0257: #endif
0258:
0259:
0260:
0261:
0262:
0263: extern int pthread_detach (pthread_t __th) __THROW;
0264:
0265:
0266:
0267: extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
0268:
0269:
0270: extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __THROW;
0271:
0272:
0273:
0274:
0275:
0276:
0277:
0278: extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
0279:
0280:
0281: extern int pthread_attr_destroy (pthread_attr_t *__attr)
0282: __THROW __nonnull ((1));
0283:
0284:
0285: extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
0286: int *__detachstate)
0287: __THROW __nonnull ((1, 2));
0288:
0289:
0290: extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
0291: int __detachstate)
0292: __THROW __nonnull ((1));
0293:
0294:
0295:
0296: extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr,
0297: size_t *__guardsize)
0298: __THROW __nonnull ((1, 2));
0299:
0300:
0301: extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
0302: size_t __guardsize)
0303: __THROW __nonnull ((1));
0304:
0305:
0306:
0307: extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
0308: __attr,
0309: struct sched_param *__restrict __param)
0310: __THROW __nonnull ((1, 2));
0311:
0312:
0313: extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
0314: __const struct sched_param *__restrict
0315: __param) __THROW __nonnull ((1, 2));
0316:
0317:
0318: extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
0319: __attr, int *__restrict __policy)
0320: __THROW __nonnull ((1, 2));
0321:
0322:
0323: extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
0324: __THROW __nonnull ((1));
0325:
0326:
0327: extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
0328: __attr, int *__restrict __inherit)
0329: __THROW __nonnull ((1, 2));
0330:
0331:
0332: extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
0333: int __inherit)
0334: __THROW __nonnull ((1));
0335:
0336:
0337:
0338: extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
0339: int *__restrict __scope)
0340: __THROW __nonnull ((1, 2));
0341:
0342:
0343: extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
0344: __THROW __nonnull ((1));
0345:
0346:
0347: extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
0348: __attr, void **__restrict __stackaddr)
0349: __THROW __nonnull ((1, 2)) __attribute_deprecated__;
0350:
0351:
0352:
0353:
0354:
0355: extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
0356: void *__stackaddr)
0357: __THROW __nonnull ((1)) __attribute_deprecated__;
0358:
0359:
0360: extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
0361: __attr, size_t *__restrict __stacksize)
0362: __THROW __nonnull ((1, 2));
0363:
0364:
0365:
0366:
0367: extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
0368: size_t __stacksize)
0369: __THROW __nonnull ((1));
0370:
0371: #ifdef __USE_XOPEN2K
0372:
0373: extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
0374: void **__restrict __stackaddr,
0375: size_t *__restrict __stacksize)
0376: __THROW __nonnull ((1, 2, 3));
0377:
0378:
0379:
0380:
0381: extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
0382: size_t __stacksize) __THROW __nonnull ((1));
0383: #endif
0384:
0385: #ifdef __USE_GNU
0386:
0387:
0388: extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
0389: size_t __cpusetsize,
0390: __const cpu_set_t *__cpuset)
0391: __THROW __nonnull ((1, 3));
0392:
0393:
0394:
0395: extern int pthread_attr_getaffinity_np (__const pthread_attr_t *__attr,
0396: size_t __cpusetsize,
0397: cpu_set_t *__cpuset)
0398: __THROW __nonnull ((1, 3));
0399:
0400:
0401:
0402:
0403:
0404: extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
0405: __THROW __nonnull ((2));
0406: #endif
0407:
0408:
0409:
0410:
0411:
0412:
0413: extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
0414: __const struct sched_param *__param)
0415: __THROW __nonnull ((3));
0416:
0417:
0418: extern int pthread_getschedparam (pthread_t __target_thread,
0419: int *__restrict __policy,
0420: struct sched_param *__restrict __param)
0421: __THROW __nonnull ((2, 3));
0422:
0423:
0424: extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
0425: __THROW;
0426:
0427:
0428: #ifdef __USE_GNU
0429:
0430: extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
0431: size_t __buflen)
0432: __THROW __nonnull ((2));
0433:
0434:
0435: extern int pthread_setname_np (pthread_t __target_thread, __const char *__name)
0436: __THROW __nonnull ((2));
0437: #endif
0438:
0439:
0440: #ifdef __USE_UNIX98
0441:
0442: extern int pthread_getconcurrency (void) __THROW;
0443:
0444:
0445: extern int pthread_setconcurrency (int __level) __THROW;
0446: #endif
0447:
0448: #ifdef __USE_GNU
0449:
0450:
0451:
0452:
0453: extern int pthread_yield (void) __THROW;
0454:
0455:
0456:
0457:
0458: extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
0459: __const cpu_set_t *__cpuset)
0460: __THROW __nonnull ((3));
0461:
0462:
0463: extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
0464: cpu_set_t *__cpuset)
0465: __THROW __nonnull ((3));
0466: #endif
0467:
0468:
0469:
0470:
0471:
0472:
0473:
0474:
0475:
0476:
0477:
0478: extern int pthread_once (pthread_once_t *__once_control,
0479: void (*__init_routine) (void)) __nonnull ((1, 2));
0480:
0481:
0482:
0483:
0484:
0485:
0486:
0487:
0488:
0489:
0490: extern int pthread_setcancelstate (int __state, int *__oldstate);
0491:
0492:
0493:
0494: extern int pthread_setcanceltype (int __type, int *__oldtype);
0495:
0496:
0497: extern int pthread_cancel (pthread_t __th);
0498:
0499:
0500:
0501:
0502: extern void pthread_testcancel (void);
0503:
0504:
0505:
0506:
0507: typedef struct
0508: {
0509: struct
0510: {
0511: __jmp_buf __cancel_jmp_buf;
0512: int __mask_was_saved;
0513: } __cancel_jmp_buf[1];
0514: void *__pad[4];
0515: } __pthread_unwind_buf_t __attribute__ ((__aligned__));
0516:
0517:
0518: #ifndef __cleanup_fct_attribute
0519: # define __cleanup_fct_attribute
0520: #endif
0521:
0522:
0523:
0524: struct __pthread_cleanup_frame
0525: {
0526: void (*__cancel_routine) (void *);
0527: void *__cancel_arg;
0528: int __do_it;
0529: int __cancel_type;
0530: };
0531:
0532: #if defined __GNUC__ && defined __EXCEPTIONS
0533: # ifdef __cplusplus
0534:
0535: class __pthread_cleanup_class
0536: {
0537: void (*__cancel_routine) (void *);
0538: void *__cancel_arg;
0539: int __do_it;
0540: int __cancel_type;
0541:
0542: public:
0543: __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
0544: : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
0545: ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
0546: void __setdoit (int __newval) { __do_it = __newval; }
0547: void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
0548: &__cancel_type); }
0549: void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
0550: };
0551:
0552:
0553:
0554:
0555:
0556:
0557:
0558:
0559: # define pthread_cleanup_push(routine, arg) \
0560: do { \
0561: __pthread_cleanup_class __clframe (routine, arg)
0562:
0563:
0564:
0565: # define pthread_cleanup_pop(execute) \
0566: __clframe.__setdoit (execute); \
0567: } while (0)
0568:
0569: # ifdef __USE_GNU
0570:
0571:
0572:
0573: # define pthread_cleanup_push_defer_np(routine, arg) \
0574: do { \
0575: __pthread_cleanup_class __clframe (routine, arg); \
0576: __clframe.__defer ()
0577:
0578:
0579:
0580:
0581: # define pthread_cleanup_pop_restore_np(execute) \
0582: __clframe.__restore (); \
0583: __clframe.__setdoit (execute); \
0584: } while (0)
0585: # endif
0586: # else
0587:
0588:
0589:
0590:
0591: __extern_inline void
0592: __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
0593: {
0594: if (__frame->__do_it)
0595: __frame->__cancel_routine (__frame->__cancel_arg);
0596: }
0597:
0598:
0599:
0600:
0601:
0602:
0603:
0604:
0605: # define pthread_cleanup_push(routine, arg) \
0606: do { \
0607: struct __pthread_cleanup_frame __clframe \
0608: __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
0609: = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
0610: .__do_it = 1 };
0611:
0612:
0613:
0614: # define pthread_cleanup_pop(execute) \
0615: __clframe.__do_it = (execute); \
0616: } while (0)
0617:
0618: # ifdef __USE_GNU
0619:
0620:
0621:
0622: # define pthread_cleanup_push_defer_np(routine, arg) \
0623: do { \
0624: struct __pthread_cleanup_frame __clframe \
0625: __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
0626: = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
0627: .__do_it = 1 }; \
0628: (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
0629: &__clframe.__cancel_type)
0630:
0631:
0632:
0633:
0634: # define pthread_cleanup_pop_restore_np(execute) \
0635: (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
0636: __clframe.__do_it = (execute); \
0637: } while (0)
0638: # endif
0639: # endif
0640: #else
0641:
0642:
0643:
0644:
0645:
0646:
0647:
0648: # define pthread_cleanup_push(routine, arg) \
0649: do { \
0650: __pthread_unwind_buf_t __cancel_buf; \
0651: void (*__cancel_routine) (void *) = (routine); \
0652: void *__cancel_arg = (arg); \
0653: int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
0654: __cancel_buf.__cancel_jmp_buf, 0); \
0655: if (__builtin_expect (__not_first_call, 0)) \
0656: { \
0657: __cancel_routine (__cancel_arg); \
0658: __pthread_unwind_next (&__cancel_buf); \
0659: \
0660: } \
0661: \
0662: __pthread_register_cancel (&__cancel_buf); \
0663: do {
0664: extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
0665: __cleanup_fct_attribute;
0666:
0667:
0668:
0669: # define pthread_cleanup_pop(execute) \
0670: do { } while (0);\
0671: } while (0); \
0672: __pthread_unregister_cancel (&__cancel_buf); \
0673: if (execute) \
0674: __cancel_routine (__cancel_arg); \
0675: } while (0)
0676: extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
0677: __cleanup_fct_attribute;
0678:
0679: # ifdef __USE_GNU
0680:
0681:
0682:
0683: # define pthread_cleanup_push_defer_np(routine, arg) \
0684: do { \
0685: __pthread_unwind_buf_t __cancel_buf; \
0686: void (*__cancel_routine) (void *) = (routine); \
0687: void *__cancel_arg = (arg); \
0688: int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
0689: __cancel_buf.__cancel_jmp_buf, 0); \
0690: if (__builtin_expect (__not_first_call, 0)) \
0691: { \
0692: __cancel_routine (__cancel_arg); \
0693: __pthread_unwind_next (&__cancel_buf); \
0694: \
0695: } \
0696: \
0697: __pthread_register_cancel_defer (&__cancel_buf); \
0698: do {
0699: extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
0700: __cleanup_fct_attribute;
0701:
0702:
0703:
0704:
0705: # define pthread_cleanup_pop_restore_np(execute) \
0706: do { } while (0);\
0707: } while (0); \
0708: __pthread_unregister_cancel_restore (&__cancel_buf); \
0709: if (execute) \
0710: __cancel_routine (__cancel_arg); \
0711: } while (0)
0712: extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
0713: __cleanup_fct_attribute;
0714: # endif
0715:
0716:
0717: extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
0718: __cleanup_fct_attribute __attribute__ ((__noreturn__))
0719: # ifndef SHARED
0720: __attribute__ ((__weak__))
0721: # endif
0722: ;
0723: #endif
0724:
0725:
0726: struct __jmp_buf_tag;
0727: extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROW;
0728:
0729:
0730:
0731:
0732:
0733: extern int pthread_mutex_init (pthread_mutex_t *__mutex,
0734: __const pthread_mutexattr_t *__mutexattr)
0735: __THROW __nonnull ((1));
0736:
0737:
0738: extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
0739: __THROW __nonnull ((1));
0740:
0741:
0742: extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
0743: __THROWNL __nonnull ((1));
0744:
0745:
0746: extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
0747: __THROWNL __nonnull ((1));
0748:
0749: #ifdef __USE_XOPEN2K
0750:
0751: extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
0752: __const struct timespec *__restrict
0753: __abstime) __THROWNL __nonnull ((1, 2));
0754: #endif
0755:
0756:
0757: extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
0758: __THROWNL __nonnull ((1));
0759:
0760:
0761:
0762: extern int pthread_mutex_getprioceiling (__const pthread_mutex_t *
0763: __restrict __mutex,
0764: int *__restrict __prioceiling)
0765: __THROW __nonnull ((1, 2));
0766:
0767:
0768:
0769: extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
0770: int __prioceiling,
0771: int *__restrict __old_ceiling)
0772: __THROW __nonnull ((1, 3));
0773:
0774:
0775: #ifdef __USE_XOPEN2K8
0776:
0777: extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
0778: __THROW __nonnull ((1));
0779: # ifdef __USE_GNU
0780: extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
0781: __THROW __nonnull ((1));
0782: # endif
0783: #endif
0784:
0785:
0786:
0787:
0788:
0789:
0790: extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
0791: __THROW __nonnull ((1));
0792:
0793:
0794: extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
0795: __THROW __nonnull ((1));
0796:
0797:
0798: extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
0799: __restrict __attr,
0800: int *__restrict __pshared)
0801: __THROW __nonnull ((1, 2));
0802:
0803:
0804: extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
0805: int __pshared)
0806: __THROW __nonnull ((1));
0807:
0808: #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
0809:
0810: extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
0811: __attr, int *__restrict __kind)
0812: __THROW __nonnull ((1, 2));
0813:
0814:
0815:
0816:
0817: extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
0818: __THROW __nonnull ((1));
0819: #endif
0820:
0821:
0822: extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t *
0823: __restrict __attr,
0824: int *__restrict __protocol)
0825: __THROW __nonnull ((1, 2));
0826:
0827:
0828:
0829: extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
0830: int __protocol)
0831: __THROW __nonnull ((1));
0832:
0833:
0834: extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t *
0835: __restrict __attr,
0836: int *__restrict __prioceiling)
0837: __THROW __nonnull ((1, 2));
0838:
0839:
0840: extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
0841: int __prioceiling)
0842: __THROW __nonnull ((1));
0843:
0844: #ifdef __USE_XOPEN2K
0845:
0846: extern int pthread_mutexattr_getrobust (__const pthread_mutexattr_t *__attr,
0847: int *__robustness)
0848: __THROW __nonnull ((1, 2));
0849: # ifdef __USE_GNU
0850: extern int pthread_mutexattr_getrobust_np (__const pthread_mutexattr_t *__attr,
0851: int *__robustness)
0852: __THROW __nonnull ((1, 2));
0853: # endif
0854:
0855:
0856: extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
0857: int __robustness)
0858: __THROW __nonnull ((1));
0859: # ifdef __USE_GNU
0860: extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
0861: int __robustness)
0862: __THROW __nonnull ((1));
0863: # endif
0864: #endif
0865:
0866:
0867: #if defined __USE_UNIX98 || defined __USE_XOPEN2K
0868:
0869:
0870:
0871:
0872: extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
0873: __const pthread_rwlockattr_t *__restrict
0874: __attr) __THROW __nonnull ((1));
0875:
0876:
0877: extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
0878: __THROW __nonnull ((1));
0879:
0880:
0881: extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
0882: __THROWNL __nonnull ((1));
0883:
0884:
0885: extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
0886: __THROWNL __nonnull ((1));
0887:
0888: # ifdef __USE_XOPEN2K
0889:
0890: extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
0891: __const struct timespec *__restrict
0892: __abstime) __THROWNL __nonnull ((1, 2));
0893: # endif
0894:
0895:
0896: extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
0897: __THROWNL __nonnull ((1));
0898:
0899:
0900: extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
0901: __THROWNL __nonnull ((1));
0902:
0903: # ifdef __USE_XOPEN2K
0904:
0905: extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
0906: __const struct timespec *__restrict
0907: __abstime) __THROWNL __nonnull ((1, 2));
0908: # endif
0909:
0910:
0911: extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
0912: __THROWNL __nonnull ((1));
0913:
0914:
0915:
0916:
0917:
0918: extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
0919: __THROW __nonnull ((1));
0920:
0921:
0922: extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
0923: __THROW __nonnull ((1));
0924:
0925:
0926: extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
0927: __restrict __attr,
0928: int *__restrict __pshared)
0929: __THROW __nonnull ((1, 2));
0930:
0931:
0932: extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
0933: int __pshared)
0934: __THROW __nonnull ((1));
0935:
0936:
0937: extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *
0938: __restrict __attr,
0939: int *__restrict __pref)
0940: __THROW __nonnull ((1, 2));
0941:
0942:
0943: extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
0944: int __pref) __THROW __nonnull ((1));
0945: #endif
0946:
0947:
0948:
0949:
0950:
0951:
0952: extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
0953: __const pthread_condattr_t *__restrict
0954: __cond_attr) __THROW __nonnull ((1));
0955:
0956:
0957: extern int pthread_cond_destroy (pthread_cond_t *__cond)
0958: __THROW __nonnull ((1));
0959:
0960:
0961: extern int pthread_cond_signal (pthread_cond_t *__cond)
0962: __THROWNL __nonnull ((1));
0963:
0964:
0965: extern int pthread_cond_broadcast (pthread_cond_t *__cond)
0966: __THROWNL __nonnull ((1));
0967:
0968:
0969:
0970:
0971:
0972:
0973: extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
0974: pthread_mutex_t *__restrict __mutex)
0975: __nonnull ((1, 2));
0976:
0977:
0978:
0979:
0980:
0981:
0982:
0983:
0984: extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
0985: pthread_mutex_t *__restrict __mutex,
0986: __const struct timespec *__restrict
0987: __abstime) __nonnull ((1, 2, 3));
0988:
0989:
0990:
0991:
0992: extern int pthread_condattr_init (pthread_condattr_t *__attr)
0993: __THROW __nonnull ((1));
0994:
0995:
0996: extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
0997: __THROW __nonnull ((1));
0998:
0999:
1000: extern int pthread_condattr_getpshared (__const pthread_condattr_t *
1001: __restrict __attr,
1002: int *__restrict __pshared)
1003: __THROW __nonnull ((1, 2));
1004:
1005:
1006: extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1007: int __pshared) __THROW __nonnull ((1));
1008:
1009: #ifdef __USE_XOPEN2K
1010:
1011: extern int pthread_condattr_getclock (__const pthread_condattr_t *
1012: __restrict __attr,
1013: __clockid_t *__restrict __clock_id)
1014: __THROW __nonnull ((1, 2));
1015:
1016:
1017: extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1018: __clockid_t __clock_id)
1019: __THROW __nonnull ((1));
1020: #endif
1021:
1022:
1023: #ifdef __USE_XOPEN2K
1024:
1025:
1026:
1027:
1028: extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1029: __THROW __nonnull ((1));
1030:
1031:
1032: extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1033: __THROW __nonnull ((1));
1034:
1035:
1036: extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1037: __THROWNL __nonnull ((1));
1038:
1039:
1040: extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1041: __THROWNL __nonnull ((1));
1042:
1043:
1044: extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1045: __THROWNL __nonnull ((1));
1046:
1047:
1048:
1049:
1050:
1051:
1052: extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1053: __const pthread_barrierattr_t *__restrict
1054: __attr, unsigned int __count)
1055: __THROW __nonnull ((1));
1056:
1057:
1058: extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1059: __THROW __nonnull ((1));
1060:
1061:
1062: extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1063: __THROWNL __nonnull ((1));
1064:
1065:
1066:
1067: extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1068: __THROW __nonnull ((1));
1069:
1070:
1071: extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1072: __THROW __nonnull ((1));
1073:
1074:
1075: extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
1076: __restrict __attr,
1077: int *__restrict __pshared)
1078: __THROW __nonnull ((1, 2));
1079:
1080:
1081: extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1082: int __pshared)
1083: __THROW __nonnull ((1));
1084: #endif
1085:
1086:
1087:
1088:
1089:
1090:
1091:
1092:
1093:
1094:
1095: extern int pthread_key_create (pthread_key_t *__key,
1096: void (*__destr_function) (void *))
1097: __THROW __nonnull ((1));
1098:
1099:
1100: extern int pthread_key_delete (pthread_key_t __key) __THROW;
1101:
1102:
1103: extern void *pthread_getspecific (pthread_key_t __key) __THROW;
1104:
1105:
1106: extern int pthread_setspecific (pthread_key_t __key,
1107: __const void *__pointer) __THROW ;
1108:
1109:
1110: #ifdef __USE_XOPEN2K
1111:
1112: extern int pthread_getcpuclockid (pthread_t __thread_id,
1113: __clockid_t *__clock_id)
1114: __THROW __nonnull ((2));
1115: #endif
1116:
1117:
1118:
1119:
1120:
1121:
1122:
1123:
1124:
1125:
1126:
1127:
1128:
1129: extern int pthread_atfork (void (*__prepare) (void),
1130: void (*__parent) (void),
1131: void (*__child) (void)) __THROW;
1132:
1133:
1134: #ifdef __USE_EXTERN_INLINES
1135:
1136: __extern_inline int
1137: __NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
1138: {
1139: return __thread1 == __thread2;
1140: }
1141: #endif
1142:
1143: __END_DECLS
1144:
1145: #endif
1146:
© Andrew Scott 2006 -
2024,
All Rights Reserved