Back to index

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