]>
Commit | Line | Data |
---|---|---|
bfffffae | 1 | /* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
a88c9263 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. | |
4 | ||
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 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #ifndef _BITS_PTHREADTYPES_H | |
21 | #define _BITS_PTHREADTYPES_H 1 | |
22 | ||
23 | #include <bits/wordsize.h> | |
24 | ||
25 | #if __WORDSIZE == 64 | |
26 | # define __SIZEOF_PTHREAD_ATTR_T 56 | |
27 | # define __SIZEOF_PTHREAD_MUTEX_T 40 | |
28 | # define __SIZEOF_PTHREAD_MUTEXATTR_T 4 | |
29 | # define __SIZEOF_PTHREAD_COND_T 48 | |
30 | # define __SIZEOF_PTHREAD_CONDATTR_T 4 | |
31 | # define __SIZEOF_PTHREAD_RWLOCK_T 56 | |
32 | # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 | |
33 | # define __SIZEOF_PTHREAD_BARRIER_T 32 | |
34 | # define __SIZEOF_PTHREAD_BARRIERATTR_T 4 | |
35 | #else | |
36 | # define __SIZEOF_PTHREAD_ATTR_T 36 | |
37 | # define __SIZEOF_PTHREAD_MUTEX_T 24 | |
38 | # define __SIZEOF_PTHREAD_MUTEXATTR_T 4 | |
39 | # define __SIZEOF_PTHREAD_COND_T 48 | |
40 | # define __SIZEOF_PTHREAD_CONDATTR_T 4 | |
41 | # define __SIZEOF_PTHREAD_RWLOCK_T 32 | |
42 | # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 | |
43 | # define __SIZEOF_PTHREAD_BARRIER_T 20 | |
44 | # define __SIZEOF_PTHREAD_BARRIERATTR_T 4 | |
45 | #endif | |
46 | ||
47 | ||
48 | /* Thread identifiers. The structure of the attribute type is not | |
49 | exposed on purpose. */ | |
806e4a4a | 50 | typedef unsigned long int pthread_t; |
a88c9263 UD |
51 | |
52 | ||
53 | typedef union | |
54 | { | |
55 | char __size[__SIZEOF_PTHREAD_ATTR_T]; | |
56 | long int __align; | |
57 | } pthread_attr_t; | |
58 | ||
59 | ||
60 | /* Data structures for mutex handling. The structure of the attribute | |
61 | type is not exposed on purpose. */ | |
bfffffae | 62 | typedef union __pthread_mutex_u |
a88c9263 | 63 | { |
a334319f | 64 | struct |
a88c9263 UD |
65 | { |
66 | int __lock; | |
67 | unsigned int __count; | |
61623643 UD |
68 | int __owner; |
69 | #if __WORDSIZE == 64 | |
70 | unsigned int __nusers; | |
71 | #endif | |
a88c9263 UD |
72 | /* KIND must stay at this position in the structure to maintain |
73 | binary compatibility. */ | |
74 | int __kind; | |
bfffffae UD |
75 | #if __WORDSIZE == 64 |
76 | int __spins; | |
77 | union __pthread_mutex_u *__next; | |
78 | union __pthread_mutex_u *__prev; | |
79 | # define __PTHREAD_MUTEX_HAVE_PREV 1 | |
80 | #else | |
61623643 | 81 | unsigned int __nusers; |
bfffffae UD |
82 | union |
83 | { | |
84 | int __spins; | |
85 | union __pthread_mutex_u *__next; | |
86 | }; | |
61623643 | 87 | #endif |
a88c9263 UD |
88 | } __data; |
89 | char __size[__SIZEOF_PTHREAD_MUTEX_T]; | |
90 | long int __align; | |
91 | } pthread_mutex_t; | |
92 | ||
93 | typedef union | |
94 | { | |
95 | char __size[__SIZEOF_PTHREAD_MUTEXATTR_T]; | |
7da168bf | 96 | int __align; |
a88c9263 UD |
97 | } pthread_mutexattr_t; |
98 | ||
99 | ||
100 | /* Data structure for conditional variable handling. The structure of | |
101 | the attribute type is not exposed on purpose. */ | |
102 | typedef union | |
103 | { | |
104 | struct | |
105 | { | |
106 | int __lock; | |
75fccede | 107 | unsigned int __futex; |
e9f4e844 UD |
108 | __extension__ unsigned long long int __total_seq; |
109 | __extension__ unsigned long long int __wakeup_seq; | |
110 | __extension__ unsigned long long int __woken_seq; | |
284bdc42 | 111 | void *__mutex; |
73f7c32c | 112 | unsigned int __nwaiters; |
893a3511 | 113 | unsigned int __broadcast_seq; |
a88c9263 UD |
114 | } __data; |
115 | char __size[__SIZEOF_PTHREAD_COND_T]; | |
e9f4e844 | 116 | __extension__ long long int __align; |
a88c9263 UD |
117 | } pthread_cond_t; |
118 | ||
119 | typedef union | |
120 | { | |
121 | char __size[__SIZEOF_PTHREAD_CONDATTR_T]; | |
7da168bf | 122 | int __align; |
a88c9263 UD |
123 | } pthread_condattr_t; |
124 | ||
125 | ||
126 | /* Keys for thread-specific data */ | |
127 | typedef unsigned int pthread_key_t; | |
128 | ||
129 | ||
130 | /* Once-only execution */ | |
131 | typedef int pthread_once_t; | |
132 | ||
133 | ||
ccc63b07 | 134 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K |
a88c9263 UD |
135 | /* Data structure for read-write lock variable handling. The |
136 | structure of the attribute type is not exposed on purpose. */ | |
137 | typedef union | |
138 | { | |
139 | # if __WORDSIZE == 64 | |
a234e27d | 140 | struct |
a88c9263 UD |
141 | { |
142 | int __lock; | |
143 | unsigned int __nr_readers; | |
144 | unsigned int __readers_wakeup; | |
145 | unsigned int __writer_wakeup; | |
146 | unsigned int __nr_readers_queued; | |
147 | unsigned int __nr_writers_queued; | |
4ad0bbf4 UD |
148 | int __writer; |
149 | int __pad1; | |
a88c9263 | 150 | unsigned long int __pad2; |
4ad0bbf4 | 151 | unsigned long int __pad3; |
a88c9263 UD |
152 | /* FLAGS must stay at this position in the structure to maintain |
153 | binary compatibility. */ | |
154 | unsigned int __flags; | |
155 | } __data; | |
156 | # else | |
157 | struct | |
158 | { | |
159 | int __lock; | |
160 | unsigned int __nr_readers; | |
161 | unsigned int __readers_wakeup; | |
162 | unsigned int __writer_wakeup; | |
163 | unsigned int __nr_readers_queued; | |
164 | unsigned int __nr_writers_queued; | |
165 | /* FLAGS must stay at this position in the structure to maintain | |
166 | binary compatibility. */ | |
167 | unsigned int __flags; | |
4ad0bbf4 | 168 | int __writer; |
a88c9263 UD |
169 | } __data; |
170 | # endif | |
171 | char __size[__SIZEOF_PTHREAD_RWLOCK_T]; | |
172 | long int __align; | |
173 | } pthread_rwlock_t; | |
174 | ||
175 | typedef union | |
176 | { | |
177 | char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T]; | |
178 | long int __align; | |
179 | } pthread_rwlockattr_t; | |
180 | #endif | |
181 | ||
182 | ||
183 | #ifdef __USE_XOPEN2K | |
184 | /* POSIX spinlock data type. */ | |
185 | typedef volatile int pthread_spinlock_t; | |
186 | ||
187 | ||
188 | /* POSIX barriers data type. The structure of the type is | |
189 | deliberately not exposed. */ | |
190 | typedef union | |
191 | { | |
192 | char __size[__SIZEOF_PTHREAD_BARRIER_T]; | |
193 | long int __align; | |
194 | } pthread_barrier_t; | |
195 | ||
196 | typedef union | |
197 | { | |
198 | char __size[__SIZEOF_PTHREAD_BARRIERATTR_T]; | |
199 | int __align; | |
200 | } pthread_barrierattr_t; | |
201 | #endif | |
202 | ||
203 | ||
204 | #endif /* bits/pthreadtypes.h */ |