OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libpthread / nptl / sysdeps / unix / sysv / linux / internaltypes.h
1 /* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library 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 GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _INTERNALTYPES_H
20 #define _INTERNALTYPES_H        1
21
22 #include <stdint.h>
23 #include <sched.h>
24
25 struct pthread_attr
26 {
27   /* Scheduler parameters and priority.  */
28   struct sched_param schedparam;
29   int schedpolicy;
30   /* Various flags like detachstate, scope, etc.  */
31   int flags;
32   /* Size of guard area.  */
33   size_t guardsize;
34   /* Stack handling.  */
35   void *stackaddr;
36   size_t stacksize;
37   /* Affinity map.  */
38   cpu_set_t *cpuset;
39   size_t cpusetsize;
40 };
41
42 #define ATTR_FLAG_DETACHSTATE           0x0001
43 #define ATTR_FLAG_NOTINHERITSCHED       0x0002
44 #define ATTR_FLAG_SCOPEPROCESS          0x0004
45 #define ATTR_FLAG_STACKADDR             0x0008
46 #define ATTR_FLAG_OLDATTR               0x0010
47 #define ATTR_FLAG_SCHED_SET             0x0020
48 #define ATTR_FLAG_POLICY_SET            0x0040
49
50
51 /* Mutex attribute data structure.  */
52 struct pthread_mutexattr
53 {
54   /* Identifier for the kind of mutex.
55
56      Bit 31 is set if the mutex is to be shared between processes.
57
58      Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
59      the type of the mutex.  */
60   int mutexkind;
61 };
62
63
64 /* Conditional variable attribute data structure.  */
65 struct pthread_condattr
66 {
67   /* Combination of values:
68
69      Bit 0  : flag whether coditional variable will be shareable between
70               processes.
71
72      Bit 1-7: clock ID.  */
73   int value;
74 };
75
76
77 /* The __NWAITERS field is used as a counter and to house the number
78    of bits for other purposes.  COND_CLOCK_BITS is the number
79    of bits needed to represent the ID of the clock.  COND_NWAITERS_SHIFT
80    is the number of bits reserved for other purposes like the clock.  */
81 #define COND_CLOCK_BITS         1
82 #define COND_NWAITERS_SHIFT     1
83
84
85 /* Read-write lock variable attribute data structure.  */
86 struct pthread_rwlockattr
87 {
88   int lockkind;
89   int pshared;
90 };
91
92
93 /* Barrier data structure.  */
94 struct pthread_barrier
95 {
96   unsigned int curr_event;
97   int lock;
98   unsigned int left;
99   unsigned int init_count;
100   int private;
101 };
102
103
104 /* Barrier variable attribute data structure.  */
105 struct pthread_barrierattr
106 {
107   int pshared;
108 };
109
110
111 /* Thread-local data handling.  */
112 struct pthread_key_struct
113 {
114   /* Sequence numbers.  Even numbers indicated vacant entries.  Note
115      that zero is even.  We use uintptr_t to not require padding on
116      32- and 64-bit machines.  On 64-bit machines it helps to avoid
117      wrapping, too.  */
118   uintptr_t seq;
119
120   /* Destructor for the data.  */
121   void (*destr) (void *);
122 };
123
124 /* Check whether an entry is unused.  */
125 #define KEY_UNUSED(p) (((p) & 1) == 0)
126 /* Check whether a key is usable.  We cannot reuse an allocated key if
127    the sequence counter would overflow after the next destroy call.
128    This would mean that we potentially free memory for a key with the
129    same sequence.  This is *very* unlikely to happen, A program would
130    have to create and destroy a key 2^31 times (on 32-bit platforms,
131    on 64-bit platforms that would be 2^63).  If it should happen we
132    simply don't use this specific key anymore.  */
133 #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
134
135
136 /* Handling of read-write lock data.  */
137 // XXX For now there is only one flag.  Maybe more in future.
138 #define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
139
140
141 /* Semaphore variable structure.  */
142 struct new_sem
143 {
144   unsigned int value;
145   int private;
146   unsigned long int nwaiters;
147 };
148
149 struct old_sem
150 {
151   unsigned int value;
152 };
153
154
155 /* Compatibility type for old conditional variable interfaces.  */
156 typedef struct
157 {
158   pthread_cond_t *cond;
159 } pthread_cond_2_0_t;
160
161 #endif  /* internaltypes.h */