Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / x86 / bits / pthreadtypes.h
blob44606159d04fa3e1fa295d8f372139d4ea6deb84
1 /* Copyright (C) 2002-2015 Free Software Foundation, Inc.
2 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.
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.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #ifndef _BITS_PTHREADTYPES_H
19 #define _BITS_PTHREADTYPES_H 1
21 #include <bits/wordsize.h>
23 #ifdef __x86_64__
24 # if __WORDSIZE == 64
25 # define __SIZEOF_PTHREAD_ATTR_T 56
26 # define __SIZEOF_PTHREAD_MUTEX_T 40
27 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
28 # define __SIZEOF_PTHREAD_COND_T 48
29 # define __SIZEOF_PTHREAD_CONDATTR_T 4
30 # define __SIZEOF_PTHREAD_RWLOCK_T 56
31 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
32 # define __SIZEOF_PTHREAD_BARRIER_T 32
33 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
34 # else
35 # define __SIZEOF_PTHREAD_ATTR_T 32
36 # define __SIZEOF_PTHREAD_MUTEX_T 32
37 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
38 # define __SIZEOF_PTHREAD_COND_T 48
39 # define __SIZEOF_PTHREAD_CONDATTR_T 4
40 # define __SIZEOF_PTHREAD_RWLOCK_T 44
41 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
42 # define __SIZEOF_PTHREAD_BARRIER_T 20
43 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
44 # endif
45 #else
46 # define __SIZEOF_PTHREAD_ATTR_T 36
47 # define __SIZEOF_PTHREAD_MUTEX_T 24
48 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
49 # define __SIZEOF_PTHREAD_COND_T 48
50 # define __SIZEOF_PTHREAD_CONDATTR_T 4
51 # define __SIZEOF_PTHREAD_RWLOCK_T 32
52 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
53 # define __SIZEOF_PTHREAD_BARRIER_T 20
54 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
55 #endif
58 /* Thread identifiers. The structure of the attribute type is not
59 exposed on purpose. */
60 typedef unsigned long int pthread_t;
63 union pthread_attr_t
65 char __size[__SIZEOF_PTHREAD_ATTR_T];
66 long int __align;
68 #ifndef __have_pthread_attr_t
69 typedef union pthread_attr_t pthread_attr_t;
70 # define __have_pthread_attr_t 1
71 #endif
74 #ifdef __x86_64__
75 typedef struct __pthread_internal_list
77 struct __pthread_internal_list *__prev;
78 struct __pthread_internal_list *__next;
79 } __pthread_list_t;
80 #else
81 typedef struct __pthread_internal_slist
83 struct __pthread_internal_slist *__next;
84 } __pthread_slist_t;
85 #endif
88 /* Data structures for mutex handling. The structure of the attribute
89 type is not exposed on purpose. */
90 typedef union
92 struct __pthread_mutex_s
94 int __lock;
95 unsigned int __count;
96 int __owner;
97 #ifdef __x86_64__
98 unsigned int __nusers;
99 #endif
100 /* KIND must stay at this position in the structure to maintain
101 binary compatibility. */
102 int __kind;
103 #ifdef __x86_64__
104 short __spins;
105 short __elision;
106 __pthread_list_t __list;
107 # define __PTHREAD_MUTEX_HAVE_PREV 1
108 /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
109 # define __PTHREAD_SPINS 0, 0
110 #else
111 unsigned int __nusers;
112 __extension__ union
114 struct
116 short __espins;
117 short __elision;
118 # define __spins __elision_data.__espins
119 # define __elision __elision_data.__elision
120 # define __PTHREAD_SPINS { 0, 0 }
121 } __elision_data;
122 __pthread_slist_t __list;
124 #endif
125 } __data;
126 char __size[__SIZEOF_PTHREAD_MUTEX_T];
127 long int __align;
128 } pthread_mutex_t;
130 typedef union
132 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
133 int __align;
134 } pthread_mutexattr_t;
137 /* Data structure for conditional variable handling. The structure of
138 the attribute type is not exposed on purpose. */
139 typedef union
141 struct
143 int __lock;
144 unsigned int __futex;
145 __extension__ unsigned long long int __total_seq;
146 __extension__ unsigned long long int __wakeup_seq;
147 __extension__ unsigned long long int __woken_seq;
148 void *__mutex;
149 unsigned int __nwaiters;
150 unsigned int __broadcast_seq;
151 } __data;
152 char __size[__SIZEOF_PTHREAD_COND_T];
153 __extension__ long long int __align;
154 } pthread_cond_t;
156 typedef union
158 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
159 int __align;
160 } pthread_condattr_t;
163 /* Keys for thread-specific data */
164 typedef unsigned int pthread_key_t;
167 /* Once-only execution */
168 typedef int pthread_once_t;
171 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
172 /* Data structure for read-write lock variable handling. The
173 structure of the attribute type is not exposed on purpose. */
174 typedef union
176 # ifdef __x86_64__
177 struct
179 int __lock;
180 unsigned int __nr_readers;
181 unsigned int __readers_wakeup;
182 unsigned int __writer_wakeup;
183 unsigned int __nr_readers_queued;
184 unsigned int __nr_writers_queued;
185 int __writer;
186 int __shared;
187 signed char __rwelision;
188 # ifdef __ILP32__
189 unsigned char __pad1[3];
190 # define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0 }
191 # else
192 unsigned char __pad1[7];
193 # define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 }
194 # endif
195 unsigned long int __pad2;
196 /* FLAGS must stay at this position in the structure to maintain
197 binary compatibility. */
198 unsigned int __flags;
199 # define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
200 } __data;
201 # else
202 struct
204 int __lock;
205 unsigned int __nr_readers;
206 unsigned int __readers_wakeup;
207 unsigned int __writer_wakeup;
208 unsigned int __nr_readers_queued;
209 unsigned int __nr_writers_queued;
210 /* FLAGS must stay at this position in the structure to maintain
211 binary compatibility. */
212 unsigned char __flags;
213 unsigned char __shared;
214 signed char __rwelision;
215 # define __PTHREAD_RWLOCK_ELISION_EXTRA 0
216 unsigned char __pad2;
217 int __writer;
218 } __data;
219 # endif
220 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
221 long int __align;
222 } pthread_rwlock_t;
224 typedef union
226 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
227 long int __align;
228 } pthread_rwlockattr_t;
229 #endif
232 #ifdef __USE_XOPEN2K
233 /* POSIX spinlock data type. */
234 typedef volatile int pthread_spinlock_t;
237 /* POSIX barriers data type. The structure of the type is
238 deliberately not exposed. */
239 typedef union
241 char __size[__SIZEOF_PTHREAD_BARRIER_T];
242 long int __align;
243 } pthread_barrier_t;
245 typedef union
247 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
248 int __align;
249 } pthread_barrierattr_t;
250 #endif
253 #ifndef __x86_64__
254 /* Extra attributes for the cleanup functions. */
255 # define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
256 #endif
258 #endif /* bits/pthreadtypes.h */