xref: /aosp_15_r20/bionic/libc/include/pthread.h (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2008 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker  * All rights reserved.
4*8d67ca89SAndroid Build Coastguard Worker  *
5*8d67ca89SAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
6*8d67ca89SAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
7*8d67ca89SAndroid Build Coastguard Worker  * are met:
8*8d67ca89SAndroid Build Coastguard Worker  *  * Redistributions of source code must retain the above copyright
9*8d67ca89SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
10*8d67ca89SAndroid Build Coastguard Worker  *  * Redistributions in binary form must reproduce the above copyright
11*8d67ca89SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in
12*8d67ca89SAndroid Build Coastguard Worker  *    the documentation and/or other materials provided with the
13*8d67ca89SAndroid Build Coastguard Worker  *    distribution.
14*8d67ca89SAndroid Build Coastguard Worker  *
15*8d67ca89SAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16*8d67ca89SAndroid Build Coastguard Worker  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17*8d67ca89SAndroid Build Coastguard Worker  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18*8d67ca89SAndroid Build Coastguard Worker  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19*8d67ca89SAndroid Build Coastguard Worker  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20*8d67ca89SAndroid Build Coastguard Worker  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21*8d67ca89SAndroid Build Coastguard Worker  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22*8d67ca89SAndroid Build Coastguard Worker  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23*8d67ca89SAndroid Build Coastguard Worker  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24*8d67ca89SAndroid Build Coastguard Worker  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25*8d67ca89SAndroid Build Coastguard Worker  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*8d67ca89SAndroid Build Coastguard Worker  * SUCH DAMAGE.
27*8d67ca89SAndroid Build Coastguard Worker  */
28*8d67ca89SAndroid Build Coastguard Worker 
29*8d67ca89SAndroid Build Coastguard Worker #pragma once
30*8d67ca89SAndroid Build Coastguard Worker 
31*8d67ca89SAndroid Build Coastguard Worker /**
32*8d67ca89SAndroid Build Coastguard Worker  * @file pthread.h
33*8d67ca89SAndroid Build Coastguard Worker  * @brief POSIX threads.
34*8d67ca89SAndroid Build Coastguard Worker  */
35*8d67ca89SAndroid Build Coastguard Worker 
36*8d67ca89SAndroid Build Coastguard Worker #include <sys/cdefs.h>
37*8d67ca89SAndroid Build Coastguard Worker 
38*8d67ca89SAndroid Build Coastguard Worker #include <limits.h>
39*8d67ca89SAndroid Build Coastguard Worker #include <bits/page_size.h>
40*8d67ca89SAndroid Build Coastguard Worker #include <bits/pthread_types.h>
41*8d67ca89SAndroid Build Coastguard Worker #include <sched.h>
42*8d67ca89SAndroid Build Coastguard Worker #include <sys/types.h>
43*8d67ca89SAndroid Build Coastguard Worker #include <time.h>
44*8d67ca89SAndroid Build Coastguard Worker 
45*8d67ca89SAndroid Build Coastguard Worker __BEGIN_DECLS
46*8d67ca89SAndroid Build Coastguard Worker 
47*8d67ca89SAndroid Build Coastguard Worker enum {
48*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_MUTEX_NORMAL = 0,
49*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_MUTEX_RECURSIVE = 1,
50*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_MUTEX_ERRORCHECK = 2,
51*8d67ca89SAndroid Build Coastguard Worker 
52*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_MUTEX_ERRORCHECK_NP = PTHREAD_MUTEX_ERRORCHECK,
53*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_MUTEX_RECURSIVE_NP  = PTHREAD_MUTEX_RECURSIVE,
54*8d67ca89SAndroid Build Coastguard Worker 
55*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
56*8d67ca89SAndroid Build Coastguard Worker };
57*8d67ca89SAndroid Build Coastguard Worker 
58*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_MUTEX_INITIALIZER { { ((PTHREAD_MUTEX_NORMAL & 3) << 14) } }
59*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { { ((PTHREAD_MUTEX_RECURSIVE & 3) << 14) } }
60*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP { { ((PTHREAD_MUTEX_ERRORCHECK & 3) << 14) } }
61*8d67ca89SAndroid Build Coastguard Worker 
62*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_COND_INITIALIZER  { { 0 } }
63*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_COND_INITIALIZER_MONOTONIC_NP  { { 1 << 1 } }
64*8d67ca89SAndroid Build Coastguard Worker 
65*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_RWLOCK_INITIALIZER  { { 0 } }
66*8d67ca89SAndroid Build Coastguard Worker 
67*8d67ca89SAndroid Build Coastguard Worker enum {
68*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_RWLOCK_PREFER_READER_NP = 0,
69*8d67ca89SAndroid Build Coastguard Worker   PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP = 1,
70*8d67ca89SAndroid Build Coastguard Worker };
71*8d67ca89SAndroid Build Coastguard Worker 
72*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_ONCE_INIT 0
73*8d67ca89SAndroid Build Coastguard Worker 
74*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_BARRIER_SERIAL_THREAD (-1)
75*8d67ca89SAndroid Build Coastguard Worker 
76*8d67ca89SAndroid Build Coastguard Worker #if defined(__LP64__)
77*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_STACK_MIN 16384
78*8d67ca89SAndroid Build Coastguard Worker #else
79*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_STACK_MIN 8192
80*8d67ca89SAndroid Build Coastguard Worker #endif
81*8d67ca89SAndroid Build Coastguard Worker 
82*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_CREATE_DETACHED 1
83*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_CREATE_JOINABLE 0
84*8d67ca89SAndroid Build Coastguard Worker 
85*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_EXPLICIT_SCHED 0
86*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_INHERIT_SCHED 1
87*8d67ca89SAndroid Build Coastguard Worker 
88*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_PRIO_NONE 0
89*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_PRIO_INHERIT 1
90*8d67ca89SAndroid Build Coastguard Worker 
91*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_PROCESS_PRIVATE 0
92*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_PROCESS_SHARED 1
93*8d67ca89SAndroid Build Coastguard Worker 
94*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_SCOPE_SYSTEM 0
95*8d67ca89SAndroid Build Coastguard Worker #define PTHREAD_SCOPE_PROCESS 1
96*8d67ca89SAndroid Build Coastguard Worker 
97*8d67ca89SAndroid Build Coastguard Worker int pthread_atfork(void (* _Nullable __prepare)(void), void (* _Nullable __parent)(void), void (* _Nullable __child)(void));
98*8d67ca89SAndroid Build Coastguard Worker 
99*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_destroy(pthread_attr_t* _Nonnull __attr);
100*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getdetachstate(const pthread_attr_t* _Nonnull __attr, int* _Nonnull __state);
101*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getguardsize(const pthread_attr_t* _Nonnull __attr, size_t* _Nonnull __size);
102*8d67ca89SAndroid Build Coastguard Worker 
103*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
104*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getinheritsched(const pthread_attr_t* _Nonnull __attr, int* _Nonnull __flag) __INTRODUCED_IN(28);
105*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
106*8d67ca89SAndroid Build Coastguard Worker 
107*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getschedparam(const pthread_attr_t* _Nonnull __attr, struct sched_param* _Nonnull __param);
108*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getschedpolicy(const pthread_attr_t* _Nonnull __attr, int* _Nonnull __policy);
109*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getscope(const pthread_attr_t* _Nonnull __attr, int* _Nonnull __scope);
110*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getstack(const pthread_attr_t* _Nonnull __attr, void* _Nullable * _Nonnull __addr, size_t* _Nonnull __size);
111*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_getstacksize(const pthread_attr_t* _Nonnull __attr, size_t* _Nonnull __size);
112*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_init(pthread_attr_t* _Nonnull __attr);
113*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setdetachstate(pthread_attr_t* _Nonnull __attr, int __state);
114*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setguardsize(pthread_attr_t* _Nonnull __attr, size_t __size);
115*8d67ca89SAndroid Build Coastguard Worker 
116*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
117*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setinheritsched(pthread_attr_t* _Nonnull __attr, int __flag) __INTRODUCED_IN(28);
118*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
119*8d67ca89SAndroid Build Coastguard Worker 
120*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setschedparam(pthread_attr_t* _Nonnull __attr, const struct sched_param* _Nonnull __param);
121*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setschedpolicy(pthread_attr_t* _Nonnull __attr, int __policy);
122*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setscope(pthread_attr_t* _Nonnull __attr, int __scope);
123*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setstack(pthread_attr_t* _Nonnull __attr, void* _Nonnull __addr, size_t __size);
124*8d67ca89SAndroid Build Coastguard Worker int pthread_attr_setstacksize(pthread_attr_t* _Nonnull __addr, size_t __size);
125*8d67ca89SAndroid Build Coastguard Worker 
126*8d67ca89SAndroid Build Coastguard Worker int pthread_condattr_destroy(pthread_condattr_t* _Nonnull __attr);
127*8d67ca89SAndroid Build Coastguard Worker int pthread_condattr_getclock(const pthread_condattr_t* _Nonnull __attr, clockid_t* _Nonnull __clock);
128*8d67ca89SAndroid Build Coastguard Worker int pthread_condattr_getpshared(const pthread_condattr_t* _Nonnull __attr, int* _Nonnull __shared);
129*8d67ca89SAndroid Build Coastguard Worker int pthread_condattr_init(pthread_condattr_t* _Nonnull __attr);
130*8d67ca89SAndroid Build Coastguard Worker int pthread_condattr_setclock(pthread_condattr_t* _Nonnull __attr, clockid_t __clock);
131*8d67ca89SAndroid Build Coastguard Worker int pthread_condattr_setpshared(pthread_condattr_t* _Nonnull __attr, int __shared);
132*8d67ca89SAndroid Build Coastguard Worker 
133*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_broadcast(pthread_cond_t* _Nonnull __cond);
134*8d67ca89SAndroid Build Coastguard Worker 
135*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(30)
136*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_clockwait(pthread_cond_t* _Nonnull __cond, pthread_mutex_t* _Nonnull __mutex, clockid_t __clock,
137*8d67ca89SAndroid Build Coastguard Worker                            const struct timespec* _Nullable __timeout) __INTRODUCED_IN(30);
138*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(30) */
139*8d67ca89SAndroid Build Coastguard Worker 
140*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_destroy(pthread_cond_t* _Nonnull __cond);
141*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_init(pthread_cond_t* _Nonnull __cond, const pthread_condattr_t* _Nullable __attr);
142*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_signal(pthread_cond_t* _Nonnull __cond);
143*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_timedwait(pthread_cond_t* _Nonnull __cond, pthread_mutex_t* _Nonnull __mutex, const struct timespec* _Nullable __timeout);
144*8d67ca89SAndroid Build Coastguard Worker /*
145*8d67ca89SAndroid Build Coastguard Worker  * Condition variables use CLOCK_REALTIME by default for their timeouts, however that is
146*8d67ca89SAndroid Build Coastguard Worker  * typically inappropriate, since that clock can change dramatically, causing the timeout to
147*8d67ca89SAndroid Build Coastguard Worker  * either expire earlier or much later than intended.
148*8d67ca89SAndroid Build Coastguard Worker  * Condition variables have an initialization option to use CLOCK_MONOTONIC, and in addition,
149*8d67ca89SAndroid Build Coastguard Worker  * Android provides pthread_cond_timedwait_monotonic_np to use CLOCK_MONOTONIC on a condition
150*8d67ca89SAndroid Build Coastguard Worker  * variable for this single wait no matter how it was initialized.
151*8d67ca89SAndroid Build Coastguard Worker  * Note that pthread_cond_clockwait() allows specifying an arbitrary clock and has superseded this
152*8d67ca89SAndroid Build Coastguard Worker  * function.
153*8d67ca89SAndroid Build Coastguard Worker  */
154*8d67ca89SAndroid Build Coastguard Worker 
155*8d67ca89SAndroid Build Coastguard Worker #if (!defined(__LP64__)) || (defined(__LP64__) && __ANDROID_API__ >= 28)
156*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_timedwait_monotonic_np(pthread_cond_t* _Nonnull __cond, pthread_mutex_t* _Nonnull __mutex,
157*8d67ca89SAndroid Build Coastguard Worker                                         const struct timespec* _Nullable __timeout) __INTRODUCED_IN_64(28);
158*8d67ca89SAndroid Build Coastguard Worker #endif /* (!defined(__LP64__)) || (defined(__LP64__) && __ANDROID_API__ >= 28) */
159*8d67ca89SAndroid Build Coastguard Worker 
160*8d67ca89SAndroid Build Coastguard Worker int pthread_cond_wait(pthread_cond_t* _Nonnull __cond, pthread_mutex_t* _Nonnull __mutex);
161*8d67ca89SAndroid Build Coastguard Worker 
162*8d67ca89SAndroid Build Coastguard Worker int pthread_create(pthread_t* _Nonnull __pthread_ptr, pthread_attr_t const* _Nullable __attr, void* _Nullable (* _Nonnull __start_routine)(void* _Nullable), void* _Nullable);
163*8d67ca89SAndroid Build Coastguard Worker 
164*8d67ca89SAndroid Build Coastguard Worker int pthread_detach(pthread_t __pthread);
165*8d67ca89SAndroid Build Coastguard Worker void pthread_exit(void* _Nullable __return_value) __noreturn;
166*8d67ca89SAndroid Build Coastguard Worker 
167*8d67ca89SAndroid Build Coastguard Worker int pthread_equal(pthread_t __lhs, pthread_t __rhs);
168*8d67ca89SAndroid Build Coastguard Worker 
169*8d67ca89SAndroid Build Coastguard Worker int pthread_getattr_np(pthread_t __pthread, pthread_attr_t* _Nonnull __attr);
170*8d67ca89SAndroid Build Coastguard Worker 
171*8d67ca89SAndroid Build Coastguard Worker int pthread_getcpuclockid(pthread_t __pthread, clockid_t* _Nonnull __clock);
172*8d67ca89SAndroid Build Coastguard Worker 
173*8d67ca89SAndroid Build Coastguard Worker void* _Nullable pthread_getspecific(pthread_key_t __key);
174*8d67ca89SAndroid Build Coastguard Worker 
175*8d67ca89SAndroid Build Coastguard Worker pid_t pthread_gettid_np(pthread_t __pthread);
176*8d67ca89SAndroid Build Coastguard Worker 
177*8d67ca89SAndroid Build Coastguard Worker int pthread_join(pthread_t __pthread, void* _Nullable * _Nullable __return_value_ptr);
178*8d67ca89SAndroid Build Coastguard Worker 
179*8d67ca89SAndroid Build Coastguard Worker /**
180*8d67ca89SAndroid Build Coastguard Worker  * [pthread_key_create(3)](https://man7.org/linux/man-pages/man3/pthread_key_create.3p.html)
181*8d67ca89SAndroid Build Coastguard Worker  * creates a key for thread-specific data.
182*8d67ca89SAndroid Build Coastguard Worker  *
183*8d67ca89SAndroid Build Coastguard Worker  * There is a limit of `PTHREAD_KEYS_MAX` keys per process, but most callers
184*8d67ca89SAndroid Build Coastguard Worker  * should just use the C or C++ `thread_local` storage specifier anyway. When
185*8d67ca89SAndroid Build Coastguard Worker  * targeting new enough OS versions, the compiler will automatically use
186*8d67ca89SAndroid Build Coastguard Worker  * ELF TLS; when targeting old OS versions the emutls implementation will
187*8d67ca89SAndroid Build Coastguard Worker  * multiplex pthread keys behind the scenes, using one per library rather than
188*8d67ca89SAndroid Build Coastguard Worker  * one per thread-local variable. If you are implementing the runtime for a
189*8d67ca89SAndroid Build Coastguard Worker  * different language, you should consider similar implementation choices and
190*8d67ca89SAndroid Build Coastguard Worker  * avoid a direct one-to-one mapping from thread locals to pthread keys.
191*8d67ca89SAndroid Build Coastguard Worker  *
192*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
193*8d67ca89SAndroid Build Coastguard Worker  */
194*8d67ca89SAndroid Build Coastguard Worker int pthread_key_create(pthread_key_t* _Nonnull __key_ptr, void (* _Nullable __key_destructor)(void* _Nullable));
195*8d67ca89SAndroid Build Coastguard Worker 
196*8d67ca89SAndroid Build Coastguard Worker /**
197*8d67ca89SAndroid Build Coastguard Worker  * [pthread_key_delete(3)](https://man7.org/linux/man-pages/man3/pthread_key_delete.3p.html)
198*8d67ca89SAndroid Build Coastguard Worker  * deletes a key for thread-specific data.
199*8d67ca89SAndroid Build Coastguard Worker  *
200*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
201*8d67ca89SAndroid Build Coastguard Worker  */
202*8d67ca89SAndroid Build Coastguard Worker int pthread_key_delete(pthread_key_t __key);
203*8d67ca89SAndroid Build Coastguard Worker 
204*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_destroy(pthread_mutexattr_t* _Nonnull __attr);
205*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_getpshared(const pthread_mutexattr_t* _Nonnull __attr, int* _Nonnull __shared);
206*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_gettype(const pthread_mutexattr_t* _Nonnull __attr, int* _Nonnull __type);
207*8d67ca89SAndroid Build Coastguard Worker 
208*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
209*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_getprotocol(const pthread_mutexattr_t* _Nonnull __attr, int* _Nonnull __protocol) __INTRODUCED_IN(28);
210*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
211*8d67ca89SAndroid Build Coastguard Worker 
212*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_init(pthread_mutexattr_t* _Nonnull __attr);
213*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_setpshared(pthread_mutexattr_t* _Nonnull __attr, int __shared);
214*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_settype(pthread_mutexattr_t* _Nonnull __attr, int __type);
215*8d67ca89SAndroid Build Coastguard Worker 
216*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
217*8d67ca89SAndroid Build Coastguard Worker int pthread_mutexattr_setprotocol(pthread_mutexattr_t* _Nonnull __attr, int __protocol) __INTRODUCED_IN(28);
218*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
219*8d67ca89SAndroid Build Coastguard Worker 
220*8d67ca89SAndroid Build Coastguard Worker 
221*8d67ca89SAndroid Build Coastguard Worker 
222*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(30)
223*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_clocklock(pthread_mutex_t* _Nonnull __mutex, clockid_t __clock,
224*8d67ca89SAndroid Build Coastguard Worker                             const struct timespec* _Nullable __abstime) __INTRODUCED_IN(30);
225*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(30) */
226*8d67ca89SAndroid Build Coastguard Worker 
227*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_destroy(pthread_mutex_t* _Nonnull __mutex);
228*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_init(pthread_mutex_t* _Nonnull __mutex, const pthread_mutexattr_t* _Nullable __attr);
229*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_lock(pthread_mutex_t* _Nonnull __mutex);
230*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_timedlock(pthread_mutex_t* _Nonnull __mutex, const struct timespec* _Nullable __timeout);
231*8d67ca89SAndroid Build Coastguard Worker 
232*8d67ca89SAndroid Build Coastguard Worker /*
233*8d67ca89SAndroid Build Coastguard Worker  * POSIX historically only supported using pthread_mutex_timedlock() with CLOCK_REALTIME, however
234*8d67ca89SAndroid Build Coastguard Worker  * that is typically inappropriate, since that clock can change dramatically, causing the timeout to
235*8d67ca89SAndroid Build Coastguard Worker  * either expire earlier or much later than intended.
236*8d67ca89SAndroid Build Coastguard Worker  * This function is added to use a timespec based on CLOCK_MONOTONIC that does not suffer
237*8d67ca89SAndroid Build Coastguard Worker  * from this issue.
238*8d67ca89SAndroid Build Coastguard Worker  * Note that pthread_mutex_clocklock() allows specifying an arbitrary clock and has superseded this
239*8d67ca89SAndroid Build Coastguard Worker  * function.
240*8d67ca89SAndroid Build Coastguard Worker  */
241*8d67ca89SAndroid Build Coastguard Worker 
242*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
243*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_timedlock_monotonic_np(pthread_mutex_t* _Nonnull __mutex, const struct timespec* _Nullable __timeout)
244*8d67ca89SAndroid Build Coastguard Worker     __INTRODUCED_IN(28);
245*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
246*8d67ca89SAndroid Build Coastguard Worker 
247*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_trylock(pthread_mutex_t* _Nonnull __mutex);
248*8d67ca89SAndroid Build Coastguard Worker int pthread_mutex_unlock(pthread_mutex_t* _Nonnull __mutex);
249*8d67ca89SAndroid Build Coastguard Worker 
250*8d67ca89SAndroid Build Coastguard Worker int pthread_once(pthread_once_t* _Nonnull __once, void (* _Nonnull __init_routine)(void));
251*8d67ca89SAndroid Build Coastguard Worker 
252*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlockattr_init(pthread_rwlockattr_t* _Nonnull __attr);
253*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlockattr_destroy(pthread_rwlockattr_t* _Nonnull __attr);
254*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* _Nonnull __attr, int* _Nonnull __shared);
255*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlockattr_setpshared(pthread_rwlockattr_t* _Nonnull __attr, int __shared);
256*8d67ca89SAndroid Build Coastguard Worker 
257*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(23)
258*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t* _Nonnull __attr, int* _Nonnull __kind)
259*8d67ca89SAndroid Build Coastguard Worker   __INTRODUCED_IN(23);
260*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t* _Nonnull __attr, int __kind) __INTRODUCED_IN(23);
261*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(23) */
262*8d67ca89SAndroid Build Coastguard Worker 
263*8d67ca89SAndroid Build Coastguard Worker 
264*8d67ca89SAndroid Build Coastguard Worker 
265*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(30)
266*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_clockrdlock(pthread_rwlock_t* _Nonnull __rwlock, clockid_t __clock,
267*8d67ca89SAndroid Build Coastguard Worker                                const struct timespec* _Nullable __timeout) __INTRODUCED_IN(30);
268*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_clockwrlock(pthread_rwlock_t* _Nonnull __rwlock, clockid_t __clock,
269*8d67ca89SAndroid Build Coastguard Worker                                const struct timespec* _Nullable __timeout) __INTRODUCED_IN(30);
270*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(30) */
271*8d67ca89SAndroid Build Coastguard Worker 
272*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_destroy(pthread_rwlock_t* _Nonnull __rwlock);
273*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_init(pthread_rwlock_t* _Nonnull __rwlock, const pthread_rwlockattr_t* _Nullable __attr);
274*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_rdlock(pthread_rwlock_t* _Nonnull __rwlock);
275*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_timedrdlock(pthread_rwlock_t* _Nonnull __rwlock, const struct timespec* _Nullable __timeout);
276*8d67ca89SAndroid Build Coastguard Worker /* See the comment on pthread_mutex_timedlock_monotonic_np for usage of this function. */
277*8d67ca89SAndroid Build Coastguard Worker 
278*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
279*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_timedrdlock_monotonic_np(pthread_rwlock_t* _Nonnull __rwlock,
280*8d67ca89SAndroid Build Coastguard Worker                                             const struct timespec* _Nullable __timeout) __INTRODUCED_IN(28);
281*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
282*8d67ca89SAndroid Build Coastguard Worker 
283*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_timedwrlock(pthread_rwlock_t* _Nonnull __rwlock, const struct timespec* _Nullable __timeout);
284*8d67ca89SAndroid Build Coastguard Worker /* See the comment on pthread_mutex_timedlock_monotonic_np for usage of this function. */
285*8d67ca89SAndroid Build Coastguard Worker 
286*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
287*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_timedwrlock_monotonic_np(pthread_rwlock_t* _Nonnull __rwlock,
288*8d67ca89SAndroid Build Coastguard Worker                                             const struct timespec* _Nullable __timeout) __INTRODUCED_IN(28);
289*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
290*8d67ca89SAndroid Build Coastguard Worker 
291*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_tryrdlock(pthread_rwlock_t* _Nonnull __rwlock);
292*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_trywrlock(pthread_rwlock_t* _Nonnull __rwlock);
293*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_unlock(pthread_rwlock_t* _Nonnull __rwlock);
294*8d67ca89SAndroid Build Coastguard Worker int pthread_rwlock_wrlock(pthread_rwlock_t* _Nonnull __rwlock);
295*8d67ca89SAndroid Build Coastguard Worker 
296*8d67ca89SAndroid Build Coastguard Worker 
297*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(24)
298*8d67ca89SAndroid Build Coastguard Worker int pthread_barrierattr_init(pthread_barrierattr_t* _Nonnull __attr) __INTRODUCED_IN(24);
299*8d67ca89SAndroid Build Coastguard Worker int pthread_barrierattr_destroy(pthread_barrierattr_t* _Nonnull __attr) __INTRODUCED_IN(24);
300*8d67ca89SAndroid Build Coastguard Worker int pthread_barrierattr_getpshared(const pthread_barrierattr_t* _Nonnull __attr, int* _Nonnull __shared) __INTRODUCED_IN(24);
301*8d67ca89SAndroid Build Coastguard Worker int pthread_barrierattr_setpshared(pthread_barrierattr_t* _Nonnull __attr, int __shared) __INTRODUCED_IN(24);
302*8d67ca89SAndroid Build Coastguard Worker 
303*8d67ca89SAndroid Build Coastguard Worker int pthread_barrier_init(pthread_barrier_t* _Nonnull __barrier, const pthread_barrierattr_t* _Nullable __attr, unsigned __count) __INTRODUCED_IN(24);
304*8d67ca89SAndroid Build Coastguard Worker int pthread_barrier_destroy(pthread_barrier_t* _Nonnull __barrier) __INTRODUCED_IN(24);
305*8d67ca89SAndroid Build Coastguard Worker int pthread_barrier_wait(pthread_barrier_t* _Nonnull __barrier) __INTRODUCED_IN(24);
306*8d67ca89SAndroid Build Coastguard Worker 
307*8d67ca89SAndroid Build Coastguard Worker int pthread_spin_destroy(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
308*8d67ca89SAndroid Build Coastguard Worker int pthread_spin_init(pthread_spinlock_t* _Nonnull __spinlock, int __shared) __INTRODUCED_IN(24);
309*8d67ca89SAndroid Build Coastguard Worker int pthread_spin_lock(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
310*8d67ca89SAndroid Build Coastguard Worker int pthread_spin_trylock(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
311*8d67ca89SAndroid Build Coastguard Worker int pthread_spin_unlock(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
312*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(24) */
313*8d67ca89SAndroid Build Coastguard Worker 
314*8d67ca89SAndroid Build Coastguard Worker 
315*8d67ca89SAndroid Build Coastguard Worker pthread_t pthread_self(void) __attribute_const__;
316*8d67ca89SAndroid Build Coastguard Worker 
317*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_GNU) && __BIONIC_AVAILABILITY_GUARD(26)
318*8d67ca89SAndroid Build Coastguard Worker /**
319*8d67ca89SAndroid Build Coastguard Worker  * [pthread_getname_np(3)](https://man7.org/linux/man-pages/man3/pthread_getname_np.3.html)
320*8d67ca89SAndroid Build Coastguard Worker  * gets the name of the given thread.
321*8d67ca89SAndroid Build Coastguard Worker  * Names are at most 16 bytes (including '\0').
322*8d67ca89SAndroid Build Coastguard Worker  *
323*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
324*8d67ca89SAndroid Build Coastguard Worker  *
325*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 26.
326*8d67ca89SAndroid Build Coastguard Worker  */
327*8d67ca89SAndroid Build Coastguard Worker int pthread_getname_np(pthread_t __pthread, char* _Nonnull __buf, size_t __n) __INTRODUCED_IN(26);
328*8d67ca89SAndroid Build Coastguard Worker #endif
329*8d67ca89SAndroid Build Coastguard Worker 
330*8d67ca89SAndroid Build Coastguard Worker /**
331*8d67ca89SAndroid Build Coastguard Worker  * [pthread_setname_np(3)](https://man7.org/linux/man-pages/man3/pthread_setname_np.3.html)
332*8d67ca89SAndroid Build Coastguard Worker  * sets the name of the given thread.
333*8d67ca89SAndroid Build Coastguard Worker  * Names are at most 16 bytes (including '\0').
334*8d67ca89SAndroid Build Coastguard Worker  * Truncation must be done by the caller;
335*8d67ca89SAndroid Build Coastguard Worker  * calls with longer names will fail with ERANGE.
336*8d67ca89SAndroid Build Coastguard Worker  *
337*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
338*8d67ca89SAndroid Build Coastguard Worker  *
339*8d67ca89SAndroid Build Coastguard Worker  * This should only have been available under _GNU_SOURCE,
340*8d67ca89SAndroid Build Coastguard Worker  * but is always available on Android by historical accident.
341*8d67ca89SAndroid Build Coastguard Worker  */
342*8d67ca89SAndroid Build Coastguard Worker int pthread_setname_np(pthread_t __pthread, const char* _Nonnull __name);
343*8d67ca89SAndroid Build Coastguard Worker 
344*8d67ca89SAndroid Build Coastguard Worker /**
345*8d67ca89SAndroid Build Coastguard Worker  * [pthread_getaffinity_np(3)](https://man7.org/linux/man-pages/man3/pthread_getaffinity_np.3.html)
346*8d67ca89SAndroid Build Coastguard Worker  * gets the CPU affinity mask for the given thread.
347*8d67ca89SAndroid Build Coastguard Worker  *
348*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
349*8d67ca89SAndroid Build Coastguard Worker  *
350*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 36.
351*8d67ca89SAndroid Build Coastguard Worker  * See sched_getaffinity() and pthread_gettid_np() for greater portability.
352*8d67ca89SAndroid Build Coastguard Worker  */
353*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_GNU) && __BIONIC_AVAILABILITY_GUARD(36)
354*8d67ca89SAndroid Build Coastguard Worker int pthread_getaffinity_np(pthread_t __pthread, size_t __cpu_set_size, cpu_set_t* __cpu_set) __INTRODUCED_IN(36);
355*8d67ca89SAndroid Build Coastguard Worker #endif
356*8d67ca89SAndroid Build Coastguard Worker 
357*8d67ca89SAndroid Build Coastguard Worker /**
358*8d67ca89SAndroid Build Coastguard Worker  * [pthread_setaffinity_np(3)](https://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html)
359*8d67ca89SAndroid Build Coastguard Worker  * sets the CPU affinity mask for the given thread.
360*8d67ca89SAndroid Build Coastguard Worker  *
361*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
362*8d67ca89SAndroid Build Coastguard Worker  *
363*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 36.
364*8d67ca89SAndroid Build Coastguard Worker  * See sched_getaffinity() and pthread_gettid_np() for greater portability.
365*8d67ca89SAndroid Build Coastguard Worker  */
366*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_GNU) && __BIONIC_AVAILABILITY_GUARD(36)
367*8d67ca89SAndroid Build Coastguard Worker int pthread_setaffinity_np(pthread_t __pthread, size_t __cpu_set_size, const cpu_set_t* __cpu_set) __INTRODUCED_IN(36);
368*8d67ca89SAndroid Build Coastguard Worker #endif
369*8d67ca89SAndroid Build Coastguard Worker 
370*8d67ca89SAndroid Build Coastguard Worker /**
371*8d67ca89SAndroid Build Coastguard Worker  * [pthread_setschedparam(3)](https://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html)
372*8d67ca89SAndroid Build Coastguard Worker  * sets the scheduler policy and parameters of the given thread.
373*8d67ca89SAndroid Build Coastguard Worker  *
374*8d67ca89SAndroid Build Coastguard Worker  * This call is not useful to applications on Android, because they don't
375*8d67ca89SAndroid Build Coastguard Worker  * have permission to set their scheduling policy, and the only priority
376*8d67ca89SAndroid Build Coastguard Worker  * for their policy is 0 anyway. If you only need to set your scheduling
377*8d67ca89SAndroid Build Coastguard Worker  * priority, see setpriority() instead.
378*8d67ca89SAndroid Build Coastguard Worker  *
379*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
380*8d67ca89SAndroid Build Coastguard Worker  */
381*8d67ca89SAndroid Build Coastguard Worker int pthread_setschedparam(pthread_t __pthread, int __policy, const struct sched_param* _Nonnull __param);
382*8d67ca89SAndroid Build Coastguard Worker 
383*8d67ca89SAndroid Build Coastguard Worker /**
384*8d67ca89SAndroid Build Coastguard Worker  * [pthread_getschedparam(3)](https://man7.org/linux/man-pages/man3/pthread_getschedparam.3.html)
385*8d67ca89SAndroid Build Coastguard Worker  * gets the scheduler policy and parameters of the given thread.
386*8d67ca89SAndroid Build Coastguard Worker  *
387*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
388*8d67ca89SAndroid Build Coastguard Worker  */
389*8d67ca89SAndroid Build Coastguard Worker int pthread_getschedparam(pthread_t __pthread, int* _Nonnull __policy, struct sched_param* _Nonnull __param);
390*8d67ca89SAndroid Build Coastguard Worker 
391*8d67ca89SAndroid Build Coastguard Worker /**
392*8d67ca89SAndroid Build Coastguard Worker  * [pthread_setschedprio(3)](https://man7.org/linux/man-pages/man3/pthread_setschedprio.3.html)
393*8d67ca89SAndroid Build Coastguard Worker  * sets the scheduler priority of the given thread.
394*8d67ca89SAndroid Build Coastguard Worker  *
395*8d67ca89SAndroid Build Coastguard Worker  * This call is not useful to applications on Android, because they don't
396*8d67ca89SAndroid Build Coastguard Worker  * have permission to set their scheduling policy, and the only priority
397*8d67ca89SAndroid Build Coastguard Worker  * for their policy is 0 anyway. If you only need to set your scheduling
398*8d67ca89SAndroid Build Coastguard Worker  * priority, see setpriority() instead.
399*8d67ca89SAndroid Build Coastguard Worker  *
400*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns an error number on failure.
401*8d67ca89SAndroid Build Coastguard Worker  *
402*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 28.
403*8d67ca89SAndroid Build Coastguard Worker  */
404*8d67ca89SAndroid Build Coastguard Worker 
405*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(28)
406*8d67ca89SAndroid Build Coastguard Worker int pthread_setschedprio(pthread_t __pthread, int __priority) __INTRODUCED_IN(28);
407*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(28) */
408*8d67ca89SAndroid Build Coastguard Worker 
409*8d67ca89SAndroid Build Coastguard Worker 
410*8d67ca89SAndroid Build Coastguard Worker int pthread_setspecific(pthread_key_t __key, const void* _Nullable __value);
411*8d67ca89SAndroid Build Coastguard Worker 
412*8d67ca89SAndroid Build Coastguard Worker typedef void (* _Nullable __pthread_cleanup_func_t)(void* _Nullable);
413*8d67ca89SAndroid Build Coastguard Worker 
414*8d67ca89SAndroid Build Coastguard Worker typedef struct __pthread_cleanup_t {
415*8d67ca89SAndroid Build Coastguard Worker   struct __pthread_cleanup_t*   _Nullable __cleanup_prev;
416*8d67ca89SAndroid Build Coastguard Worker   __pthread_cleanup_func_t      _Nullable __cleanup_routine;
417*8d67ca89SAndroid Build Coastguard Worker   void*                         _Nullable __cleanup_arg;
418*8d67ca89SAndroid Build Coastguard Worker } __pthread_cleanup_t;
419*8d67ca89SAndroid Build Coastguard Worker 
420*8d67ca89SAndroid Build Coastguard Worker void __pthread_cleanup_push(__pthread_cleanup_t* _Nonnull c, __pthread_cleanup_func_t _Nullable, void* _Nullable);
421*8d67ca89SAndroid Build Coastguard Worker void __pthread_cleanup_pop(__pthread_cleanup_t* _Nonnull, int);
422*8d67ca89SAndroid Build Coastguard Worker 
423*8d67ca89SAndroid Build Coastguard Worker /* Believe or not, the definitions of pthread_cleanup_push and
424*8d67ca89SAndroid Build Coastguard Worker  * pthread_cleanup_pop below are correct. Posix states that these
425*8d67ca89SAndroid Build Coastguard Worker  * can be implemented as macros that might introduce opening and
426*8d67ca89SAndroid Build Coastguard Worker  * closing braces, and that using setjmp/longjmp/return/break/continue
427*8d67ca89SAndroid Build Coastguard Worker  * between them results in undefined behavior.
428*8d67ca89SAndroid Build Coastguard Worker  */
429*8d67ca89SAndroid Build Coastguard Worker #define  pthread_cleanup_push(routine, arg)                      \
430*8d67ca89SAndroid Build Coastguard Worker     do {                                                         \
431*8d67ca89SAndroid Build Coastguard Worker         __pthread_cleanup_t  __cleanup;                          \
432*8d67ca89SAndroid Build Coastguard Worker         __pthread_cleanup_push( &__cleanup, (routine), (arg) );  \
433*8d67ca89SAndroid Build Coastguard Worker 
434*8d67ca89SAndroid Build Coastguard Worker #define  pthread_cleanup_pop(execute)                  \
435*8d67ca89SAndroid Build Coastguard Worker         __pthread_cleanup_pop( &__cleanup, (execute)); \
436*8d67ca89SAndroid Build Coastguard Worker     } while (0);                                       \
437*8d67ca89SAndroid Build Coastguard Worker 
438*8d67ca89SAndroid Build Coastguard Worker __END_DECLS
439