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