]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
New pthread rwlock that is more scalable.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / powerpc / bits / pthreadtypes.h
CommitLineData
f3c13160 1/* Machine-specific pthread type layouts. PowerPC version.
bfff8b1b 2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
f3c13160 3 This file is part of the GNU C Library.
f3c13160
RM
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
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
f3c13160
RM
18
19#ifndef _BITS_PTHREADTYPES_H
20#define _BITS_PTHREADTYPES_H 1
21
22#include <bits/wordsize.h>
23
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 36
36# define __SIZEOF_PTHREAD_MUTEX_T 24
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 32
41# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
42# define __SIZEOF_PTHREAD_BARRIER_T 20
43# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
44#endif
45
46
47/* Thread identifiers. The structure of the attribute type is
48 deliberately not exposed. */
806e4a4a 49typedef unsigned long int pthread_t;
f3c13160
RM
50
51
8da0464f 52union pthread_attr_t
f3c13160
RM
53{
54 char __size[__SIZEOF_PTHREAD_ATTR_T];
55 long int __align;
4a3dded5
UD
56};
57#ifndef __have_pthread_attr_t
22f9d9df 58typedef union pthread_attr_t pthread_attr_t;
4a3dded5
UD
59# define __have_pthread_attr_t 1
60#endif
f3c13160
RM
61
62
683040c3
UD
63#if __WORDSIZE == 64
64typedef struct __pthread_internal_list
65{
66 struct __pthread_internal_list *__prev;
67 struct __pthread_internal_list *__next;
68} __pthread_list_t;
69#else
70typedef struct __pthread_internal_slist
71{
72 struct __pthread_internal_slist *__next;
73} __pthread_slist_t;
74#endif
75
76
f3c13160
RM
77/* Data structures for mutex handling. The structure of the attribute
78 type is deliberately not exposed. */
d804f5df 79typedef union
f3c13160 80{
d804f5df 81 struct __pthread_mutex_s
f3c13160
RM
82 {
83 int __lock;
84 unsigned int __count;
61623643
UD
85 int __owner;
86#if __WORDSIZE == 64
87 unsigned int __nusers;
88#endif
f3c13160 89 /* KIND must stay at this position in the structure to maintain
c74940f2 90 binary compatibility with static initializers. */
f3c13160 91 int __kind;
bfffffae 92#if __WORDSIZE == 64
8d2c0a59
AZ
93 short __spins;
94 short __elision;
683040c3 95 __pthread_list_t __list;
bfffffae 96# define __PTHREAD_MUTEX_HAVE_PREV 1
8d2c0a59 97# define __PTHREAD_SPINS 0, 0
bfffffae 98#else
61623643 99 unsigned int __nusers;
01a3f2ef 100 __extension__ union
bfffffae 101 {
8d2c0a59
AZ
102 struct
103 {
104 short __espins;
105 short __elision;
106# define __spins __elision_data.__espins
107# define __elision __elision_data.__elision
108# define __PTHREAD_SPINS { 0, 0 }
109 } __elision_data;
683040c3 110 __pthread_slist_t __list;
bfffffae 111 };
61623643 112#endif
f3c13160
RM
113 } __data;
114 char __size[__SIZEOF_PTHREAD_MUTEX_T];
115 long int __align;
116} pthread_mutex_t;
117
118typedef union
119{
120 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
7da168bf 121 int __align;
f3c13160
RM
122} pthread_mutexattr_t;
123
124
125/* Data structure for conditional variable handling. The structure of
ed19993b 126 the attribute type is not exposed on purpose. */
f3c13160
RM
127typedef union
128{
129 struct
130 {
ed19993b
TR
131 __extension__ union
132 {
133 __extension__ unsigned long long int __wseq;
134 struct {
135 unsigned int __low;
136 unsigned int __high;
137 } __wseq32;
138 };
139 __extension__ union
140 {
141 __extension__ unsigned long long int __g1_start;
142 struct {
143 unsigned int __low;
144 unsigned int __high;
145 } __g1_start32;
146 };
147 unsigned int __g_refs[2];
148 unsigned int __g_size[2];
149 unsigned int __g1_orig_size;
150 unsigned int __wrefs;
151 unsigned int __g_signals[2];
f3c13160
RM
152 } __data;
153 char __size[__SIZEOF_PTHREAD_COND_T];
e9f4e844 154 __extension__ long long int __align;
f3c13160
RM
155} pthread_cond_t;
156
157typedef union
158{
159 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
7da168bf 160 int __align;
f3c13160
RM
161} pthread_condattr_t;
162
163
164/* Keys for thread-specific data */
165typedef unsigned int pthread_key_t;
166
167
168/* Once-only execution */
169typedef int pthread_once_t;
170
171
ccc63b07 172#if defined __USE_UNIX98 || defined __USE_XOPEN2K
f3c13160
RM
173/* Data structure for read-write lock variable handling. The
174 structure of the attribute type is deliberately not exposed. */
175typedef union
176{
a234e27d 177# if __WORDSIZE == 64
f3c13160
RM
178 struct
179 {
cc25c8b4
TR
180 unsigned int __readers;
181 unsigned int __writers;
182 unsigned int __wrphase_futex;
183 unsigned int __writers_futex;
184 unsigned int __pad3;
185 unsigned int __pad4;
186 int __cur_writer;
e59660bc 187 int __shared;
4b45943a
AZ
188 unsigned char __rwelision;
189 unsigned char __pad1[7];
a234e27d
UD
190 unsigned long int __pad2;
191 /* FLAGS must stay at this position in the structure to maintain
192 binary compatibility. */
193 unsigned int __flags;
4b45943a 194# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, {0, 0, 0, 0, 0, 0, 0 }
a234e27d
UD
195 } __data;
196# else
197 struct
198 {
cc25c8b4
TR
199 unsigned int __readers;
200 unsigned int __writers;
201 unsigned int __wrphase_futex;
202 unsigned int __writers_futex;
203 unsigned int __pad3;
204 unsigned int __pad4;
4b45943a 205 unsigned char __rwelision;
e59660bc
UD
206 unsigned char __pad2;
207 unsigned char __shared;
f3c13160
RM
208 /* FLAGS must stay at this position in the structure to maintain
209 binary compatibility. */
e59660bc 210 unsigned char __flags;
cc25c8b4 211 int __cur_writer;
4b45943a 212#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
f3c13160 213 } __data;
a234e27d 214# endif
f3c13160
RM
215 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
216 long int __align;
217} pthread_rwlock_t;
218
8491ed6d 219
f3c13160
RM
220typedef union
221{
222 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
223 long int __align;
224} pthread_rwlockattr_t;
225#endif
226
227
228#ifdef __USE_XOPEN2K
229/* POSIX spinlock data type. */
230typedef volatile int pthread_spinlock_t;
231
232
233/* POSIX barriers data type. The structure of the type is
234 deliberately not exposed. */
235typedef union
236{
237 char __size[__SIZEOF_PTHREAD_BARRIER_T];
238 long int __align;
239} pthread_barrier_t;
240
241typedef union
242{
243 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
244 int __align;
245} pthread_barrierattr_t;
246#endif
247
248
249#endif /* bits/pthreadtypes.h */