Back to index

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