]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/tile/nptl/bits/pthreadtypes.h
New pthread rwlock that is more scalable.
[thirdparty/glibc.git] / sysdeps / tile / nptl / bits / pthreadtypes.h
CommitLineData
bfff8b1b 1/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
63d143a2
CM
2 This file is part of the GNU C Library.
3 Based on work contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
ab84e3ff
PE
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
63d143a2
CM
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. */
50typedef unsigned long int pthread_t;
51
52
87df4a4b 53union pthread_attr_t
63d143a2
CM
54{
55 char __size[__SIZEOF_PTHREAD_ATTR_T];
56 long int __align;
87df4a4b
CM
57};
58#ifndef __have_pthread_attr_t
59typedef union pthread_attr_t pthread_attr_t;
60# define __have_pthread_attr_t 1
61#endif
63d143a2
CM
62
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
77/* Data structures for mutex handling. The structure of the attribute
78 type is not exposed on purpose. */
79typedef union
80{
81 struct __pthread_mutex_s
82 {
83 int __lock;
84 unsigned int __count;
85 int __owner;
86#if __WORDSIZE == 64
87 unsigned int __nusers;
88#endif
89 /* KIND must stay at this position in the structure to maintain
c74940f2 90 binary compatibility with static initializers. */
63d143a2
CM
91 int __kind;
92#if __WORDSIZE == 64
93 int __spins;
94 __pthread_list_t __list;
95# define __PTHREAD_MUTEX_HAVE_PREV 1
96#else
97 unsigned int __nusers;
98 __extension__ union
99 {
100 int __spins;
101 __pthread_slist_t __list;
102 };
103#endif
104 } __data;
105 char __size[__SIZEOF_PTHREAD_MUTEX_T];
106 long int __align;
107} pthread_mutex_t;
108
109typedef union
110{
111 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
112 int __align;
113} pthread_mutexattr_t;
114
01f8eac2
AZ
115/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
116#define __PTHREAD_SPINS 0
117
63d143a2
CM
118
119/* Data structure for conditional variable handling. The structure of
120 the attribute type is not exposed on purpose. */
121typedef union
122{
123 struct
124 {
ed19993b
TR
125 __extension__ union
126 {
127 __extension__ unsigned long long int __wseq;
128 struct {
129 unsigned int __low;
130 unsigned int __high;
131 } __wseq32;
132 };
133 __extension__ union
134 {
135 __extension__ unsigned long long int __g1_start;
136 struct {
137 unsigned int __low;
138 unsigned int __high;
139 } __g1_start32;
140 };
141 unsigned int __g_refs[2];
142 unsigned int __g_size[2];
143 unsigned int __g1_orig_size;
144 unsigned int __wrefs;
145 unsigned int __g_signals[2];
63d143a2
CM
146 } __data;
147 char __size[__SIZEOF_PTHREAD_COND_T];
148 __extension__ long long int __align;
149} pthread_cond_t;
150
151typedef union
152{
153 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
154 int __align;
155} pthread_condattr_t;
156
157
158/* Keys for thread-specific data */
159typedef unsigned int pthread_key_t;
160
161
162/* Once-only execution */
163typedef int pthread_once_t;
164
165
166#if defined __USE_UNIX98 || defined __USE_XOPEN2K
167/* Data structure for read-write lock variable handling. The
168 structure of the attribute type is not exposed on purpose. */
169typedef union
170{
171# if __WORDSIZE == 64
172 struct
173 {
cc25c8b4
TR
174 unsigned int __readers;
175 unsigned int __writers;
176 unsigned int __wrphase_futex;
177 unsigned int __writers_futex;
178 unsigned int __pad3;
179 unsigned int __pad4;
180 int __cur_writer;
63d143a2
CM
181 int __shared;
182 unsigned long int __pad1;
183 unsigned long int __pad2;
184 /* FLAGS must stay at this position in the structure to maintain
185 binary compatibility. */
186 unsigned int __flags;
187 } __data;
188# else
189 struct
190 {
cc25c8b4
TR
191 unsigned int __readers;
192 unsigned int __writers;
193 unsigned int __wrphase_futex;
194 unsigned int __writers_futex;
195 unsigned int __pad3;
196 unsigned int __pad4;
63d143a2
CM
197 /* FLAGS must stay at this position in the structure to maintain
198 binary compatibility. */
199 unsigned char __flags;
200 unsigned char __shared;
201 unsigned char __pad1;
202 unsigned char __pad2;
cc25c8b4 203 int __cur_writer;
63d143a2
CM
204 } __data;
205# endif
206 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
207 long int __align;
208} pthread_rwlock_t;
209
8491ed6d
AK
210#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
211
63d143a2
CM
212typedef union
213{
214 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
215 long int __align;
216} pthread_rwlockattr_t;
217#endif
218
219
220#ifdef __USE_XOPEN2K
221/* POSIX spinlock data type. */
222typedef volatile int pthread_spinlock_t;
223
224
225/* POSIX barriers data type. The structure of the type is
226 deliberately not exposed. */
227typedef union
228{
229 char __size[__SIZEOF_PTHREAD_BARRIER_T];
230 long int __align;
231} pthread_barrier_t;
232
233typedef union
234{
235 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
236 int __align;
237} pthread_barrierattr_t;
238#endif
239
240
241#endif /* bits/pthreadtypes.h */