]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 2002-2014 Free Software Foundation, Inc. |
76a50749 UD |
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 | |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
76a50749 UD |
18 | |
19 | #ifndef _INTERNALTYPES_H | |
20 | #define _INTERNALTYPES_H 1 | |
21 | ||
73e9ae88 UD |
22 | #include <stdint.h> |
23 | ||
76a50749 UD |
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; | |
80f536db UD |
37 | /* Affinity map. */ |
38 | cpu_set_t *cpuset; | |
701a7b23 | 39 | size_t cpusetsize; |
76a50749 UD |
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 | |
5cb48b84 | 46 | #define ATTR_FLAG_OLDATTR 0x0010 |
14ffbc83 UD |
47 | #define ATTR_FLAG_SCHED_SET 0x0020 |
48 | #define ATTR_FLAG_POLICY_SET 0x0040 | |
76a50749 UD |
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 | { | |
86a9ee5e UD |
67 | /* Combination of values: |
68 | ||
382466e0 | 69 | Bit 0 : flag whether conditional variable will be sharable between |
86a9ee5e UD |
70 | processes. |
71 | ||
72 | Bit 1-7: clock ID. */ | |
73 | int value; | |
76a50749 UD |
74 | }; |
75 | ||
76 | ||
73f7c32c | 77 | /* The __NWAITERS field is used as a counter and to house the number |
ee5d5755 UD |
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 | |
0154658d | 82 | #define COND_NWAITERS_SHIFT 1 |
73f7c32c UD |
83 | |
84 | ||
76a50749 UD |
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; | |
d8ff3792 | 100 | int private; |
76a50749 UD |
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. */ | |
3d2dd6ca | 142 | struct new_sem |
76a50749 | 143 | { |
3d2dd6ca UD |
144 | unsigned int value; |
145 | int private; | |
146 | unsigned long int nwaiters; | |
147 | }; | |
148 | ||
149 | struct old_sem | |
150 | { | |
151 | unsigned int value; | |
76a50749 UD |
152 | }; |
153 | ||
73e9ae88 UD |
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 | ||
76a50749 | 161 | #endif /* internaltypes.h */ |