]>
Commit | Line | Data |
---|---|---|
6f5d2fa8 | 1 | /* Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. |
da1ea0f0 CD |
2 | This file is part of the GNU C Library. |
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 | |
ab84e3ff PE |
15 | License along with the GNU C Library. If not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
da1ea0f0 CD |
17 | |
18 | #ifndef _BITS_PTHREADTYPES_H | |
19 | #define _BITS_PTHREADTYPES_H 1 | |
20 | ||
b599860d | 21 | /* Linuxthread type sizes (bytes): |
da1ea0f0 | 22 | sizeof(pthread_attr_t) = 0x24 (36) |
6f5d2fa8 CD |
23 | sizeof(pthread_barrier_t) = 0x30 (48) |
24 | sizeof(pthread_barrierattr_t) = 0x4 (4) | |
da1ea0f0 | 25 | sizeof(pthread_cond_t) = 0x30 (48) |
da1ea0f0 | 26 | sizeof(pthread_condattr_t) = 0x4 (4) |
6f5d2fa8 CD |
27 | sizeof(pthread_mutex_t) = 0x30 (48) |
28 | sizeof(pthread_mutexattr_t) = 0x4 (4) | |
da1ea0f0 CD |
29 | sizeof(pthread_rwlock_t) = 0x40 (64) |
30 | sizeof(pthread_rwlockattr_t) = 0x8 (8) | |
6f5d2fa8 | 31 | sizeof(pthread_spinlock_t) = 0x10 (16) */ |
da1ea0f0 CD |
32 | |
33 | #define __SIZEOF_PTHREAD_ATTR_T 36 | |
6f5d2fa8 CD |
34 | #define __SIZEOF_PTHREAD_BARRIER_T 48 |
35 | #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 | |
be0f2008 | 36 | #define __SIZEOF_PTHREAD_COND_T 48 |
da1ea0f0 | 37 | #define __SIZEOF_PTHREAD_CONDATTR_T 4 |
6f5d2fa8 CD |
38 | #define __SIZEOF_PTHREAD_MUTEX_T 48 |
39 | #define __SIZEOF_PTHREAD_MUTEXATTR_T 4 | |
da1ea0f0 CD |
40 | #define __SIZEOF_PTHREAD_RWLOCK_T 64 |
41 | #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 | |
da1ea0f0 | 42 | |
da1ea0f0 CD |
43 | /* Thread identifiers. The structure of the attribute type is not |
44 | exposed on purpose. */ | |
45 | typedef unsigned long int pthread_t; | |
46 | ||
a64b8a46 | 47 | union pthread_attr_t |
da1ea0f0 CD |
48 | { |
49 | char __size[__SIZEOF_PTHREAD_ATTR_T]; | |
50 | long int __align; | |
a64b8a46 CD |
51 | }; |
52 | #ifndef __have_pthread_attr_t | |
53 | typedef union pthread_attr_t pthread_attr_t; | |
54 | # define __have_pthread_attr_t 1 | |
55 | #endif | |
da1ea0f0 CD |
56 | |
57 | ||
58 | typedef struct __pthread_internal_slist | |
59 | { | |
60 | struct __pthread_internal_slist *__next; | |
61 | } __pthread_slist_t; | |
62 | ||
63 | ||
64 | /* Data structures for mutex handling. The structure of the attribute | |
65 | type is not exposed on purpose. */ | |
66 | typedef union | |
67 | { | |
68 | struct __pthread_mutex_s | |
69 | { | |
b80ec536 | 70 | int __lock __attribute__ ((aligned(16))); |
da1ea0f0 CD |
71 | unsigned int __count; |
72 | int __owner; | |
73 | /* KIND must stay at this position in the structure to maintain | |
74 | binary compatibility. */ | |
75 | int __kind; | |
be0f2008 CD |
76 | /* The old 4-word 16-byte aligned lock. This is initalized |
77 | to all ones by the Linuxthreads PTHREAD_MUTEX_INITIALIZER. | |
78 | Unused in NPTL. */ | |
79 | int __compat_padding[4]; | |
80 | /* In the old structure there are 4 words left due to alignment. | |
81 | In NPTL two words are used. */ | |
da1ea0f0 CD |
82 | unsigned int __nusers; |
83 | __extension__ union | |
84 | { | |
85 | int __spins; | |
86 | __pthread_slist_t __list; | |
87 | }; | |
be0f2008 CD |
88 | /* Two more words are left before the NPTL |
89 | pthread_mutex_t is larger than Linuxthreads. */ | |
90 | int __reserved1; | |
91 | int __reserved2; | |
da1ea0f0 CD |
92 | } __data; |
93 | char __size[__SIZEOF_PTHREAD_MUTEX_T]; | |
94 | long int __align; | |
95 | } pthread_mutex_t; | |
96 | ||
97 | typedef union | |
98 | { | |
99 | char __size[__SIZEOF_PTHREAD_MUTEXATTR_T]; | |
100 | long int __align; | |
101 | } pthread_mutexattr_t; | |
102 | ||
103 | ||
104 | /* Data structure for conditional variable handling. The structure of | |
be0f2008 CD |
105 | the attribute type is not exposed on purpose. However, this structure |
106 | is exposed via PTHREAD_COND_INITIALIZER, and because of this, the | |
107 | Linuxthreads version sets the first four ints to one. In the NPTL | |
108 | version we must check, in every function using pthread_cond_t, | |
109 | for the static Linuxthreads initializer and clear the appropriate | |
110 | words. */ | |
da1ea0f0 CD |
111 | typedef union |
112 | { | |
113 | struct | |
114 | { | |
be0f2008 CD |
115 | /* In the old Linuxthreads pthread_cond_t, this is the |
116 | start of the 4-word lock structure, the next four words | |
117 | are set all to 1 by the Linuxthreads | |
118 | PTHREAD_COND_INITIALIZER. */ | |
b80ec536 | 119 | int __lock __attribute__ ((aligned(16))); |
be0f2008 CD |
120 | /* Tracks the initialization of this structure: |
121 | 0 initialized with NPTL PTHREAD_COND_INITIALIZER. | |
122 | 1 initialized with Linuxthreads PTHREAD_COND_INITIALIZER. | |
123 | 2 initialization in progress. */ | |
124 | int __initializer; | |
da1ea0f0 | 125 | unsigned int __futex; |
be0f2008 CD |
126 | void *__mutex; |
127 | /* In the old Linuxthreads this would have been the start | |
128 | of the pthread_fastlock status word. */ | |
da1ea0f0 CD |
129 | __extension__ unsigned long long int __total_seq; |
130 | __extension__ unsigned long long int __wakeup_seq; | |
131 | __extension__ unsigned long long int __woken_seq; | |
da1ea0f0 CD |
132 | unsigned int __nwaiters; |
133 | unsigned int __broadcast_seq; | |
be0f2008 CD |
134 | /* The NPTL pthread_cond_t is exactly the same size as |
135 | the Linuxthreads version, there are no words to spare. */ | |
da1ea0f0 CD |
136 | } __data; |
137 | char __size[__SIZEOF_PTHREAD_COND_T]; | |
138 | __extension__ long long int __align; | |
139 | } pthread_cond_t; | |
140 | ||
141 | typedef union | |
142 | { | |
143 | char __size[__SIZEOF_PTHREAD_CONDATTR_T]; | |
144 | long int __align; | |
145 | } pthread_condattr_t; | |
146 | ||
147 | ||
148 | /* Keys for thread-specific data */ | |
149 | typedef unsigned int pthread_key_t; | |
150 | ||
151 | ||
152 | /* Once-only execution */ | |
153 | typedef int pthread_once_t; | |
154 | ||
155 | ||
156 | #if defined __USE_UNIX98 || defined __USE_XOPEN2K | |
157 | /* Data structure for read-write lock variable handling. The | |
158 | structure of the attribute type is not exposed on purpose. */ | |
159 | typedef union | |
160 | { | |
161 | struct | |
162 | { | |
be0f2008 CD |
163 | /* In the old Linuxthreads pthread_rwlock_t, this is the |
164 | start of the 4-word 16-byte aligned lock structure. The | |
165 | next four words are all set to 1 by the Linuxthreads | |
166 | PTHREAD_RWLOCK_INITIALIZER. We ignore them in NPTL. */ | |
b80ec536 | 167 | int __compat_padding[4] __attribute__ ((aligned(16))); |
da1ea0f0 | 168 | int __lock; |
da1ea0f0 CD |
169 | unsigned int __nr_readers; |
170 | unsigned int __readers_wakeup; | |
171 | unsigned int __writer_wakeup; | |
172 | unsigned int __nr_readers_queued; | |
173 | unsigned int __nr_writers_queued; | |
be0f2008 CD |
174 | int __writer; |
175 | /* An unused word, reserved for future use. It was added | |
176 | to maintain the location of the flags from the Linuxthreads | |
177 | layout of this structure. */ | |
178 | int __reserved1; | |
da1ea0f0 CD |
179 | /* FLAGS must stay at this position in the structure to maintain |
180 | binary compatibility. */ | |
b599860d CD |
181 | unsigned char __pad2; |
182 | unsigned char __pad1; | |
183 | unsigned char __shared; | |
184 | unsigned char __flags; | |
be0f2008 CD |
185 | /* The NPTL pthread_rwlock_t is 4 words smaller than the |
186 | Linuxthreads version. One word is in the middle of the | |
187 | structure, the other three are at the end. */ | |
188 | int __reserved2; | |
189 | int __reserved3; | |
190 | int __reserved4; | |
da1ea0f0 CD |
191 | } __data; |
192 | char __size[__SIZEOF_PTHREAD_RWLOCK_T]; | |
193 | long int __align; | |
194 | } pthread_rwlock_t; | |
195 | ||
196 | typedef union | |
197 | { | |
198 | char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T]; | |
199 | long int __align; | |
200 | } pthread_rwlockattr_t; | |
201 | #endif | |
202 | ||
203 | ||
204 | #ifdef __USE_XOPEN2K | |
205 | /* POSIX spinlock data type. */ | |
206 | typedef volatile int pthread_spinlock_t; | |
207 | ||
208 | ||
209 | /* POSIX barriers data type. The structure of the type is | |
210 | deliberately not exposed. */ | |
211 | typedef union | |
212 | { | |
213 | char __size[__SIZEOF_PTHREAD_BARRIER_T]; | |
214 | long int __align; | |
215 | } pthread_barrier_t; | |
216 | ||
217 | typedef union | |
218 | { | |
219 | char __size[__SIZEOF_PTHREAD_BARRIERATTR_T]; | |
220 | int __align; | |
221 | } pthread_barrierattr_t; | |
222 | #endif | |
223 | ||
224 | ||
225 | #endif /* bits/pthreadtypes.h */ |