1    	/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
2    	   This file is part of the GNU C Library.
3    	   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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
16   	   License along with the GNU C Library; if not, write to the Free
17   	   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18   	   02111-1307 USA.  */
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.  */
50   	typedef unsigned long int pthread_t;
51   	
52   	
53   	typedef union
54   	{
55   	  char __size[__SIZEOF_PTHREAD_ATTR_T];
56   	  long int __align;
57   	} pthread_attr_t;
58   	
59   	
60   	#if __WORDSIZE == 64
61   	typedef struct __pthread_internal_list
62   	{
63   	  struct __pthread_internal_list *__prev;
64   	  struct __pthread_internal_list *__next;
65   	} __pthread_list_t;
66   	#else
67   	typedef struct __pthread_internal_slist
68   	{
69   	  struct __pthread_internal_slist *__next;
70   	} __pthread_slist_t;
71   	#endif
72   	
73   	
74   	/* Data structures for mutex handling.  The structure of the attribute
75   	   type is not exposed on purpose.  */
76   	typedef union
77   	{
78   	  struct __pthread_mutex_s
79   	  {
80   	    int __lock;
81   	    unsigned int __count;
82   	    int __owner;
83   	#if __WORDSIZE == 64
84   	    unsigned int __nusers;
85   	#endif
86   	    /* KIND must stay at this position in the structure to maintain
87   	       binary compatibility.  */
88   	    int __kind;
89   	#if __WORDSIZE == 64
90   	    int __spins;
91   	    __pthread_list_t __list;
92   	# define __PTHREAD_MUTEX_HAVE_PREV	1
93   	#else
94   	    unsigned int __nusers;
95   	    __extension__ union
96   	    {
97   	      int __spins;
98   	      __pthread_slist_t __list;
99   	    };
100  	#endif
101  	  } __data;
102  	  char __size[__SIZEOF_PTHREAD_MUTEX_T];
103  	  long int __align;
104  	} pthread_mutex_t;
105  	
106  	typedef union
107  	{
108  	  char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
109  	  int __align;
110  	} pthread_mutexattr_t;
111  	
112  	
113  	/* Data structure for conditional variable handling.  The structure of
114  	   the attribute type is not exposed on purpose.  */
115  	typedef union
116  	{
117  	  struct
118  	  {
119  	    int __lock;
120  	    unsigned int __futex;
121  	    __extension__ unsigned long long int __total_seq;
122  	    __extension__ unsigned long long int __wakeup_seq;
123  	    __extension__ unsigned long long int __woken_seq;
124  	    void *__mutex;
125  	    unsigned int __nwaiters;
126  	    unsigned int __broadcast_seq;
127  	  } __data;
128  	  char __size[__SIZEOF_PTHREAD_COND_T];
129  	  __extension__ long long int __align;
130  	} pthread_cond_t;
131  	
132  	typedef union
133  	{
134  	  char __size[__SIZEOF_PTHREAD_CONDATTR_T];
135  	  int __align;
136  	} pthread_condattr_t;
137  	
138  	
139  	/* Keys for thread-specific data */
140  	typedef unsigned int pthread_key_t;
141  	
142  	
143  	/* Once-only execution */
144  	typedef int pthread_once_t;
145  	
146  	
147  	#if defined __USE_UNIX98 || defined __USE_XOPEN2K
148  	/* Data structure for read-write lock variable handling.  The
149  	   structure of the attribute type is not exposed on purpose.  */
150  	typedef union
151  	{
152  	# if __WORDSIZE == 64
153  	  struct
154  	  {
155  	    int __lock;
156  	    unsigned int __nr_readers;
157  	    unsigned int __readers_wakeup;
158  	    unsigned int __writer_wakeup;
159  	    unsigned int __nr_readers_queued;
160  	    unsigned int __nr_writers_queued;
161  	    int __writer;
162  	    int __shared;
163  	    unsigned long int __pad1;
164  	    unsigned long int __pad2;
165  	    /* FLAGS must stay at this position in the structure to maintain
166  	       binary compatibility.  */
167  	    unsigned int __flags;
168  	  } __data;
169  	# else
170  	  struct
171  	  {
172  	    int __lock;
173  	    unsigned int __nr_readers;
174  	    unsigned int __readers_wakeup;
175  	    unsigned int __writer_wakeup;
176  	    unsigned int __nr_readers_queued;
177  	    unsigned int __nr_writers_queued;
178  	    /* FLAGS must stay at this position in the structure to maintain
179  	       binary compatibility.  */
180  	    unsigned char __flags;
181  	    unsigned char __shared;
182  	    unsigned char __pad1;
183  	    unsigned char __pad2;
184  	    int __writer;
185  	  } __data;
186  	# endif
187  	  char __size[__SIZEOF_PTHREAD_RWLOCK_T];
188  	  long int __align;
189  	} pthread_rwlock_t;
190  	
191  	typedef union
192  	{
193  	  char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
194  	  long int __align;
195  	} pthread_rwlockattr_t;
196  	#endif
197  	
198  	
199  	#ifdef __USE_XOPEN2K
200  	/* POSIX spinlock data type.  */
201  	typedef volatile int pthread_spinlock_t;
202  	
203  	
204  	/* POSIX barriers data type.  The structure of the type is
205  	   deliberately not exposed.  */
206  	typedef union
207  	{
208  	  char __size[__SIZEOF_PTHREAD_BARRIER_T];
209  	  long int __align;
210  	} pthread_barrier_t;
211  	
212  	typedef union
213  	{
214  	  char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
215  	  int __align;
216  	} pthread_barrierattr_t;
217  	#endif
218  	
219  	
220  	#if __WORDSIZE == 32
221  	/* Extra attributes for the cleanup functions.  */
222  	# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
223  	#endif
224  	
225  	#endif	/* bits/pthreadtypes.h */
226