]>
Commit | Line | Data |
---|---|---|
73e9ae88 | 1 | /* Copyright (C) 2002, 2003 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 | |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #ifndef _INTERNALTYPES_H | |
21 | #define _INTERNALTYPES_H 1 | |
22 | ||
73e9ae88 UD |
23 | #include <stdint.h> |
24 | ||
76a50749 UD |
25 | |
26 | struct pthread_attr | |
27 | { | |
28 | /* Scheduler parameters and priority. */ | |
29 | struct sched_param schedparam; | |
30 | int schedpolicy; | |
31 | /* Various flags like detachstate, scope, etc. */ | |
32 | int flags; | |
33 | /* Size of guard area. */ | |
34 | size_t guardsize; | |
35 | /* Stack handling. */ | |
36 | void *stackaddr; | |
37 | size_t stacksize; | |
80f536db UD |
38 | /* Affinity map. */ |
39 | cpu_set_t *cpuset; | |
76a50749 UD |
40 | |
41 | /* Chain of all initialized attributes. Keep this last since it is | |
42 | not always used. */ | |
43 | struct pthread_attr *next; | |
44 | }; | |
45 | ||
46 | #define ATTR_FLAG_DETACHSTATE 0x0001 | |
47 | #define ATTR_FLAG_NOTINHERITSCHED 0x0002 | |
48 | #define ATTR_FLAG_SCOPEPROCESS 0x0004 | |
49 | #define ATTR_FLAG_STACKADDR 0x0008 | |
5cb48b84 | 50 | #define ATTR_FLAG_OLDATTR 0x0010 |
76a50749 UD |
51 | |
52 | ||
53 | /* Mutex attribute data structure. */ | |
54 | struct pthread_mutexattr | |
55 | { | |
56 | /* Identifier for the kind of mutex. | |
57 | ||
58 | Bit 31 is set if the mutex is to be shared between processes. | |
59 | ||
60 | Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify | |
61 | the type of the mutex. */ | |
62 | int mutexkind; | |
63 | }; | |
64 | ||
65 | ||
66 | /* Conditional variable attribute data structure. */ | |
67 | struct pthread_condattr | |
68 | { | |
86a9ee5e UD |
69 | /* Combination of values: |
70 | ||
71 | Bit 0 : flag whether coditional variable will be shareable between | |
72 | processes. | |
73 | ||
74 | Bit 1-7: clock ID. */ | |
75 | int value; | |
76a50749 UD |
76 | }; |
77 | ||
78 | ||
79 | /* Read-write lock variable attribute data structure. */ | |
80 | struct pthread_rwlockattr | |
81 | { | |
82 | int lockkind; | |
83 | int pshared; | |
84 | }; | |
85 | ||
86 | ||
87 | /* Barrier data structure. */ | |
88 | struct pthread_barrier | |
89 | { | |
90 | unsigned int curr_event; | |
91 | int lock; | |
92 | unsigned int left; | |
93 | unsigned int init_count; | |
94 | }; | |
95 | ||
96 | ||
97 | /* Barrier variable attribute data structure. */ | |
98 | struct pthread_barrierattr | |
99 | { | |
100 | int pshared; | |
101 | }; | |
102 | ||
103 | ||
104 | /* Thread-local data handling. */ | |
105 | struct pthread_key_struct | |
106 | { | |
107 | /* Sequence numbers. Even numbers indicated vacant entries. Note | |
108 | that zero is even. We use uintptr_t to not require padding on | |
109 | 32- and 64-bit machines. On 64-bit machines it helps to avoid | |
110 | wrapping, too. */ | |
111 | uintptr_t seq; | |
112 | ||
113 | /* Destructor for the data. */ | |
114 | void (*destr) (void *); | |
115 | }; | |
116 | ||
117 | /* Check whether an entry is unused. */ | |
118 | #define KEY_UNUSED(p) (((p) & 1) == 0) | |
119 | /* Check whether a key is usable. We cannot reuse an allocated key if | |
120 | the sequence counter would overflow after the next destroy call. | |
121 | This would mean that we potentially free memory for a key with the | |
122 | same sequence. This is *very* unlikely to happen, A program would | |
123 | have to create and destroy a key 2^31 times (on 32-bit platforms, | |
124 | on 64-bit platforms that would be 2^63). If it should happen we | |
125 | simply don't use this specific key anymore. */ | |
126 | #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2))) | |
127 | ||
128 | ||
129 | /* Handling of read-write lock data. */ | |
130 | // XXX For now there is only one flag. Maybe more in future. | |
131 | #define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0) | |
132 | ||
133 | ||
134 | /* Semaphore variable structure. */ | |
135 | struct sem | |
136 | { | |
137 | unsigned int count; | |
138 | }; | |
139 | ||
73e9ae88 UD |
140 | |
141 | /* Compatibility type for old conditional variable interfaces. */ | |
142 | typedef struct | |
143 | { | |
144 | pthread_cond_t *cond; | |
145 | } pthread_cond_2_0_t; | |
146 | ||
76a50749 | 147 | #endif /* internaltypes.h */ |