1/* Declaration of common pthread types for all architectures.
2 Copyright (C) 2017-2024 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 _BITS_PTHREADTYPES_COMMON_H
20# define _BITS_PTHREADTYPES_COMMON_H 1
21
22/* For internal mutex and condition variable definitions. */
23#include <bits/thread-shared-types.h>
24
25/* Thread identifiers. The structure of the attribute type is not
26 exposed on purpose. */
27typedef unsigned long int pthread_t;
28
29
30/* Data structures for mutex handling. The structure of the attribute
31 type is not exposed on purpose. */
32typedef union
33{
34 char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
35 int __align;
36} pthread_mutexattr_t;
37
38
39/* Data structure for condition variable handling. The structure of
40 the attribute type is not exposed on purpose. */
41typedef union
42{
43 char __size[__SIZEOF_PTHREAD_CONDATTR_T];
44 int __align;
45} pthread_condattr_t;
46
47
48/* Keys for thread-specific data */
49typedef unsigned int pthread_key_t;
50
51
52/* Once-only execution */
53typedef int __ONCE_ALIGNMENT pthread_once_t;
54
55
56union pthread_attr_t
57{
58 char __size[__SIZEOF_PTHREAD_ATTR_T];
59 long int __align;
60};
61#ifndef __have_pthread_attr_t
62typedef union pthread_attr_t pthread_attr_t;
63# define __have_pthread_attr_t 1
64#endif
65
66
67typedef union
68{
69 struct __pthread_mutex_s __data;
70 char __size[__SIZEOF_PTHREAD_MUTEX_T];
71 long int __align;
72} pthread_mutex_t;
73
74
75typedef union
76{
77 struct __pthread_cond_s __data;
78 char __size[__SIZEOF_PTHREAD_COND_T];
79 __extension__ long long int __align;
80} pthread_cond_t;
81
82
83#if defined __USE_UNIX98 || defined __USE_XOPEN2K
84/* Data structure for reader-writer lock variable handling. The
85 structure of the attribute type is deliberately not exposed. */
86typedef union
87{
88 struct __pthread_rwlock_arch_t __data;
89 char __size[__SIZEOF_PTHREAD_RWLOCK_T];
90 long int __align;
91} pthread_rwlock_t;
92
93typedef union
94{
95 char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
96 long int __align;
97} pthread_rwlockattr_t;
98#endif
99
100
101#ifdef __USE_XOPEN2K
102/* POSIX spinlock data type. */
103typedef volatile int pthread_spinlock_t;
104
105
106/* POSIX barriers data type. The structure of the type is
107 deliberately not exposed. */
108typedef union
109{
110 char __size[__SIZEOF_PTHREAD_BARRIER_T];
111 long int __align;
112} pthread_barrier_t;
113
114typedef union
115{
116 char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
117 int __align;
118} pthread_barrierattr_t;
119#endif
120
121#endif
122