pthreadtypes.h 5.5 KB

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