Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / hppa / nptl / bits / pthreadtypes.h
blobdeec4dae8c744f08912af0c6c095fd8c40a02c52
1 /* Copyright (C) 2005-2014 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 /* Linuxthread type sizes (bytes):
22 sizeof(pthread_attr_t) = 0x24 (36)
23 sizeof(pthread_barrier_t) = 0x30 (48)
24 sizeof(pthread_barrierattr_t) = 0x4 (4)
25 sizeof(pthread_cond_t) = 0x30 (48)
26 sizeof(pthread_condattr_t) = 0x4 (4)
27 sizeof(pthread_mutex_t) = 0x30 (48)
28 sizeof(pthread_mutexattr_t) = 0x4 (4)
29 sizeof(pthread_rwlock_t) = 0x40 (64)
30 sizeof(pthread_rwlockattr_t) = 0x8 (8)
31 sizeof(pthread_spinlock_t) = 0x10 (16) */
33 #define __SIZEOF_PTHREAD_ATTR_T 36
34 #define __SIZEOF_PTHREAD_BARRIER_T 48
35 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4
36 #define __SIZEOF_PTHREAD_COND_T 48
37 #define __SIZEOF_PTHREAD_CONDATTR_T 4
38 #define __SIZEOF_PTHREAD_MUTEX_T 48
39 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
40 #define __SIZEOF_PTHREAD_RWLOCK_T 64
41 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
43 /* Thread identifiers. The structure of the attribute type is not
44 exposed on purpose. */
45 typedef unsigned long int pthread_t;
47 union pthread_attr_t
49 char __size[__SIZEOF_PTHREAD_ATTR_T];
50 long int __align;
52 #ifndef __have_pthread_attr_t
53 typedef union pthread_attr_t pthread_attr_t;
54 # define __have_pthread_attr_t 1
55 #endif
58 typedef struct __pthread_internal_slist
60 struct __pthread_internal_slist *__next;
61 } __pthread_slist_t;
64 /* Data structures for mutex handling. The structure of the attribute
65 type is not exposed on purpose. */
66 typedef union
68 struct __pthread_mutex_s
70 int __lock __attribute__ ((aligned(16)));
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;
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. */
82 unsigned int __nusers;
83 __extension__ union
85 int __spins;
86 __pthread_slist_t __list;
88 /* Two more words are left before the NPTL
89 pthread_mutex_t is larger than Linuxthreads. */
90 int __reserved1;
91 int __reserved2;
92 } __data;
93 char __size[__SIZEOF_PTHREAD_MUTEX_T];
94 long int __align;
95 } pthread_mutex_t;
97 typedef union
99 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
100 long int __align;
101 } pthread_mutexattr_t;
104 /* Data structure for conditional variable handling. The structure of
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. */
111 typedef union
113 struct
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. */
119 int __lock __attribute__ ((aligned(16)));
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;
125 unsigned int __futex;
126 void *__mutex;
127 /* In the old Linuxthreads this would have been the start
128 of the pthread_fastlock status word. */
129 __extension__ unsigned long long int __total_seq;
130 __extension__ unsigned long long int __wakeup_seq;
131 __extension__ unsigned long long int __woken_seq;
132 unsigned int __nwaiters;
133 unsigned int __broadcast_seq;
134 /* The NPTL pthread_cond_t is exactly the same size as
135 the Linuxthreads version, there are no words to spare. */
136 } __data;
137 char __size[__SIZEOF_PTHREAD_COND_T];
138 __extension__ long long int __align;
139 } pthread_cond_t;
141 typedef union
143 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
144 long int __align;
145 } pthread_condattr_t;
148 /* Keys for thread-specific data */
149 typedef unsigned int pthread_key_t;
152 /* Once-only execution */
153 typedef int pthread_once_t;
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
161 struct
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. */
167 int __compat_padding[4] __attribute__ ((aligned(16)));
168 int __lock;
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;
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;
179 /* FLAGS must stay at this position in the structure to maintain
180 binary compatibility. */
181 unsigned char __pad2;
182 unsigned char __pad1;
183 unsigned char __shared;
184 unsigned char __flags;
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;
191 } __data;
192 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
193 long int __align;
194 } pthread_rwlock_t;
196 typedef union
198 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
199 long int __align;
200 } pthread_rwlockattr_t;
201 #endif
204 #ifdef __USE_XOPEN2K
205 /* POSIX spinlock data type. */
206 typedef volatile int pthread_spinlock_t;
209 /* POSIX barriers data type. The structure of the type is
210 deliberately not exposed. */
211 typedef union
213 char __size[__SIZEOF_PTHREAD_BARRIER_T];
214 long int __align;
215 } pthread_barrier_t;
217 typedef union
219 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
220 int __align;
221 } pthread_barrierattr_t;
222 #endif
225 #endif /* bits/pthreadtypes.h */