Update copyright notices with scripts/update-copyrights.
[jlayton/glibc.git] / nptl / sysdeps / unix / sysv / linux / s390 / bits / pthreadtypes.h
1 /* Copyright (C) 2003-2013 Free Software Foundation, Inc.
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
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #ifndef _BITS_PTHREADTYPES_H
19 #define _BITS_PTHREADTYPES_H    1
20
21 #include <bits/wordsize.h>
22
23 #if __WORDSIZE == 64
24 # define __SIZEOF_PTHREAD_ATTR_T 56
25 # define __SIZEOF_PTHREAD_MUTEX_T 40
26 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
27 # define __SIZEOF_PTHREAD_COND_T 48
28 # define __SIZEOF_PTHREAD_CONDATTR_T 4
29 # define __SIZEOF_PTHREAD_RWLOCK_T 56
30 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
31 # define __SIZEOF_PTHREAD_BARRIER_T 32
32 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
33 #else
34 # define __SIZEOF_PTHREAD_ATTR_T 36
35 # define __SIZEOF_PTHREAD_MUTEX_T 24
36 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
37 # define __SIZEOF_PTHREAD_COND_T 48
38 # define __SIZEOF_PTHREAD_CONDATTR_T 4
39 # define __SIZEOF_PTHREAD_RWLOCK_T 32
40 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
41 # define __SIZEOF_PTHREAD_BARRIER_T 20
42 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
43 #endif
44
45
46 /* Thread identifiers.  The structure of the attribute type is not
47    exposed on purpose.  */
48 typedef unsigned long int pthread_t;
49
50
51 union pthread_attr_t
52 {
53   char __size[__SIZEOF_PTHREAD_ATTR_T];
54   long int __align;
55 };
56 #ifndef __have_pthread_attr_t
57 typedef union pthread_attr_t pthread_attr_t;
58 # define __have_pthread_attr_t  1
59 #endif
60
61
62 #if __WORDSIZE == 64
63 typedef struct __pthread_internal_list
64 {
65   struct __pthread_internal_list *__prev;
66   struct __pthread_internal_list *__next;
67 } __pthread_list_t;
68 #else
69 typedef struct __pthread_internal_slist
70 {
71   struct __pthread_internal_slist *__next;
72 } __pthread_slist_t;
73 #endif
74
75
76 /* Data structures for mutex handling.  The structure of the attribute
77    type is not exposed on purpose.  */
78 typedef union
79 {
80   struct __pthread_mutex_s
81   {
82     int __lock;
83     unsigned int __count;
84     int __owner;
85 #if __WORDSIZE == 64
86     unsigned int __nusers;
87 #endif
88     /* KIND must stay at this position in the structure to maintain
89        binary compatibility.  */
90     int __kind;
91 #if __WORDSIZE == 64
92     int __spins;
93     __pthread_list_t __list;
94 # define __PTHREAD_MUTEX_HAVE_PREV      1
95 #else
96     unsigned int __nusers;
97     __extension__ union
98     {
99       int __spins;
100       __pthread_slist_t __list;
101     };
102 #endif
103   } __data;
104   char __size[__SIZEOF_PTHREAD_MUTEX_T];
105   long int __align;
106 } pthread_mutex_t;
107
108 typedef union
109 {
110   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
111   int __align;
112 } pthread_mutexattr_t;
113
114
115 /* Data structure for conditional variable handling.  The structure of
116    the attribute type is not exposed on purpose.  */
117 typedef union
118 {
119   struct
120   {
121     int __lock;
122     unsigned int __futex;
123     __extension__ unsigned long long int __total_seq;
124     __extension__ unsigned long long int __wakeup_seq;
125     __extension__ unsigned long long int __woken_seq;
126     void *__mutex;
127     unsigned int __nwaiters;
128     unsigned int __broadcast_seq;
129   } __data;
130   char __size[__SIZEOF_PTHREAD_COND_T];
131   __extension__ long long int __align;
132 } pthread_cond_t;
133
134 typedef union
135 {
136   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
137   int __align;
138 } pthread_condattr_t;
139
140
141 /* Keys for thread-specific data */
142 typedef unsigned int pthread_key_t;
143
144
145 /* Once-only execution */
146 typedef int pthread_once_t;
147
148
149 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
150 /* Data structure for read-write lock variable handling.  The
151    structure of the attribute type is not exposed on purpose.  */
152 typedef union
153 {
154 # if __WORDSIZE == 64
155   struct
156   {
157     int __lock;
158     unsigned int __nr_readers;
159     unsigned int __readers_wakeup;
160     unsigned int __writer_wakeup;
161     unsigned int __nr_readers_queued;
162     unsigned int __nr_writers_queued;
163     int __writer;
164     int __shared;
165     unsigned long int __pad1;
166     unsigned long int __pad2;
167     /* FLAGS must stay at this position in the structure to maintain
168        binary compatibility.  */
169     unsigned int __flags;
170   } __data;
171 # else
172   struct
173   {
174     int __lock;
175     unsigned int __nr_readers;
176     unsigned int __readers_wakeup;
177     unsigned int __writer_wakeup;
178     unsigned int __nr_readers_queued;
179     unsigned int __nr_writers_queued;
180     unsigned char __pad1;
181     unsigned char __pad2;
182     unsigned char __shared;
183     /* FLAGS must stay at this position in the structure to maintain
184        binary compatibility.  */
185     unsigned char __flags;
186     int __writer;
187   } __data;
188 # endif
189   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
190   long int __align;
191 } pthread_rwlock_t;
192
193 typedef union
194 {
195   char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
196   long int __align;
197 } pthread_rwlockattr_t;
198 #endif
199
200
201 #ifdef __USE_XOPEN2K
202 /* POSIX spinlock data type.  */
203 typedef volatile int pthread_spinlock_t;
204
205
206 /* POSIX barriers data type.  The structure of the type is
207    deliberately not exposed.  */
208 typedef union
209 {
210   char __size[__SIZEOF_PTHREAD_BARRIER_T];
211   long int __align;
212 } pthread_barrier_t;
213
214 typedef union
215 {
216   char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
217   int __align;
218 } pthread_barrierattr_t;
219 #endif
220
221
222 #endif  /* bits/pthreadtypes.h */