]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
Inital import
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / pthread / bits / pthreadtypes.h
1 /* Linuxthreads - a simple clone()-based implementation of Posix        */
2 /* threads for Linux.                                                   */
3 /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr)              */
4 /*                                                                      */
5 /* This program is free software; you can redistribute it and/or        */
6 /* modify it under the terms of the GNU Library General Public License  */
7 /* as published by the Free Software Foundation; either version 2       */
8 /* of the License, or (at your option) any later version.               */
9 /*                                                                      */
10 /* This program is distributed in the hope that it will be useful,      */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of       */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
13 /* GNU Library General Public License for more details.                 */
14
15 #if !defined _BITS_TYPES_H && !defined _PTHREAD_H
16 # error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
17 #endif
18
19 #ifndef _BITS_PTHREADTYPES_H
20 #define _BITS_PTHREADTYPES_H    1
21
22 #define __need_schedparam
23 #include <bits/sched.h>
24
25 /* Fast locks (not abstract because mutexes and conditions aren't abstract). */
26 struct _pthread_fastlock
27 {
28   long int __status;   /* "Free" or "taken" or head of waiting list */
29   int __spinlock;      /* Used by compare_and_swap emulation. Also,
30                           adaptive SMP lock stores spin count here. */
31 };
32
33 #ifndef _PTHREAD_DESCR_DEFINED
34 /* Thread descriptors */
35 typedef struct _pthread_descr_struct *_pthread_descr;
36 # define _PTHREAD_DESCR_DEFINED
37 #endif
38
39
40 /* Attributes for threads.  */
41 typedef struct __pthread_attr_s
42 {
43   int __detachstate;
44   int __schedpolicy;
45   struct __sched_param __schedparam;
46   int __inheritsched;
47   int __scope;
48   size_t __guardsize;
49   int __stackaddr_set;
50   void *__stackaddr;
51   size_t __stacksize;
52 } pthread_attr_t;
53
54
55 /* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
56
57 #ifdef __GLIBC_HAVE_LONG_LONG
58 __extension__ typedef long long __pthread_cond_align_t;
59 #else
60 typedef long __pthread_cond_align_t;
61 #endif
62
63 typedef struct
64 {
65   struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
66   _pthread_descr __c_waiting;        /* Threads waiting on this condition */
67   char __padding[48 - sizeof (struct _pthread_fastlock)
68                  - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
69   __pthread_cond_align_t __align;
70 } pthread_cond_t;
71
72
73 /* Attribute for conditionally variables.  */
74 typedef struct
75 {
76   int __dummy;
77 } pthread_condattr_t;
78
79 /* Keys for thread-specific data */
80 typedef unsigned int pthread_key_t;
81
82
83 /* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER).  */
84 /* (The layout is unnatural to maintain binary compatibility
85     with earlier releases of LinuxThreads.) */
86 typedef struct
87 {
88   int __m_reserved;               /* Reserved for future use */
89   int __m_count;                  /* Depth of recursive locking */
90   _pthread_descr __m_owner;       /* Owner thread (if recursive or errcheck) */
91   int __m_kind;                   /* Mutex kind: fast, recursive or errcheck */
92   struct _pthread_fastlock __m_lock; /* Underlying fast lock */
93 } pthread_mutex_t;
94
95
96 /* Attribute for mutex.  */
97 typedef struct
98 {
99   int __mutexkind;
100 } pthread_mutexattr_t;
101
102
103 /* Once-only execution */
104 typedef int pthread_once_t;
105
106
107 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
108 /* Read-write locks.  */
109 typedef struct _pthread_rwlock_t
110 {
111   struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
112   int __rw_readers;                   /* Number of readers */
113   _pthread_descr __rw_writer;         /* Identity of writer, or NULL if none */
114   _pthread_descr __rw_read_waiting;   /* Threads waiting for reading */
115   _pthread_descr __rw_write_waiting;  /* Threads waiting for writing */
116   int __rw_kind;                      /* Reader/Writer preference selection */
117   int __rw_pshared;                   /* Shared between processes or not */
118 } pthread_rwlock_t;
119
120
121 /* Attribute for read-write locks.  */
122 typedef struct
123 {
124   int __lockkind;
125   int __pshared;
126 } pthread_rwlockattr_t;
127 #endif
128
129 #ifdef __USE_XOPEN2K
130 /* POSIX spinlock data type.  */
131 typedef __volatile__ int pthread_spinlock_t;
132
133 /* POSIX barrier. */
134 typedef struct {
135   struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
136   int __ba_required;                  /* Threads needed for completion */
137   int __ba_present;                   /* Threads waiting */
138   _pthread_descr __ba_waiting;        /* Queue of waiting threads */
139 } pthread_barrier_t;
140
141 /* barrier attribute */
142 typedef struct {
143   int __pshared;
144 } pthread_barrierattr_t;
145
146 #endif
147
148
149 /* Thread identifiers */
150 typedef unsigned long int pthread_t;
151
152 #endif  /* bits/pthreadtypes.h */