1/* Common threading primitives definitions for both POSIX and C11.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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 <https://www.gnu.org/licenses/>. */
18
19#ifndef _THREAD_SHARED_TYPES_H
20#define _THREAD_SHARED_TYPES_H 1
21
22/* Arch-specific definitions. Each architecture must define the following
23 macros to define the expected sizes of pthread data types:
24
25 __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t.
26 __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t.
27 __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t.
28 __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t.
29 __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t.
30 __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t.
31 __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t.
32 __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t.
33 __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t.
34
35 The additional macro defines any constraint for the lock alignment
36 inside the thread structures:
37
38 __LOCK_ALIGNMENT - for internal lock/futex usage.
39
40 Same idea but for the once locking primitive:
41
42 __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. */
43
44#include <bits/pthreadtypes-arch.h>
45
46
47/* Common definition of pthread_mutex_t. */
48
49typedef struct __pthread_internal_list
50{
51 struct __pthread_internal_list *__prev;
52 struct __pthread_internal_list *__next;
53} __pthread_list_t;
54
55typedef struct __pthread_internal_slist
56{
57 struct __pthread_internal_slist *__next;
58} __pthread_slist_t;
59
60/* Arch-specific mutex definitions. A generic implementation is provided
61 by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture
62 can override it by defining:
63
64 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t
65 definition). It should contains at least the internal members
66 defined in the generic version.
67
68 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with
69 atomic operations.
70
71 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization.
72 It should initialize the mutex internal flag. */
73
74#include <bits/struct_mutex.h>
75
76/* Arch-sepecific read-write lock definitions. A generic implementation is
77 provided by struct_rwlock.h. If required, an architecture can override it
78 by defining:
79
80 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition).
81 It should contain at least the internal members defined in the
82 generic version.
83
84 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization.
85 It should initialize the rwlock internal type. */
86
87#include <bits/struct_rwlock.h>
88
89
90/* Common definition of pthread_cond_t. */
91
92struct __pthread_cond_s
93{
94 __extension__ union
95 {
96 __extension__ unsigned long long int __wseq;
97 struct
98 {
99 unsigned int __low;
100 unsigned int __high;
101 } __wseq32;
102 };
103 __extension__ union
104 {
105 __extension__ unsigned long long int __g1_start;
106 struct
107 {
108 unsigned int __low;
109 unsigned int __high;
110 } __g1_start32;
111 };
112 unsigned int __g_refs[2] __LOCK_ALIGNMENT;
113 unsigned int __g_size[2];
114 unsigned int __g1_orig_size;
115 unsigned int __wrefs;
116 unsigned int __g_signals[2];
117};
118
119#endif /* _THREAD_SHARED_TYPES_H */
120