pthreadtypes.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
  2. The GNU C Library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Lesser General Public
  4. License as published by the Free Software Foundation; either
  5. version 2.1 of the License, or (at your option) any later version.
  6. The GNU C Library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public
  11. License along with the GNU C Library; if not, write to the Free
  12. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  13. 02111-1307 USA. */
  14. #ifndef _BITS_PTHREADTYPES_H
  15. #define _BITS_PTHREADTYPES_H 1
  16. #define __SIZEOF_PTHREAD_ATTR_T 56
  17. #define __SIZEOF_PTHREAD_MUTEX_T 40
  18. #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
  19. #define __SIZEOF_PTHREAD_COND_T 48
  20. #define __SIZEOF_PTHREAD_COND_COMPAT_T 12
  21. #define __SIZEOF_PTHREAD_CONDATTR_T 4
  22. #define __SIZEOF_PTHREAD_RWLOCK_T 56
  23. #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
  24. #define __SIZEOF_PTHREAD_BARRIER_T 32
  25. #define __SIZEOF_PTHREAD_BARRIERATTR_T 4
  26. /* Thread identifiers. The structure of the attribute type is not
  27. exposed on purpose. */
  28. typedef unsigned long int pthread_t;
  29. union pthread_attr_t
  30. {
  31. char __size[__SIZEOF_PTHREAD_ATTR_T];
  32. long int __align;
  33. };
  34. #ifndef __have_pthread_attr_t
  35. typedef union pthread_attr_t pthread_attr_t;
  36. # define __have_pthread_attr_t 1
  37. #endif
  38. typedef struct __pthread_internal_list
  39. {
  40. struct __pthread_internal_list *__prev;
  41. struct __pthread_internal_list *__next;
  42. } __pthread_list_t;
  43. /* Data structures for mutex handling. The structure of the attribute
  44. type is not exposed on purpose. */
  45. typedef union
  46. {
  47. struct __pthread_mutex_s
  48. {
  49. int __lock;
  50. unsigned int __count;
  51. int __owner;
  52. unsigned int __nusers;
  53. /* KIND must stay at this position in the structure to maintain
  54. binary compatibility with static initializers. */
  55. int __kind;
  56. int __spins;
  57. __pthread_list_t __list;
  58. #define __PTHREAD_MUTEX_HAVE_PREV 1
  59. } __data;
  60. char __size[__SIZEOF_PTHREAD_MUTEX_T];
  61. long int __align;
  62. } pthread_mutex_t;
  63. typedef union
  64. {
  65. char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
  66. long int __align;
  67. } pthread_mutexattr_t;
  68. /* Data structure for conditional variable handling. The structure of
  69. the attribute type is not exposed on purpose. */
  70. typedef union
  71. {
  72. struct
  73. {
  74. int __lock;
  75. unsigned int __futex;
  76. __extension__ unsigned long long int __total_seq;
  77. __extension__ unsigned long long int __wakeup_seq;
  78. __extension__ unsigned long long int __woken_seq;
  79. void *__mutex;
  80. unsigned int __nwaiters;
  81. unsigned int __broadcast_seq;
  82. } __data;
  83. char __size[__SIZEOF_PTHREAD_COND_T];
  84. __extension__ long long int __align;
  85. } pthread_cond_t;
  86. typedef union
  87. {
  88. char __size[__SIZEOF_PTHREAD_CONDATTR_T];
  89. long int __align;
  90. } pthread_condattr_t;
  91. /* Keys for thread-specific data */
  92. typedef unsigned int pthread_key_t;
  93. /* Once-only execution */
  94. typedef int pthread_once_t;
  95. #if defined __USE_UNIX98 || defined __USE_XOPEN2K
  96. /* Data structure for read-write lock variable handling. The
  97. structure of the attribute type is not exposed on purpose. */
  98. typedef union
  99. {
  100. struct
  101. {
  102. int __lock;
  103. unsigned int __nr_readers;
  104. unsigned int __readers_wakeup;
  105. unsigned int __writer_wakeup;
  106. unsigned int __nr_readers_queued;
  107. unsigned int __nr_writers_queued;
  108. int __writer;
  109. int __shared;
  110. unsigned long int __pad1;
  111. unsigned long int __pad2;
  112. unsigned int __flags;
  113. } __data;
  114. char __size[__SIZEOF_PTHREAD_RWLOCK_T];
  115. long int __align;
  116. } pthread_rwlock_t;
  117. typedef union
  118. {
  119. char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
  120. long int __align;
  121. } pthread_rwlockattr_t;
  122. #endif
  123. #ifdef __USE_XOPEN2K
  124. /* POSIX spinlock data type. */
  125. typedef volatile int pthread_spinlock_t;
  126. /* POSIX barriers data type. The structure of the type is
  127. deliberately not exposed. */
  128. typedef union
  129. {
  130. char __size[__SIZEOF_PTHREAD_BARRIER_T];
  131. long int __align;
  132. } pthread_barrier_t;
  133. typedef union
  134. {
  135. char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
  136. int __align;
  137. } pthread_barrierattr_t;
  138. #endif
  139. #endif /* bits/pthreadtypes.h */