]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 2003-2014 Free Software Foundation, Inc. |
a88c9263 | 2 | This file is part of the GNU C Library. |
a88c9263 UD |
3 | |
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 | ||
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 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
a88c9263 UD |
17 | |
18 | #ifndef _BITS_PTHREADTYPES_H | |
19 | #define _BITS_PTHREADTYPES_H 1 | |
20 | ||
21 | #include <bits/wordsize.h> | |
22 | ||
23 | #if __WORDSIZE == 64 | |
24 | # define __SIZEOF_PTHREAD_ATTR_T 56 | |
25 | # define __SIZEOF_PTHREAD_MUTEX_T 40 | |
26 | # define __SIZEOF_PTHREAD_MUTEXATTR_T 4 | |
27 | # define __SIZEOF_PTHREAD_COND_T 48 | |
28 | # define __SIZEOF_PTHREAD_CONDATTR_T 4 | |
29 | # define __SIZEOF_PTHREAD_RWLOCK_T 56 | |
30 | # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 | |
31 | # define __SIZEOF_PTHREAD_BARRIER_T 32 | |
32 | # define __SIZEOF_PTHREAD_BARRIERATTR_T 4 | |
33 | #else | |
34 | # define __SIZEOF_PTHREAD_ATTR_T 36 | |
35 | # define __SIZEOF_PTHREAD_MUTEX_T 24 | |
36 | # define __SIZEOF_PTHREAD_MUTEXATTR_T 4 | |
37 | # define __SIZEOF_PTHREAD_COND_T 48 | |
38 | # define __SIZEOF_PTHREAD_CONDATTR_T 4 | |
39 | # define __SIZEOF_PTHREAD_RWLOCK_T 32 | |
40 | # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 | |
41 | # define __SIZEOF_PTHREAD_BARRIER_T 20 | |
42 | # define __SIZEOF_PTHREAD_BARRIERATTR_T 4 | |
43 | #endif | |
44 | ||
45 | ||
46 | /* Thread identifiers. The structure of the attribute type is not | |
47 | exposed on purpose. */ | |
806e4a4a | 48 | typedef unsigned long int pthread_t; |
a88c9263 UD |
49 | |
50 | ||
8da0464f | 51 | union pthread_attr_t |
a88c9263 UD |
52 | { |
53 | char __size[__SIZEOF_PTHREAD_ATTR_T]; | |
54 | long int __align; | |
4a3dded5 UD |
55 | }; |
56 | #ifndef __have_pthread_attr_t | |
22f9d9df | 57 | typedef union pthread_attr_t pthread_attr_t; |
4a3dded5 UD |
58 | # define __have_pthread_attr_t 1 |
59 | #endif | |
a88c9263 UD |
60 | |
61 | ||
683040c3 UD |
62 | #if __WORDSIZE == 64 |
63 | typedef struct __pthread_internal_list | |
64 | { | |
65 | struct __pthread_internal_list *__prev; | |
66 | struct __pthread_internal_list *__next; | |
67 | } __pthread_list_t; | |
68 | #else | |
69 | typedef struct __pthread_internal_slist | |
70 | { | |
71 | struct __pthread_internal_slist *__next; | |
72 | } __pthread_slist_t; | |
73 | #endif | |
74 | ||
75 | ||
a88c9263 UD |
76 | /* Data structures for mutex handling. The structure of the attribute |
77 | type is not exposed on purpose. */ | |
d804f5df | 78 | typedef union |
a88c9263 | 79 | { |
d804f5df | 80 | struct __pthread_mutex_s |
a88c9263 UD |
81 | { |
82 | int __lock; | |
83 | unsigned int __count; | |
61623643 UD |
84 | int __owner; |
85 | #if __WORDSIZE == 64 | |
86 | unsigned int __nusers; | |
87 | #endif | |
a88c9263 UD |
88 | /* KIND must stay at this position in the structure to maintain |
89 | binary compatibility. */ | |
90 | int __kind; | |
bfffffae UD |
91 | #if __WORDSIZE == 64 |
92 | int __spins; | |
683040c3 | 93 | __pthread_list_t __list; |
bfffffae UD |
94 | # define __PTHREAD_MUTEX_HAVE_PREV 1 |
95 | #else | |
61623643 | 96 | unsigned int __nusers; |
01a3f2ef | 97 | __extension__ union |
bfffffae UD |
98 | { |
99 | int __spins; | |
683040c3 | 100 | __pthread_slist_t __list; |
bfffffae | 101 | }; |
61623643 | 102 | #endif |
a88c9263 UD |
103 | } __data; |
104 | char __size[__SIZEOF_PTHREAD_MUTEX_T]; | |
105 | long int __align; | |
106 | } pthread_mutex_t; | |
107 | ||
108 | typedef union | |
109 | { | |
110 | char __size[__SIZEOF_PTHREAD_MUTEXATTR_T]; | |
7da168bf | 111 | int __align; |
a88c9263 UD |
112 | } pthread_mutexattr_t; |
113 | ||
114 | ||
115 | /* Data structure for conditional variable handling. The structure of | |
116 | the attribute type is not exposed on purpose. */ | |
117 | typedef union | |
118 | { | |
119 | struct | |
120 | { | |
121 | int __lock; | |
75fccede | 122 | unsigned int __futex; |
e9f4e844 UD |
123 | __extension__ unsigned long long int __total_seq; |
124 | __extension__ unsigned long long int __wakeup_seq; | |
125 | __extension__ unsigned long long int __woken_seq; | |
284bdc42 | 126 | void *__mutex; |
73f7c32c | 127 | unsigned int __nwaiters; |
893a3511 | 128 | unsigned int __broadcast_seq; |
a88c9263 UD |
129 | } __data; |
130 | char __size[__SIZEOF_PTHREAD_COND_T]; | |
e9f4e844 | 131 | __extension__ long long int __align; |
a88c9263 UD |
132 | } pthread_cond_t; |
133 | ||
134 | typedef union | |
135 | { | |
136 | char __size[__SIZEOF_PTHREAD_CONDATTR_T]; | |
7da168bf | 137 | int __align; |
a88c9263 UD |
138 | } pthread_condattr_t; |
139 | ||
140 | ||
141 | /* Keys for thread-specific data */ | |
142 | typedef unsigned int pthread_key_t; | |
143 | ||
144 | ||
145 | /* Once-only execution */ | |
146 | typedef int pthread_once_t; | |
147 | ||
148 | ||
ccc63b07 | 149 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K |
a88c9263 UD |
150 | /* Data structure for read-write lock variable handling. The |
151 | structure of the attribute type is not exposed on purpose. */ | |
152 | typedef union | |
153 | { | |
154 | # if __WORDSIZE == 64 | |
a234e27d | 155 | struct |
a88c9263 UD |
156 | { |
157 | int __lock; | |
158 | unsigned int __nr_readers; | |
159 | unsigned int __readers_wakeup; | |
160 | unsigned int __writer_wakeup; | |
161 | unsigned int __nr_readers_queued; | |
162 | unsigned int __nr_writers_queued; | |
4ad0bbf4 | 163 | int __writer; |
8d944b0f UD |
164 | int __shared; |
165 | unsigned long int __pad1; | |
a88c9263 UD |
166 | unsigned long int __pad2; |
167 | /* FLAGS must stay at this position in the structure to maintain | |
168 | binary compatibility. */ | |
169 | unsigned int __flags; | |
170 | } __data; | |
171 | # else | |
172 | struct | |
173 | { | |
174 | int __lock; | |
175 | unsigned int __nr_readers; | |
176 | unsigned int __readers_wakeup; | |
177 | unsigned int __writer_wakeup; | |
178 | unsigned int __nr_readers_queued; | |
179 | unsigned int __nr_writers_queued; | |
8d944b0f UD |
180 | unsigned char __pad1; |
181 | unsigned char __pad2; | |
182 | unsigned char __shared; | |
a88c9263 UD |
183 | /* FLAGS must stay at this position in the structure to maintain |
184 | binary compatibility. */ | |
8d944b0f | 185 | unsigned char __flags; |
4ad0bbf4 | 186 | int __writer; |
a88c9263 UD |
187 | } __data; |
188 | # endif | |
189 | char __size[__SIZEOF_PTHREAD_RWLOCK_T]; | |
190 | long int __align; | |
191 | } pthread_rwlock_t; | |
192 | ||
193 | typedef union | |
194 | { | |
195 | char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T]; | |
196 | long int __align; | |
197 | } pthread_rwlockattr_t; | |
198 | #endif | |
199 | ||
200 | ||
201 | #ifdef __USE_XOPEN2K | |
202 | /* POSIX spinlock data type. */ | |
203 | typedef volatile int pthread_spinlock_t; | |
204 | ||
205 | ||
206 | /* POSIX barriers data type. The structure of the type is | |
207 | deliberately not exposed. */ | |
208 | typedef union | |
209 | { | |
210 | char __size[__SIZEOF_PTHREAD_BARRIER_T]; | |
211 | long int __align; | |
212 | } pthread_barrier_t; | |
213 | ||
214 | typedef union | |
215 | { | |
216 | char __size[__SIZEOF_PTHREAD_BARRIERATTR_T]; | |
217 | int __align; | |
218 | } pthread_barrierattr_t; | |
219 | #endif | |
220 | ||
221 | ||
222 | #endif /* bits/pthreadtypes.h */ |