Back to index

glibc  2.9
pthreadtypes.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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 <endian.h>
00025 
00026 #define __SIZEOF_PTHREAD_ATTR_T 36
00027 #define __SIZEOF_PTHREAD_MUTEX_T 24
00028 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
00029 #define __SIZEOF_PTHREAD_COND_T 48
00030 #define __SIZEOF_PTHREAD_COND_COMPAT_T 12
00031 #define __SIZEOF_PTHREAD_CONDATTR_T 4
00032 #define __SIZEOF_PTHREAD_RWLOCK_T 32
00033 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
00034 #define __SIZEOF_PTHREAD_BARRIER_T 20
00035 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4
00036 
00037 
00038 /* Thread identifiers.  The structure of the attribute type is not
00039    exposed on purpose.  */
00040 typedef unsigned long int pthread_t;
00041 
00042 
00043 typedef union
00044 {
00045   char __size[__SIZEOF_PTHREAD_ATTR_T];
00046   long int __align;
00047 } pthread_attr_t;
00048 
00049 
00050 typedef struct __pthread_internal_slist
00051 {
00052   struct __pthread_internal_slist *__next;
00053 } __pthread_slist_t;
00054 
00055 
00056 /* Data structures for mutex handling.  The structure of the attribute
00057    type is not exposed on purpose.  */
00058 typedef union
00059 {
00060   struct __pthread_mutex_s
00061   {
00062     int __lock;
00063     unsigned int __count;
00064     int __owner;
00065     /* KIND must stay at this position in the structure to maintain
00066        binary compatibility.  */
00067     int __kind;
00068     unsigned int __nusers;
00069     __extension__ union
00070     {
00071       int __spins;
00072       __pthread_slist_t __list;
00073     };
00074   } __data;
00075   char __size[__SIZEOF_PTHREAD_MUTEX_T];
00076   long int __align;
00077 } pthread_mutex_t;
00078 
00079 typedef union
00080 {
00081   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
00082   long int __align;
00083 } pthread_mutexattr_t;
00084 
00085 
00086 /* Data structure for conditional variable handling.  The structure of
00087    the attribute type is not exposed on purpose.  */
00088 typedef union
00089 {
00090   struct
00091   {
00092     int __lock;
00093     unsigned int __futex;
00094     __extension__ unsigned long long int __total_seq;
00095     __extension__ unsigned long long int __wakeup_seq;
00096     __extension__ unsigned long long int __woken_seq;
00097     void *__mutex;
00098     unsigned int __nwaiters;
00099     unsigned int __broadcast_seq;
00100   } __data;
00101   char __size[__SIZEOF_PTHREAD_COND_T];
00102   __extension__ long long int __align;
00103 } pthread_cond_t;
00104 
00105 typedef union
00106 {
00107   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
00108   long int __align;
00109 } pthread_condattr_t;
00110 
00111 
00112 /* Keys for thread-specific data */
00113 typedef unsigned int pthread_key_t;
00114 
00115 
00116 /* Once-only execution */
00117 typedef int pthread_once_t;
00118 
00119 
00120 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
00121 /* Data structure for read-write lock variable handling.  The
00122    structure of the attribute type is not exposed on purpose.  */
00123 typedef union
00124 {
00125   struct
00126   {
00127     int __lock;
00128     unsigned int __nr_readers;
00129     unsigned int __readers_wakeup;
00130     unsigned int __writer_wakeup;
00131     unsigned int __nr_readers_queued;
00132     unsigned int __nr_writers_queued;
00133 #if __BYTE_ORDER == __BIG_ENDIAN
00134     unsigned char __pad1;
00135     unsigned char __pad2;
00136     unsigned char __shared;
00137     /* FLAGS must stay at this position in the structure to maintain
00138        binary compatibility.  */
00139     unsigned char __flags;
00140 #else
00141     /* FLAGS must stay at this position in the structure to maintain
00142        binary compatibility.  */
00143     unsigned char __flags;
00144     unsigned char __shared;
00145     unsigned char __pad1;
00146     unsigned char __pad2;
00147 #endif
00148     pthread_t __writer;
00149   } __data;
00150   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
00151   long int __align;
00152 } pthread_rwlock_t;
00153 
00154 typedef union
00155 {
00156   char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
00157   long int __align;
00158 } pthread_rwlockattr_t;
00159 #endif
00160 
00161 
00162 #ifdef __USE_XOPEN2K
00163 /* POSIX spinlock data type.  */
00164 typedef volatile int pthread_spinlock_t;
00165 
00166 
00167 /* POSIX barriers data type.  The structure of the type is
00168    deliberately not exposed.  */
00169 typedef union
00170 {
00171   char __size[__SIZEOF_PTHREAD_BARRIER_T];
00172   long int __align;
00173 } pthread_barrier_t;
00174 
00175 typedef union
00176 {
00177   char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
00178   int __align;
00179 } pthread_barrierattr_t;
00180 #endif
00181 
00182 
00183 #endif /* bits/pthreadtypes.h */