]> git.ipfire.org Git - thirdparty/glibc.git/blame - nptl/sysdeps/unix/sysv/linux/internaltypes.h
Update.
[thirdparty/glibc.git] / nptl / sysdeps / unix / sysv / linux / internaltypes.h
CommitLineData
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
26struct 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;
38
39 /* Chain of all initialized attributes. Keep this last since it is
40 not always used. */
41 struct pthread_attr *next;
42};
43
44#define ATTR_FLAG_DETACHSTATE 0x0001
45#define ATTR_FLAG_NOTINHERITSCHED 0x0002
46#define ATTR_FLAG_SCOPEPROCESS 0x0004
47#define ATTR_FLAG_STACKADDR 0x0008
48
49
50/* Mutex attribute data structure. */
51struct pthread_mutexattr
52{
53 /* Identifier for the kind of mutex.
54
55 Bit 31 is set if the mutex is to be shared between processes.
56
57 Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
58 the type of the mutex. */
59 int mutexkind;
60};
61
62
63/* Conditional variable attribute data structure. */
64struct pthread_condattr
65{
66 /* Flag whether coditional variable will be shareable between processes. */
67 int pshared;
68};
69
70
71/* Read-write lock variable attribute data structure. */
72struct pthread_rwlockattr
73{
74 int lockkind;
75 int pshared;
76};
77
78
79/* Barrier data structure. */
80struct pthread_barrier
81{
82 unsigned int curr_event;
83 int lock;
84 unsigned int left;
85 unsigned int init_count;
86};
87
88
89/* Barrier variable attribute data structure. */
90struct pthread_barrierattr
91{
92 int pshared;
93};
94
95
96/* Thread-local data handling. */
97struct pthread_key_struct
98{
99 /* Sequence numbers. Even numbers indicated vacant entries. Note
100 that zero is even. We use uintptr_t to not require padding on
101 32- and 64-bit machines. On 64-bit machines it helps to avoid
102 wrapping, too. */
103 uintptr_t seq;
104
105 /* Destructor for the data. */
106 void (*destr) (void *);
107};
108
109/* Check whether an entry is unused. */
110#define KEY_UNUSED(p) (((p) & 1) == 0)
111/* Check whether a key is usable. We cannot reuse an allocated key if
112 the sequence counter would overflow after the next destroy call.
113 This would mean that we potentially free memory for a key with the
114 same sequence. This is *very* unlikely to happen, A program would
115 have to create and destroy a key 2^31 times (on 32-bit platforms,
116 on 64-bit platforms that would be 2^63). If it should happen we
117 simply don't use this specific key anymore. */
118#define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
119
120
121/* Handling of read-write lock data. */
122// XXX For now there is only one flag. Maybe more in future.
123#define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
124
125
126/* Semaphore variable structure. */
127struct sem
128{
129 unsigned int count;
130};
131
73e9ae88
UD
132
133/* Compatibility type for old conditional variable interfaces. */
134typedef struct
135{
136 pthread_cond_t *cond;
137} pthread_cond_2_0_t;
138
76a50749 139#endif /* internaltypes.h */