Back to index

glibc  2.9
pthreadtypes.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _BITS_PTHREADTYPES_H
00021 #define _BITS_PTHREADTYPES_H       1
00022 
00023 #include <bits/wordsize.h>
00024 
00025 #if __WORDSIZE == 64
00026 # define __SIZEOF_PTHREAD_ATTR_T 56
00027 # define __SIZEOF_PTHREAD_MUTEX_T 40
00028 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
00029 # define __SIZEOF_PTHREAD_COND_T 48
00030 # define __SIZEOF_PTHREAD_CONDATTR_T 4
00031 # define __SIZEOF_PTHREAD_RWLOCK_T 56
00032 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
00033 # define __SIZEOF_PTHREAD_BARRIER_T 32
00034 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
00035 #else
00036 # define __SIZEOF_PTHREAD_ATTR_T 36
00037 # define __SIZEOF_PTHREAD_MUTEX_T 24
00038 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
00039 # define __SIZEOF_PTHREAD_COND_T 48
00040 # define __SIZEOF_PTHREAD_CONDATTR_T 4
00041 # define __SIZEOF_PTHREAD_RWLOCK_T 32
00042 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
00043 # define __SIZEOF_PTHREAD_BARRIER_T 20
00044 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
00045 #endif
00046 
00047 
00048 /* Thread identifiers.  The structure of the attribute type is not
00049    exposed on purpose.  */
00050 typedef unsigned long int pthread_t;
00051 
00052 
00053 typedef union
00054 {
00055   char __size[__SIZEOF_PTHREAD_ATTR_T];
00056   long int __align;
00057 } pthread_attr_t;
00058 
00059 
00060 #if __WORDSIZE == 64
00061 typedef struct __pthread_internal_list
00062 {
00063   struct __pthread_internal_list *__prev;
00064   struct __pthread_internal_list *__next;
00065 } __pthread_list_t;
00066 #else
00067 typedef struct __pthread_internal_slist
00068 {
00069   struct __pthread_internal_slist *__next;
00070 } __pthread_slist_t;
00071 #endif
00072 
00073 
00074 /* Data structures for mutex handling.  The structure of the attribute
00075    type is not exposed on purpose.  */
00076 typedef union
00077 {
00078   struct __pthread_mutex_s
00079   {
00080     int __lock;
00081     unsigned int __count;
00082     int __owner;
00083 #if __WORDSIZE == 64
00084     unsigned int __nusers;
00085 #endif
00086     /* KIND must stay at this position in the structure to maintain
00087        binary compatibility.  */
00088     int __kind;
00089 #if __WORDSIZE == 64
00090     int __spins;
00091     __pthread_list_t __list;
00092 # define __PTHREAD_MUTEX_HAVE_PREV 1
00093 #else
00094     unsigned int __nusers;
00095     __extension__ union
00096     {
00097       int __spins;
00098       __pthread_slist_t __list;
00099     };
00100 #endif
00101   } __data;
00102   char __size[__SIZEOF_PTHREAD_MUTEX_T];
00103   long int __align;
00104 } pthread_mutex_t;
00105 
00106 typedef union
00107 {
00108   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
00109   int __align;
00110 } pthread_mutexattr_t;
00111 
00112 
00113 /* Data structure for conditional variable handling.  The structure of
00114    the attribute type is not exposed on purpose.  */
00115 typedef union
00116 {
00117   struct
00118   {
00119     int __lock;
00120     unsigned int __futex;
00121     __extension__ unsigned long long int __total_seq;
00122     __extension__ unsigned long long int __wakeup_seq;
00123     __extension__ unsigned long long int __woken_seq;
00124     void *__mutex;
00125     unsigned int __nwaiters;
00126     unsigned int __broadcast_seq;
00127   } __data;
00128   char __size[__SIZEOF_PTHREAD_COND_T];
00129   __extension__ long long int __align;
00130 } pthread_cond_t;
00131 
00132 typedef union
00133 {
00134   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
00135   int __align;
00136 } pthread_condattr_t;
00137 
00138 
00139 /* Keys for thread-specific data */
00140 typedef unsigned int pthread_key_t;
00141 
00142 
00143 /* Once-only execution */
00144 typedef int pthread_once_t;
00145 
00146 
00147 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
00148 /* Data structure for read-write lock variable handling.  The
00149    structure of the attribute type is not exposed on purpose.  */
00150 typedef union
00151 {
00152 # if __WORDSIZE == 64
00153   struct
00154   {
00155     int __lock;
00156     unsigned int __nr_readers;
00157     unsigned int __readers_wakeup;
00158     unsigned int __writer_wakeup;
00159     unsigned int __nr_readers_queued;
00160     unsigned int __nr_writers_queued;
00161     int __writer;
00162     int __shared;
00163     unsigned long int __pad1;
00164     unsigned long int __pad2;
00165     /* FLAGS must stay at this position in the structure to maintain
00166        binary compatibility.  */
00167     unsigned int __flags;
00168   } __data;
00169 # else
00170   struct
00171   {
00172     int __lock;
00173     unsigned int __nr_readers;
00174     unsigned int __readers_wakeup;
00175     unsigned int __writer_wakeup;
00176     unsigned int __nr_readers_queued;
00177     unsigned int __nr_writers_queued;
00178     /* FLAGS must stay at this position in the structure to maintain
00179        binary compatibility.  */
00180     unsigned char __flags;
00181     unsigned char __shared;
00182     unsigned char __pad1;
00183     unsigned char __pad2;
00184     int __writer;
00185   } __data;
00186 # endif
00187   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
00188   long int __align;
00189 } pthread_rwlock_t;
00190 
00191 typedef union
00192 {
00193   char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
00194   long int __align;
00195 } pthread_rwlockattr_t;
00196 #endif
00197 
00198 
00199 #ifdef __USE_XOPEN2K
00200 /* POSIX spinlock data type.  */
00201 typedef volatile int pthread_spinlock_t;
00202 
00203 
00204 /* POSIX barriers data type.  The structure of the type is
00205    deliberately not exposed.  */
00206 typedef union
00207 {
00208   char __size[__SIZEOF_PTHREAD_BARRIER_T];
00209   long int __align;
00210 } pthread_barrier_t;
00211 
00212 typedef union
00213 {
00214   char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
00215   int __align;
00216 } pthread_barrierattr_t;
00217 #endif
00218 
00219 
00220 #if __WORDSIZE == 32
00221 /* Extra attributes for the cleanup functions.  */
00222 # define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
00223 #endif
00224 
00225 #endif /* bits/pthreadtypes.h */