pthreadtypes.h 4.5 KB

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