blob: dd428123e33e469484efa19fec2ca59d0222fe31 [file] [log] [blame]
Elliott Hughes13da6002025-02-03 10:42:13 -08001// Copyright (C) 2017 The Android Open Source Project
2// SPDX-License-Identifier: BSD-2-Clause
Elliott Hughes21b56eb2017-10-20 17:57:17 -07003
4#include <pthread.h>
5
6#include "header_checks.h"
7
8static void pthread_h() {
9 MACRO(PTHREAD_BARRIER_SERIAL_THREAD);
10
11#if !defined(__BIONIC__) // No thread cancellation on Android.
12 MACRO(PTHREAD_CANCEL_ASYNCHRONOUS);
13 MACRO(PTHREAD_CANCEL_ENABLE);
14 MACRO(PTHREAD_CANCEL_DEFERRED);
15 MACRO(PTHREAD_CANCEL_DISABLE);
16 MACRO(PTHREAD_CANCELED);
17#endif
18
19 MACRO(PTHREAD_CREATE_DETACHED);
20 MACRO(PTHREAD_CREATE_JOINABLE);
21 MACRO(PTHREAD_EXPLICIT_SCHED);
22 MACRO(PTHREAD_INHERIT_SCHED);
23 MACRO(PTHREAD_MUTEX_DEFAULT);
24 MACRO(PTHREAD_MUTEX_ERRORCHECK);
25 MACRO(PTHREAD_MUTEX_NORMAL);
26 MACRO(PTHREAD_MUTEX_RECURSIVE);
27
28#if !defined(__BIONIC__) // No robust mutexes on Android.
29 MACRO(PTHREAD_MUTEX_ROBUST);
30 MACRO(PTHREAD_MUTEX_STALLED);
31#endif
32
33 MACRO(PTHREAD_ONCE_INIT);
34
Elliott Hughes21b56eb2017-10-20 17:57:17 -070035 MACRO(PTHREAD_PRIO_INHERIT);
36 MACRO(PTHREAD_PRIO_NONE);
Elliott Hughes13550b82018-01-25 22:50:09 -080037#if !defined(__BIONIC__)
Elliott Hughes21b56eb2017-10-20 17:57:17 -070038 MACRO(PTHREAD_PRIO_PROTECT);
39#endif
40
41 MACRO(PTHREAD_PROCESS_SHARED);
42 MACRO(PTHREAD_PROCESS_PRIVATE);
43 MACRO(PTHREAD_SCOPE_PROCESS);
44 MACRO(PTHREAD_SCOPE_SYSTEM);
45
46 pthread_cond_t c0 = PTHREAD_COND_INITIALIZER;
47 pthread_mutex_t m0 = PTHREAD_MUTEX_INITIALIZER;
48 pthread_rwlock_t rw0 = PTHREAD_RWLOCK_INITIALIZER;
49
50 TYPE(pthread_attr_t);
51 TYPE(pthread_barrier_t);
52 TYPE(pthread_barrierattr_t);
53 TYPE(pthread_cond_t);
54 TYPE(pthread_condattr_t);
55 TYPE(pthread_key_t);
56 TYPE(pthread_mutex_t);
57 TYPE(pthread_mutexattr_t);
58 TYPE(pthread_once_t);
59 TYPE(pthread_rwlock_t);
60 TYPE(pthread_rwlockattr_t);
61 TYPE(pthread_spinlock_t);
62 TYPE(pthread_t);
63
64 FUNCTION(pthread_atfork, int (*f)(void (*)(void), void (*)(void), void (*)(void)));
65 FUNCTION(pthread_attr_destroy, int (*f)(pthread_attr_t*));
66 FUNCTION(pthread_attr_getdetachstate, int (*f)(const pthread_attr_t*, int*));
67 FUNCTION(pthread_attr_getguardsize, int (*f)(const pthread_attr_t*, size_t*));
68 FUNCTION(pthread_attr_getinheritsched, int (*f)(const pthread_attr_t*, int*));
69 FUNCTION(pthread_attr_getschedparam, int (*f)(const pthread_attr_t*, struct sched_param*));
70 FUNCTION(pthread_attr_getschedpolicy, int (*f)(const pthread_attr_t*, int*));
71 FUNCTION(pthread_attr_getscope, int (*f)(const pthread_attr_t*, int*));
72 FUNCTION(pthread_attr_getstack, int (*f)(const pthread_attr_t*, void**, size_t*));
73 FUNCTION(pthread_attr_getstacksize, int (*f)(const pthread_attr_t*, size_t*));
74 FUNCTION(pthread_attr_init, int (*f)(pthread_attr_t*));
75 FUNCTION(pthread_attr_setdetachstate, int (*f)(pthread_attr_t*, int));
76 FUNCTION(pthread_attr_setguardsize, int (*f)(pthread_attr_t*, size_t));
77 FUNCTION(pthread_attr_setinheritsched, int (*f)(pthread_attr_t*, int));
78 FUNCTION(pthread_attr_setschedparam, int (*f)(pthread_attr_t*, const struct sched_param*));
79 FUNCTION(pthread_attr_setschedpolicy, int (*f)(pthread_attr_t*, int));
80 FUNCTION(pthread_attr_setscope, int (*f)(pthread_attr_t*, int));
81 FUNCTION(pthread_attr_setstack, int (*f)(pthread_attr_t*, void*, size_t));
82 FUNCTION(pthread_attr_setstacksize, int (*f)(pthread_attr_t*, size_t));
83 FUNCTION(pthread_barrier_destroy, int (*f)(pthread_barrier_t*));
84 FUNCTION(pthread_barrier_init, int (*f)(pthread_barrier_t*, const pthread_barrierattr_t*, unsigned));
85 FUNCTION(pthread_barrier_wait, int (*f)(pthread_barrier_t*));
86 FUNCTION(pthread_barrierattr_destroy, int (*f)(pthread_barrierattr_t*));
87 FUNCTION(pthread_barrierattr_getpshared, int (*f)(const pthread_barrierattr_t*, int*));
88 FUNCTION(pthread_barrierattr_init, int (*f)(pthread_barrierattr_t*));
89 FUNCTION(pthread_barrierattr_setpshared, int (*f)(pthread_barrierattr_t*, int));
90#if !defined(__BIONIC__) // No thread cancellation on Android.
91 FUNCTION(pthread_cancel, int (*f)(pthread_t));
92#endif
93 FUNCTION(pthread_cond_broadcast, int (*f)(pthread_cond_t*));
Elliott Hughesf4d57ac2025-01-28 14:22:12 -080094#if !defined(__GLIBC__) // Our glibc is too old.
95 FUNCTION(pthread_cond_clockwait, int (*f)(pthread_cond_t*, pthread_mutex_t*, clockid_t, const struct timespec*));
96#endif
Elliott Hughes21b56eb2017-10-20 17:57:17 -070097 FUNCTION(pthread_cond_destroy, int (*f)(pthread_cond_t*));
98 FUNCTION(pthread_cond_init, int (*f)(pthread_cond_t*, const pthread_condattr_t*));
99 FUNCTION(pthread_cond_signal, int (*f)(pthread_cond_t*));
100 FUNCTION(pthread_cond_timedwait, int (*f)(pthread_cond_t*, pthread_mutex_t*, const struct timespec*));
101 FUNCTION(pthread_cond_wait, int (*f)(pthread_cond_t*, pthread_mutex_t*));
102 FUNCTION(pthread_condattr_destroy, int (*f)(pthread_condattr_t*));
103 FUNCTION(pthread_condattr_getclock, int (*f)(const pthread_condattr_t*, clockid_t*));
104 FUNCTION(pthread_condattr_getpshared, int (*f)(const pthread_condattr_t*, int*));
105 FUNCTION(pthread_condattr_init, int (*f)(pthread_condattr_t*));
106 FUNCTION(pthread_condattr_setclock, int (*f)(pthread_condattr_t*, clockid_t));
107 FUNCTION(pthread_condattr_setpshared, int (*f)(pthread_condattr_t*, int));
108 FUNCTION(pthread_create, int (*f)(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*));
109 FUNCTION(pthread_detach, int (*f)(pthread_t));
110 FUNCTION(pthread_equal, int (*f)(pthread_t, pthread_t));
111 FUNCTION(pthread_exit, void (*f)(void*));
112#if !defined(__BIONIC__) // Marked obsolescent.
113 FUNCTION(pthread_getconcurrency, int (*f)(void));
114#endif
115 FUNCTION(pthread_getcpuclockid, int (*f)(pthread_t, clockid_t*));
116 FUNCTION(pthread_getschedparam, int (*f)(pthread_t, int*, struct sched_param*));
117 FUNCTION(pthread_getspecific, void* (*f)(pthread_key_t));
118 FUNCTION(pthread_join, int (*f)(pthread_t, void**));
119 FUNCTION(pthread_key_create, int (*f)(pthread_key_t*, void (*)(void*)));
120 FUNCTION(pthread_key_delete, int (*f)(pthread_key_t));
Elliott Hughesf4d57ac2025-01-28 14:22:12 -0800121#if !defined(__GLIBC__) // Our glibc is too old.
122 FUNCTION(pthread_mutex_clocklock, int (*f)(pthread_mutex_t*, clockid_t, const struct timespec*));
123#endif
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700124#if !defined(__BIONIC__) // No robust mutexes on Android.
125 FUNCTION(pthread_mutex_consistent, int (*f)(pthread_mutex_t*));
126#endif
127 FUNCTION(pthread_mutex_destroy, int (*f)(pthread_mutex_t*));
128#if !defined(__BIONIC__) // No robust mutexes on Android.
129 FUNCTION(pthread_mutex_getprioceiling, int (*f)(const pthread_mutex_t*, int*));
130#endif
131 FUNCTION(pthread_mutex_init, int (*f)(pthread_mutex_t*, const pthread_mutexattr_t*));
132 FUNCTION(pthread_mutex_lock, int (*f)(pthread_mutex_t*));
133#if !defined(__BIONIC__) // No robust mutexes on Android.
134 FUNCTION(pthread_mutex_setprioceiling, int (*f)(pthread_mutex_t*, int, int*));
135#endif
136 FUNCTION(pthread_mutex_timedlock, int (*f)(pthread_mutex_t*, const struct timespec*));
137 FUNCTION(pthread_mutex_trylock, int (*f)(pthread_mutex_t*));
138 FUNCTION(pthread_mutex_unlock, int (*f)(pthread_mutex_t*));
139 FUNCTION(pthread_mutexattr_destroy, int (*f)(pthread_mutexattr_t*));
140#if !defined(__BIONIC__) // No robust mutexes on Android.
141 FUNCTION(pthread_mutexattr_getprioceiling, int (*f)(const pthread_mutexattr_t*, int*));
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700142#endif
Elliott Hughes13550b82018-01-25 22:50:09 -0800143 FUNCTION(pthread_mutexattr_getprotocol, int (*f)(const pthread_mutexattr_t*, int*));
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700144 FUNCTION(pthread_mutexattr_getpshared, int (*f)(const pthread_mutexattr_t*, int*));
145#if !defined(__BIONIC__) // No robust mutexes on Android.
146 FUNCTION(pthread_mutexattr_getrobust, int (*f)(const pthread_mutexattr_t*, int*));
147#endif
148 FUNCTION(pthread_mutexattr_gettype, int (*f)(const pthread_mutexattr_t*, int*));
149 FUNCTION(pthread_mutexattr_init, int (*f)(pthread_mutexattr_t*));
150#if !defined(__BIONIC__) // No robust mutexes on Android.
151 FUNCTION(pthread_mutexattr_setprioceiling, int (*f)(pthread_mutexattr_t*, int));
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700152#endif
Elliott Hughes13550b82018-01-25 22:50:09 -0800153 FUNCTION(pthread_mutexattr_setprotocol, int (*f)(pthread_mutexattr_t*, int));
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700154 FUNCTION(pthread_mutexattr_setpshared, int (*f)(pthread_mutexattr_t*, int));
155#if !defined(__BIONIC__) // No robust mutexes on Android.
156 FUNCTION(pthread_mutexattr_setrobust, int (*f)(pthread_mutexattr_t*, int));
157#endif
158 FUNCTION(pthread_mutexattr_settype, int (*f)(pthread_mutexattr_t*, int));
159 FUNCTION(pthread_once, int (*f)(pthread_once_t*, void (*)(void)));
Elliott Hughesf4d57ac2025-01-28 14:22:12 -0800160#if !defined(__GLIBC__) // Our glibc is too old.
161 FUNCTION(pthread_rwlock_clockrdlock, int (*f)(pthread_rwlock_t*, clockid_t, const struct timespec*));
162 FUNCTION(pthread_rwlock_clockwrlock, int (*f)(pthread_rwlock_t*, clockid_t, const struct timespec*));
163#endif
Elliott Hughes21b56eb2017-10-20 17:57:17 -0700164 FUNCTION(pthread_rwlock_destroy, int (*f)(pthread_rwlock_t*));
165 FUNCTION(pthread_rwlock_init, int (*f)(pthread_rwlock_t*, const pthread_rwlockattr_t*));
166 FUNCTION(pthread_rwlock_rdlock, int (*f)(pthread_rwlock_t*));
167 FUNCTION(pthread_rwlock_timedrdlock, int (*f)(pthread_rwlock_t*, const struct timespec*));
168 FUNCTION(pthread_rwlock_timedwrlock, int (*f)(pthread_rwlock_t*, const struct timespec*));
169 FUNCTION(pthread_rwlock_tryrdlock, int (*f)(pthread_rwlock_t*));
170 FUNCTION(pthread_rwlock_trywrlock, int (*f)(pthread_rwlock_t*));
171 FUNCTION(pthread_rwlock_unlock, int (*f)(pthread_rwlock_t*));
172 FUNCTION(pthread_rwlock_wrlock, int (*f)(pthread_rwlock_t*));
173 FUNCTION(pthread_rwlockattr_destroy, int (*f)(pthread_rwlockattr_t*));
174 FUNCTION(pthread_rwlockattr_getpshared, int (*f)(const pthread_rwlockattr_t*, int*));
175 FUNCTION(pthread_rwlockattr_init, int (*f)(pthread_rwlockattr_t*));
176 FUNCTION(pthread_rwlockattr_setpshared, int (*f)(pthread_rwlockattr_t*, int));
177 FUNCTION(pthread_self, pthread_t (*f)(void));
178#if !defined(__BIONIC__) // No thread cancellation on Android.
179 FUNCTION(pthread_setcancelstate, int (*f)(int, int*));
180 FUNCTION(pthread_setcanceltype, int (*f)(int, int*));
181#endif
182#if !defined(__BIONIC__) // Marked obsolescent.
183 FUNCTION(pthread_setconcurrency, int (*f)(int));
184#endif
185 FUNCTION(pthread_setschedparam, int (*f)(pthread_t, int, const struct sched_param*));
186 FUNCTION(pthread_setschedprio, int (*f)(pthread_t, int));
187 FUNCTION(pthread_setspecific, int (*f)(pthread_key_t, const void*));
188 FUNCTION(pthread_spin_destroy, int (*f)(pthread_spinlock_t*));
189 FUNCTION(pthread_spin_init, int (*f)(pthread_spinlock_t*, int));
190 FUNCTION(pthread_spin_lock, int (*f)(pthread_spinlock_t*));
191 FUNCTION(pthread_spin_trylock, int (*f)(pthread_spinlock_t*));
192 FUNCTION(pthread_spin_unlock, int (*f)(pthread_spinlock_t*));
193#if !defined(__BIONIC__) // No thread cancellation on Android.
194 FUNCTION(pthread_testcancel, void (*f)(void));
195#endif
196
197#if !defined(pthread_cleanup_pop)
198#error pthread_cleanup_pop
199#endif
200#if !defined(pthread_cleanup_push)
201#error pthread_cleanup_push
202#endif
203}
204
205// POSIX: "Inclusion of the <pthread.h> header shall make symbols defined in the
206// headers <sched.h> and <time.h> visible."
207
208#define DO_NOT_INCLUDE_SCHED_H
209#include "sched_h.c"
210#define DO_NOT_INCLUDE_TIME_H
211#include "time_h.c"