pthreadtypes.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* Copyright (C) 2002-2017 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, see
  12. <http://www.gnu.org/licenses/>. */
  13. #ifndef _BITS_PTHREADTYPES_H
  14. #define _BITS_PTHREADTYPES_H 1
  15. #include <endian.h>
  16. #define __SIZEOF_PTHREAD_ATTR_T 64
  17. #define __SIZEOF_PTHREAD_MUTEX_T 48
  18. #define __SIZEOF_PTHREAD_MUTEXATTR_T 8
  19. #define __SIZEOF_PTHREAD_COND_T 48
  20. #define __SIZEOF_PTHREAD_COND_COMPAT_T 48
  21. #define __SIZEOF_PTHREAD_CONDATTR_T 8
  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 8
  26. #define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
  27. /* Thread identifiers. The structure of the attribute type is not
  28. exposed on purpose. */
  29. typedef unsigned long int pthread_t;
  30. union pthread_attr_t
  31. {
  32. char __size[__SIZEOF_PTHREAD_ATTR_T];
  33. long int __align;
  34. };
  35. #ifndef __have_pthread_attr_t
  36. typedef union pthread_attr_t pthread_attr_t;
  37. # define __have_pthread_attr_t1
  38. #endif
  39. typedef struct __pthread_internal_list
  40. {
  41. struct __pthread_internal_list *__prev;
  42. struct __pthread_internal_list *__next;
  43. } __pthread_list_t;
  44. /* Data structures for mutex handling. The structure of the attribute
  45. type is not exposed on purpose. */
  46. typedef union
  47. {
  48. struct __pthread_mutex_s
  49. {
  50. int __lock;
  51. unsigned int __count;
  52. int __owner;
  53. unsigned int __nusers;
  54. /* KIND must stay at this position in the structure to maintain
  55. binary compatibility with static initializers. */
  56. int __kind;
  57. int __spins;
  58. __pthread_list_t __list;
  59. #define __PTHREAD_MUTEX_HAVE_PREV 1
  60. } __data;
  61. char __size[__SIZEOF_PTHREAD_MUTEX_T];
  62. long int __align;
  63. } pthread_mutex_t;
  64. /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
  65. #define __PTHREAD_SPINS 0
  66. typedef union
  67. {
  68. char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
  69. long int __align;
  70. } pthread_mutexattr_t;
  71. /* Data structure for conditional variable handling. The structure of
  72. the attribute type is not exposed on purpose. */
  73. typedef union
  74. {
  75. struct
  76. {
  77. int __lock;
  78. unsigned int __futex;
  79. __extension__ unsigned long long int __total_seq;
  80. __extension__ unsigned long long int __wakeup_seq;
  81. __extension__ unsigned long long int __woken_seq;
  82. void *__mutex;
  83. unsigned int __nwaiters;
  84. unsigned int __broadcast_seq;
  85. } __data;
  86. char __size[__SIZEOF_PTHREAD_COND_T];
  87. __extension__ long long int __align;
  88. } pthread_cond_t;
  89. typedef union
  90. {
  91. char __size[__SIZEOF_PTHREAD_CONDATTR_T];
  92. int __align;
  93. } pthread_condattr_t;
  94. /* Keys for thread-specific data */
  95. typedef unsigned int pthread_key_t;
  96. /* Once-only execution */
  97. typedef int pthread_once_t;
  98. #if defined __USE_UNIX98 || defined __USE_XOPEN2K
  99. /* Data structure for read-write lock variable handling. The
  100. structure of the attribute type is not exposed on purpose. */
  101. typedef union
  102. {
  103. struct
  104. {
  105. int __lock;
  106. unsigned int __nr_readers;
  107. unsigned int __readers_wakeup;
  108. unsigned int __writer_wakeup;
  109. unsigned int __nr_readers_queued;
  110. unsigned int __nr_writers_queued;
  111. int __writer;
  112. int __shared;
  113. unsigned long int __pad1;
  114. unsigned long int __pad2;
  115. unsigned int __flags;
  116. } __data;
  117. char __size[__SIZEOF_PTHREAD_RWLOCK_T];
  118. long int __align;
  119. } pthread_rwlock_t;
  120. #define __PTHREAD_RWLOCK_ELISION_EXTRA 0
  121. typedef union
  122. {
  123. char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
  124. long int __align;
  125. } pthread_rwlockattr_t;
  126. #endif
  127. #ifdef __USE_XOPEN2K
  128. /* POSIX spinlock data type. */
  129. typedef volatile int pthread_spinlock_t;
  130. /* POSIX barriers data type. The structure of the type is
  131. deliberately not exposed. */
  132. typedef union
  133. {
  134. char __size[__SIZEOF_PTHREAD_BARRIER_T];
  135. long int __align;
  136. } pthread_barrier_t;
  137. typedef union
  138. {
  139. char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
  140. int __align;
  141. } pthread_barrierattr_t;
  142. #endif
  143. #endif /* bits/pthreadtypes.h */