pthreadtypes.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef _BITS_PTHREADTYPES_H
  18. #define _BITS_PTHREADTYPES_H 1
  19. #include <bits/wordsize.h>
  20. #if __WORDSIZE == 64
  21. # define __SIZEOF_PTHREAD_ATTR_T 56
  22. # define __SIZEOF_PTHREAD_MUTEX_T 40
  23. # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
  24. # define __SIZEOF_PTHREAD_COND_T 48
  25. # define __SIZEOF_PTHREAD_CONDATTR_T 4
  26. # define __SIZEOF_PTHREAD_RWLOCK_T 56
  27. # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
  28. # define __SIZEOF_PTHREAD_BARRIER_T 32
  29. # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
  30. #else
  31. # define __SIZEOF_PTHREAD_ATTR_T 36
  32. # define __SIZEOF_PTHREAD_MUTEX_T 24
  33. # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
  34. # define __SIZEOF_PTHREAD_COND_T 48
  35. # define __SIZEOF_PTHREAD_CONDATTR_T 4
  36. # define __SIZEOF_PTHREAD_RWLOCK_T 32
  37. # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
  38. # define __SIZEOF_PTHREAD_BARRIER_T 20
  39. # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
  40. #endif
  41. /* Thread identifiers. The structure of the attribute type is
  42. deliberately not exposed. */
  43. typedef unsigned long int pthread_t;
  44. typedef union
  45. {
  46. char __size[__SIZEOF_PTHREAD_ATTR_T];
  47. long int __align;
  48. } pthread_attr_t;
  49. #if __WORDSIZE == 64
  50. typedef struct __pthread_internal_list
  51. {
  52. struct __pthread_internal_list *__prev;
  53. struct __pthread_internal_list *__next;
  54. } __pthread_list_t;
  55. #else
  56. typedef struct __pthread_internal_slist
  57. {
  58. struct __pthread_internal_slist *__next;
  59. } __pthread_slist_t;
  60. #endif
  61. /* Data structures for mutex handling. The structure of the attribute
  62. type is deliberately not exposed. */
  63. typedef union
  64. {
  65. struct __pthread_mutex_s
  66. {
  67. int __lock;
  68. unsigned int __count;
  69. int __owner;
  70. #if __WORDSIZE == 64
  71. unsigned int __nusers;
  72. #endif
  73. /* KIND must stay at this position in the structure to maintain
  74. binary compatibility. */
  75. int __kind;
  76. #if __WORDSIZE == 64
  77. int __spins;
  78. __pthread_list_t __list;
  79. # define __PTHREAD_MUTEX_HAVE_PREV 1
  80. #else
  81. unsigned int __nusers;
  82. __extension__ union
  83. {
  84. int __spins;
  85. __pthread_slist_t __list;
  86. };
  87. #endif
  88. } __data;
  89. char __size[__SIZEOF_PTHREAD_MUTEX_T];
  90. long int __align;
  91. } pthread_mutex_t;
  92. typedef union
  93. {
  94. char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
  95. int __align;
  96. } pthread_mutexattr_t;
  97. /* Data structure for conditional variable handling. The structure of
  98. the attribute type is deliberately not exposed. */
  99. typedef union
  100. {
  101. struct
  102. {
  103. int __lock;
  104. unsigned int __futex;
  105. __extension__ unsigned long long int __total_seq;
  106. __extension__ unsigned long long int __wakeup_seq;
  107. __extension__ unsigned long long int __woken_seq;
  108. void *__mutex;
  109. unsigned int __nwaiters;
  110. unsigned int __broadcast_seq;
  111. } __data;
  112. char __size[__SIZEOF_PTHREAD_COND_T];
  113. __extension__ long long int __align;
  114. } pthread_cond_t;
  115. typedef union
  116. {
  117. char __size[__SIZEOF_PTHREAD_CONDATTR_T];
  118. int __align;
  119. } pthread_condattr_t;
  120. /* Keys for thread-specific data */
  121. typedef unsigned int pthread_key_t;
  122. /* Once-only execution */
  123. typedef int pthread_once_t;
  124. #if defined __USE_UNIX98 || defined __USE_XOPEN2K
  125. /* Data structure for read-write lock variable handling. The
  126. structure of the attribute type is deliberately not exposed. */
  127. typedef union
  128. {
  129. # if __WORDSIZE == 64
  130. struct
  131. {
  132. int __lock;
  133. unsigned int __nr_readers;
  134. unsigned int __readers_wakeup;
  135. unsigned int __writer_wakeup;
  136. unsigned int __nr_readers_queued;
  137. unsigned int __nr_writers_queued;
  138. int __writer;
  139. int __shared;
  140. unsigned long int __pad1;
  141. unsigned long int __pad2;
  142. /* FLAGS must stay at this position in the structure to maintain
  143. binary compatibility. */
  144. unsigned int __flags;
  145. } __data;
  146. # else
  147. struct
  148. {
  149. int __lock;
  150. unsigned int __nr_readers;
  151. unsigned int __readers_wakeup;
  152. unsigned int __writer_wakeup;
  153. unsigned int __nr_readers_queued;
  154. unsigned int __nr_writers_queued;
  155. unsigned char __pad1;
  156. unsigned char __pad2;
  157. unsigned char __shared;
  158. /* FLAGS must stay at this position in the structure to maintain
  159. binary compatibility. */
  160. unsigned char __flags;
  161. int __writer;
  162. } __data;
  163. # endif
  164. char __size[__SIZEOF_PTHREAD_RWLOCK_T];
  165. long int __align;
  166. } pthread_rwlock_t;
  167. typedef union
  168. {
  169. char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
  170. long int __align;
  171. } pthread_rwlockattr_t;
  172. #endif
  173. #ifdef __USE_XOPEN2K
  174. /* POSIX spinlock data type. */
  175. typedef volatile int pthread_spinlock_t;
  176. /* POSIX barriers data type. The structure of the type is
  177. deliberately not exposed. */
  178. typedef union
  179. {
  180. char __size[__SIZEOF_PTHREAD_BARRIER_T];
  181. long int __align;
  182. } pthread_barrier_t;
  183. typedef union
  184. {
  185. char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
  186. int __align;
  187. } pthread_barrierattr_t;
  188. #endif
  189. #endif /* bits/pthreadtypes.h */