pthreadtypes.h 4.7 KB

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