Home | History | Annotate | Download | only in bits
      1 /* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
      2    This file is part of the GNU C Library.
      3 
      4    The GNU C Library is free software; you can redistribute it and/or
      5    modify it under the terms of the GNU Lesser General Public
      6    License as published by the Free Software Foundation; either
      7    version 2.1 of the License, or (at your option) any later version.
      8 
      9    The GNU C Library is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12    Lesser General Public License for more details.
     13 
     14    You should have received a copy of the GNU Lesser General Public
     15    License along with the GNU C Library; if not, write to the Free
     16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     17    02111-1307 USA.  */
     18 
     19 #ifndef _BITS_PTHREADTYPES_H
     20 #define _BITS_PTHREADTYPES_H	1
     21 
     22 #define __SIZEOF_PTHREAD_ATTR_T 36
     23 #define __SIZEOF_PTHREAD_MUTEX_T 24
     24 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
     25 #define __SIZEOF_PTHREAD_COND_T 48
     26 #define __SIZEOF_PTHREAD_COND_COMPAT_T 12
     27 #define __SIZEOF_PTHREAD_CONDATTR_T 4
     28 #define __SIZEOF_PTHREAD_RWLOCK_T 32
     29 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
     30 #define __SIZEOF_PTHREAD_BARRIER_T 20
     31 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4
     32 
     33 
     34 /* Thread identifiers.  The structure of the attribute type is not
     35    exposed on purpose.  */
     36 typedef unsigned long int pthread_t;
     37 
     38 
     39 typedef union
     40 {
     41   char __size[__SIZEOF_PTHREAD_ATTR_T];
     42   long int __align;
     43 } pthread_attr_t;
     44 
     45 
     46 typedef struct __pthread_internal_slist
     47 {
     48   struct __pthread_internal_slist *__next;
     49 } __pthread_slist_t;
     50 
     51 
     52 /* Data structures for mutex handling.  The structure of the attribute
     53    type is not exposed on purpose.  */
     54 typedef union
     55 {
     56   struct __pthread_mutex_s
     57   {
     58     int __lock;
     59     unsigned int __count;
     60     int __owner;
     61     /* KIND must stay at this position in the structure to maintain
     62        binary compatibility.  */
     63     int __kind;
     64     unsigned int __nusers;
     65     __extension__ union
     66     {
     67       int __spins;
     68       __pthread_slist_t __list;
     69     };
     70   } __data;
     71   char __size[__SIZEOF_PTHREAD_MUTEX_T];
     72   long int __align;
     73 } pthread_mutex_t;
     74 
     75 typedef union
     76 {
     77   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
     78   long int __align;
     79 } pthread_mutexattr_t;
     80 
     81 
     82 /* Data structure for conditional variable handling.  The structure of
     83    the attribute type is not exposed on purpose.  */
     84 typedef union
     85 {
     86   struct
     87   {
     88     int __lock;
     89     unsigned int __futex;
     90     __extension__ unsigned long long int __total_seq;
     91     __extension__ unsigned long long int __wakeup_seq;
     92     __extension__ unsigned long long int __woken_seq;
     93     void *__mutex;
     94     unsigned int __nwaiters;
     95     unsigned int __broadcast_seq;
     96   } __data;
     97   char __size[__SIZEOF_PTHREAD_COND_T];
     98   __extension__ long long int __align;
     99 } pthread_cond_t;
    100 
    101 typedef union
    102 {
    103   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
    104   long int __align;
    105 } pthread_condattr_t;
    106 
    107 
    108 /* Keys for thread-specific data */
    109 typedef unsigned int pthread_key_t;
    110 
    111 
    112 /* Once-only execution */
    113 typedef int pthread_once_t;
    114 
    115 
    116 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
    117 /* Data structure for read-write lock variable handling.  The
    118    structure of the attribute type is not exposed on purpose.  */
    119 typedef union
    120 {
    121   struct
    122   {
    123     int __lock;
    124     unsigned int __nr_readers;
    125     unsigned int __readers_wakeup;
    126     unsigned int __writer_wakeup;
    127     unsigned int __nr_readers_queued;
    128     unsigned int __nr_writers_queued;
    129     /* FLAGS must stay at this position in the structure to maintain
    130        binary compatibility.  */
    131     unsigned char __flags;
    132     unsigned char __shared;
    133     unsigned char __pad1;
    134     unsigned char __pad2;
    135     int __writer;
    136   } __data;
    137   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
    138   long int __align;
    139 } pthread_rwlock_t;
    140 
    141 typedef union
    142 {
    143   char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
    144   long int __align;
    145 } pthread_rwlockattr_t;
    146 #endif
    147 
    148 
    149 #ifdef __USE_XOPEN2K
    150 /* POSIX spinlock data type.  */
    151 typedef volatile int pthread_spinlock_t;
    152 
    153 
    154 /* POSIX barriers data type.  The structure of the type is
    155    deliberately not exposed.  */
    156 typedef union
    157 {
    158   char __size[__SIZEOF_PTHREAD_BARRIER_T];
    159   long int __align;
    160 } pthread_barrier_t;
    161 
    162 typedef union
    163 {
    164   char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
    165   int __align;
    166 } pthread_barrierattr_t;
    167 #endif
    168 
    169 
    170 /* Extra attributes for the cleanup functions.  */
    171 #define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
    172 
    173 #endif	/* bits/pthreadtypes.h */
    174