17777dab0Sopenharmony_ci#ifndef _PTHREAD_H 27777dab0Sopenharmony_ci#define _PTHREAD_H 37777dab0Sopenharmony_ci#ifdef __cplusplus 47777dab0Sopenharmony_ciextern "C" { 57777dab0Sopenharmony_ci#endif 67777dab0Sopenharmony_ci 77777dab0Sopenharmony_ci#include <features.h> 87777dab0Sopenharmony_ci 97777dab0Sopenharmony_ci/* Musl did not provide the "owner" macro directly, 107777dab0Sopenharmony_ci * so users can not access the mutex-ower-ID. 117777dab0Sopenharmony_ci * Thus we added this macro for getting the owner-ID 127777dab0Sopenharmony_ci * of the mutex. */ 137777dab0Sopenharmony_ci 147777dab0Sopenharmony_ci/* These macros provides macros for accessing inner 157777dab0Sopenharmony_ci * attributes of the pthread_mutex_t struct. 167777dab0Sopenharmony_ci * It is intended for solving the coompiling failure 177777dab0Sopenharmony_ci * of Dopra codes which claims that .__data.* realm 187777dab0Sopenharmony_ci * can not be found in pthread_mutex_t. */ 197777dab0Sopenharmony_ci 207777dab0Sopenharmony_ci#define __NEED_time_t 217777dab0Sopenharmony_ci#define __NEED_clockid_t 227777dab0Sopenharmony_ci#define __NEED_struct_timespec 237777dab0Sopenharmony_ci#define __NEED_sigset_t 247777dab0Sopenharmony_ci#define __NEED_pthread_t 257777dab0Sopenharmony_ci#define __NEED_pthread_attr_t 267777dab0Sopenharmony_ci#define __NEED_pthread_mutexattr_t 277777dab0Sopenharmony_ci#define __NEED_pthread_condattr_t 287777dab0Sopenharmony_ci#define __NEED_pthread_rwlockattr_t 297777dab0Sopenharmony_ci#define __NEED_pthread_barrierattr_t 307777dab0Sopenharmony_ci#define __NEED_pthread_mutex_t 317777dab0Sopenharmony_ci#define __NEED_pthread_cond_t 327777dab0Sopenharmony_ci#define __NEED_pthread_rwlock_t 337777dab0Sopenharmony_ci#define __NEED_pthread_barrier_t 347777dab0Sopenharmony_ci#define __NEED_pthread_spinlock_t 357777dab0Sopenharmony_ci#define __NEED_pthread_key_t 367777dab0Sopenharmony_ci#define __NEED_pthread_once_t 377777dab0Sopenharmony_ci#define __NEED_size_t 387777dab0Sopenharmony_ci 397777dab0Sopenharmony_ci#include <bits/alltypes.h> 407777dab0Sopenharmony_ci 417777dab0Sopenharmony_ci#include <sched.h> 427777dab0Sopenharmony_ci#include <time.h> 437777dab0Sopenharmony_ci 447777dab0Sopenharmony_ci#define PTHREAD_CREATE_JOINABLE 0 457777dab0Sopenharmony_ci#define PTHREAD_CREATE_DETACHED 1 467777dab0Sopenharmony_ci 477777dab0Sopenharmony_ci#define PTHREAD_MUTEX_NORMAL 0 487777dab0Sopenharmony_ci#define PTHREAD_MUTEX_DEFAULT 0 497777dab0Sopenharmony_ci#define PTHREAD_MUTEX_RECURSIVE 1 507777dab0Sopenharmony_ci#define PTHREAD_MUTEX_ERRORCHECK 2 517777dab0Sopenharmony_ci 527777dab0Sopenharmony_ci#define PTHREAD_MUTEX_STALLED 0 537777dab0Sopenharmony_ci#define PTHREAD_MUTEX_ROBUST 1 547777dab0Sopenharmony_ci 557777dab0Sopenharmony_ci#define PTHREAD_PRIO_NONE 0 567777dab0Sopenharmony_ci#define PTHREAD_PRIO_INHERIT 1 577777dab0Sopenharmony_ci#define PTHREAD_PRIO_PROTECT 2 587777dab0Sopenharmony_ci 597777dab0Sopenharmony_ci#define PTHREAD_INHERIT_SCHED 0 607777dab0Sopenharmony_ci#define PTHREAD_EXPLICIT_SCHED 1 617777dab0Sopenharmony_ci 627777dab0Sopenharmony_ci#define PTHREAD_SCOPE_SYSTEM 0 637777dab0Sopenharmony_ci#define PTHREAD_SCOPE_PROCESS 1 647777dab0Sopenharmony_ci 657777dab0Sopenharmony_ci#define PTHREAD_PROCESS_PRIVATE 0 667777dab0Sopenharmony_ci#define PTHREAD_PROCESS_SHARED 1 677777dab0Sopenharmony_ci 687777dab0Sopenharmony_ci 697777dab0Sopenharmony_ci#define PTHREAD_MUTEX_INITIALIZER {{{0}}} 707777dab0Sopenharmony_ci#define PTHREAD_RWLOCK_INITIALIZER {{{0}}} 717777dab0Sopenharmony_ci#define PTHREAD_COND_INITIALIZER {{{0}}} 727777dab0Sopenharmony_ci#define PTHREAD_ONCE_INIT 0 737777dab0Sopenharmony_ci 747777dab0Sopenharmony_ci 757777dab0Sopenharmony_ci#define PTHREAD_CANCEL_ENABLE 0 767777dab0Sopenharmony_ci#define PTHREAD_CANCEL_DISABLE 1 777777dab0Sopenharmony_ci#define PTHREAD_CANCEL_MASKED 2 787777dab0Sopenharmony_ci 797777dab0Sopenharmony_ci#define PTHREAD_CANCEL_DEFERRED 0 807777dab0Sopenharmony_ci#define PTHREAD_CANCEL_ASYNCHRONOUS 1 817777dab0Sopenharmony_ci 827777dab0Sopenharmony_ci#define PTHREAD_CANCELED ((void *)-1) 837777dab0Sopenharmony_ci 847777dab0Sopenharmony_ci 857777dab0Sopenharmony_ci#define PTHREAD_BARRIER_SERIAL_THREAD (-1) 867777dab0Sopenharmony_ci 877777dab0Sopenharmony_ci 887777dab0Sopenharmony_ciint pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict); 897777dab0Sopenharmony_ciint pthread_detach(pthread_t); 907777dab0Sopenharmony_ci_Noreturn void pthread_exit(void *); 917777dab0Sopenharmony_ciint pthread_join(pthread_t, void **); 927777dab0Sopenharmony_cipid_t pthread_gettid_np(pthread_t); 937777dab0Sopenharmony_ci 947777dab0Sopenharmony_ci#ifdef __GNUC__ 957777dab0Sopenharmony_ci__attribute__((const)) 967777dab0Sopenharmony_ci#endif 977777dab0Sopenharmony_cipthread_t pthread_self(void); 987777dab0Sopenharmony_ci 997777dab0Sopenharmony_ciint pthread_equal(pthread_t, pthread_t); 1007777dab0Sopenharmony_ci#ifndef __cplusplus 1017777dab0Sopenharmony_ci#define pthread_equal(x,y) ((x)==(y)) 1027777dab0Sopenharmony_ci#endif 1037777dab0Sopenharmony_ci 1047777dab0Sopenharmony_ciint pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict); 1057777dab0Sopenharmony_ciint pthread_setschedparam(pthread_t, int, const struct sched_param *); 1067777dab0Sopenharmony_ciint pthread_setschedprio(pthread_t, int); 1077777dab0Sopenharmony_ci 1087777dab0Sopenharmony_ciint pthread_once(pthread_once_t *, void (*)(void)); 1097777dab0Sopenharmony_ci 1107777dab0Sopenharmony_ciint pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict); 1117777dab0Sopenharmony_ciint pthread_mutex_lock(pthread_mutex_t *); 1127777dab0Sopenharmony_ciint pthread_mutex_unlock(pthread_mutex_t *); 1137777dab0Sopenharmony_ciint pthread_mutex_trylock(pthread_mutex_t *); 1147777dab0Sopenharmony_ciint pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict); 1157777dab0Sopenharmony_ciint pthread_mutex_destroy(pthread_mutex_t *); 1167777dab0Sopenharmony_ci/** 1177777dab0Sopenharmony_ci * @brief lock the mutex object referenced by mutex. If the mutex is already locked, 1187777dab0Sopenharmony_ci * the calling thread shall block until the mutex becomes available as in the 1197777dab0Sopenharmony_ci * pthread_mutex_lock() function. If the mutex cannot be locked without waiting for 1207777dab0Sopenharmony_ci * another thread to unlock the mutex, this wait shall be terminated when the specified 1217777dab0Sopenharmony_ci * timeout expires. The timeout shall be based on the CLOCK_REALTIME or CLOCK_MONOTONIC clock. 1227777dab0Sopenharmony_ci * The resolution of the timeout shall be the resolution of the clock on which it is based. 1237777dab0Sopenharmony_ci * @param mutex a robust mutex and the process containing the owning thread terminated while holding the mutex lock. 1247777dab0Sopenharmony_ci * @param clock_id specified CLOCK_REALTIME or CLOCK_MONOTONIC clock. 1257777dab0Sopenharmony_ci * @param timespec the timeout shall expire specified by abstime passes. 1267777dab0Sopenharmony_ci * @return clocklock result. 1277777dab0Sopenharmony_ci * @retval 0 is returned on success. 1287777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 1297777dab0Sopenharmony_ci */ 1307777dab0Sopenharmony_ciint pthread_mutex_clocklock(pthread_mutex_t *__restrict, clockid_t, const struct timespec *__restrict); 1317777dab0Sopenharmony_ci/** 1327777dab0Sopenharmony_ci * @brief lock the mutex object referenced by mutex. If the mutex is already locked, 1337777dab0Sopenharmony_ci * the calling thread shall block until the mutex becomes available as in the 1347777dab0Sopenharmony_ci * pthread_mutex_lock() function. If the mutex cannot be locked without waiting for 1357777dab0Sopenharmony_ci * another thread to unlock the mutex, this wait shall be terminated when the specified 1367777dab0Sopenharmony_ci * timeout expires. The timeout shall be based on the CLOCK_MONOTONIC clock. 1377777dab0Sopenharmony_ci * The resolution of the timeout shall be the resolution of the clock on which it is based. 1387777dab0Sopenharmony_ci * @param mutex a robust mutex and the process containing the owning thread terminated while holding the mutex lock. 1397777dab0Sopenharmony_ci * @param timespec the timeout shall expire specified by abstime passes. 1407777dab0Sopenharmony_ci * @return clocklock result. 1417777dab0Sopenharmony_ci * @retval 0 is returned on success. 1427777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 1437777dab0Sopenharmony_ci */ 1447777dab0Sopenharmony_ciint pthread_mutex_timedlock_monotonic_np(pthread_mutex_t *__restrict, const struct timespec *__restrict); 1457777dab0Sopenharmony_ci/** 1467777dab0Sopenharmony_ci * @brief lock the mutex object referenced by mutex. If the mutex is already locked, 1477777dab0Sopenharmony_ci * the calling thread shall block until the mutex becomes available as in the 1487777dab0Sopenharmony_ci * pthread_mutex_lock() function. If the mutex cannot be locked without waiting for 1497777dab0Sopenharmony_ci * another thread to unlock the mutex, this wait shall be terminated when the specified 1507777dab0Sopenharmony_ci * timeout expires. The timeout shall be based on the CLOCK_MONOTONIC clock. 1517777dab0Sopenharmony_ci * The resolution of the timeout shall be the resolution of the clock on which it is based. 1527777dab0Sopenharmony_ci * @param mutex a robust mutex and the process containing the owning thread terminated while holding the mutex lock. 1537777dab0Sopenharmony_ci * @param ms the timeout shall expire specified by relative time(ms) passes. 1547777dab0Sopenharmony_ci * @return clocklock result. 1557777dab0Sopenharmony_ci * @retval 0 is returned on success. 1567777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 1577777dab0Sopenharmony_ci */ 1587777dab0Sopenharmony_ciint pthread_mutex_lock_timeout_np(pthread_mutex_t *__restrict, unsigned int); 1597777dab0Sopenharmony_ci 1607777dab0Sopenharmony_ciint pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__restrict); 1617777dab0Sopenharmony_ciint pthread_cond_destroy(pthread_cond_t *); 1627777dab0Sopenharmony_ciint pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict); 1637777dab0Sopenharmony_ciint pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict); 1647777dab0Sopenharmony_ci/** 1657777dab0Sopenharmony_ci * @brief The thread waits for a signal to trigger, and if timeout or signal is triggered, 1667777dab0Sopenharmony_ci * the thread wakes up. 1677777dab0Sopenharmony_ci * @param pthread_cond_t Condition variables for multithreading. 1687777dab0Sopenharmony_ci * @param pthread_mutex_t Thread mutex variable. 1697777dab0Sopenharmony_ci * @param clockid_t Clock ID used in clock and timer functions. 1707777dab0Sopenharmony_ci * @param timespec The timeout shall expire specified by abstime passes. 1717777dab0Sopenharmony_ci * @return pthread_cond_clockwait result. 1727777dab0Sopenharmony_ci * @retval 0 pthread_cond_clockwait successful. 1737777dab0Sopenharmony_ci * @retval ETIMEDOUT pthread_cond_clockwait Connection timed out. 1747777dab0Sopenharmony_ci * @retval EINVAL pthread_cond_clockwait error. 1757777dab0Sopenharmony_ci */ 1767777dab0Sopenharmony_ciint pthread_cond_clockwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, 1777777dab0Sopenharmony_ci clockid_t, const struct timespec *__restrict); 1787777dab0Sopenharmony_ci 1797777dab0Sopenharmony_ci/** 1807777dab0Sopenharmony_ci * @brief Condition variables have an initialization option to use CLOCK_MONOTONIC. 1817777dab0Sopenharmony_ci * The thread waits for a signal to trigger, and if timeout or signal is triggered, 1827777dab0Sopenharmony_ci * the thread wakes up. 1837777dab0Sopenharmony_ci * @param pthread_cond_t Condition variables for multithreading. 1847777dab0Sopenharmony_ci * @param pthread_mutex_t Thread mutex variable. 1857777dab0Sopenharmony_ci * @param timespec The timeout shall expire specified by abstime passes. 1867777dab0Sopenharmony_ci * @return pthread_cond_timedwait_monotonic_np result. 1877777dab0Sopenharmony_ci * @retval 0 pthread_cond_timedwait_monotonic_np successful. 1887777dab0Sopenharmony_ci * @retval ETIMEDOUT pthread_cond_timedwait_monotonic_np Connection timed out. 1897777dab0Sopenharmony_ci * @retval EINVAL pthread_cond_timedwait_monotonic_np error. 1907777dab0Sopenharmony_ci */ 1917777dab0Sopenharmony_ciint pthread_cond_timedwait_monotonic_np(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, 1927777dab0Sopenharmony_ci const struct timespec *__restrict); 1937777dab0Sopenharmony_ci 1947777dab0Sopenharmony_ci/** 1957777dab0Sopenharmony_ci * @brief Condition variables have an initialization option to use CLOCK_MONOTONIC and The time 1967777dab0Sopenharmony_ci * parameter is in milliseconds. The thread waits for a signal to trigger, and if timeout or 1977777dab0Sopenharmony_ci * signal is triggered, the thread wakes up. 1987777dab0Sopenharmony_ci * @param pthread_cond_t Condition variables for multithreading. 1997777dab0Sopenharmony_ci * @param pthread_mutex_t Thread mutex variable. 2007777dab0Sopenharmony_ci * @param unsigned Timeout, in milliseconds. 2017777dab0Sopenharmony_ci * @return pthread_cond_timeout_np result. 2027777dab0Sopenharmony_ci * @retval 0 pthread_cond_timeout_np successful. 2037777dab0Sopenharmony_ci * @retval ETIMEDOUT pthread_cond_timeout_np Connection timed out. 2047777dab0Sopenharmony_ci * @retval EINVAL pthread_cond_timeout_np error. 2057777dab0Sopenharmony_ci */ 2067777dab0Sopenharmony_ciint pthread_cond_timeout_np(pthread_cond_t* __restrict, pthread_mutex_t* __restrict, unsigned int); 2077777dab0Sopenharmony_ciint pthread_cond_broadcast(pthread_cond_t *); 2087777dab0Sopenharmony_ciint pthread_cond_signal(pthread_cond_t *); 2097777dab0Sopenharmony_ci 2107777dab0Sopenharmony_ciint pthread_rwlock_init(pthread_rwlock_t *__restrict, const pthread_rwlockattr_t *__restrict); 2117777dab0Sopenharmony_ciint pthread_rwlock_destroy(pthread_rwlock_t *); 2127777dab0Sopenharmony_ciint pthread_rwlock_rdlock(pthread_rwlock_t *); 2137777dab0Sopenharmony_ciint pthread_rwlock_tryrdlock(pthread_rwlock_t *); 2147777dab0Sopenharmony_ciint pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); 2157777dab0Sopenharmony_ci/** 2167777dab0Sopenharmony_ci * @brief Apply a read lock to the read-write lock referenced by rwlock as in the 2177777dab0Sopenharmony_ci * pthread_rwlock_rdlock() function. However, if the lock cannot be acquired without 2187777dab0Sopenharmony_ci * waiting for other threads to unlock the lock, this wait shall be terminated when 2197777dab0Sopenharmony_ci * the specified timeout expires. The timeout shall expire when the absolute time specified by 2207777dab0Sopenharmony_ci * abstime passes, as measured by the clock on which timeouts are based, or if the absolute time 2217777dab0Sopenharmony_ci * specified by abstime has already been passed at the time of the call. 2227777dab0Sopenharmony_ci * The timeout shall be based on the CLOCK_REALTIME or CLOCK_MONOTONIC clock. 2237777dab0Sopenharmony_ci * @param rw a read lock to the read-write lock referenced. 2247777dab0Sopenharmony_ci * @param clock_id specified CLOCK_REALTIME or CLOCK_MONOTONIC clock. 2257777dab0Sopenharmony_ci * @param timespec the timeout shall expire specified by abstime passes. 2267777dab0Sopenharmony_ci * @return clockrdlock result. 2277777dab0Sopenharmony_ci * @retval 0 is returned on success. 2287777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 2297777dab0Sopenharmony_ci */ 2307777dab0Sopenharmony_ciint pthread_rwlock_clockrdlock(pthread_rwlock_t *__restrict, clockid_t, const struct timespec *__restrict); 2317777dab0Sopenharmony_ci/** 2327777dab0Sopenharmony_ci * @brief Apply a read lock to the read-write lock referenced by rwlock as in the 2337777dab0Sopenharmony_ci * pthread_rwlock_rdlock() function. However, if the lock cannot be acquired without 2347777dab0Sopenharmony_ci * waiting for other threads to unlock the lock, this wait shall be terminated when 2357777dab0Sopenharmony_ci * the specified timeout expires. The timeout shall expire when the absolute time specified by 2367777dab0Sopenharmony_ci * abstime passes, as measured by the clock on which timeouts are based, or if the absolute time 2377777dab0Sopenharmony_ci * specified by abstime has already been passed at the time of the call. 2387777dab0Sopenharmony_ci * The timeout shall be based on the CLOCK_MONOTONIC clock. 2397777dab0Sopenharmony_ci * @param rw a read lock to the read-write lock referenced. 2407777dab0Sopenharmony_ci * @param timespec the timeout shall expire specified by abstime passes. 2417777dab0Sopenharmony_ci * @return clockrdlock result. 2427777dab0Sopenharmony_ci * @retval 0 is returned on success. 2437777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 2447777dab0Sopenharmony_ci */ 2457777dab0Sopenharmony_ciint pthread_rwlock_timedrdlock_monotonic_np(pthread_rwlock_t *__restrict, const struct timespec *__restrict); 2467777dab0Sopenharmony_ciint pthread_rwlock_wrlock(pthread_rwlock_t *); 2477777dab0Sopenharmony_ciint pthread_rwlock_trywrlock(pthread_rwlock_t *); 2487777dab0Sopenharmony_ciint pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); 2497777dab0Sopenharmony_ciint pthread_rwlock_unlock(pthread_rwlock_t *); 2507777dab0Sopenharmony_ci/** 2517777dab0Sopenharmony_ci * @brief Read-write lock variables have an initialization option to use CLOCK_MONOTONIC. 2527777dab0Sopenharmony_ci * apply a read lock to the read-write lock referenced by rwlock as in the 2537777dab0Sopenharmony_ci * pthread_rwlock_wrlock() function. However, if the lock cannot be acquired without 2547777dab0Sopenharmony_ci * waiting for other threads to unlock the lock, this wait shall be terminated when 2557777dab0Sopenharmony_ci * the specified timeout expires. The timeout shall expire when the absolute time specified by 2567777dab0Sopenharmony_ci * abstime passes, as measured by the clock on which timeouts are based, or if the absolute time 2577777dab0Sopenharmony_ci * specified by abstime has already been passed at the time of the call. 2587777dab0Sopenharmony_ci * The timeout shall be based on the CLOCK_MONOTONIC clock. 2597777dab0Sopenharmony_ci * @param rw a read lock to the read-write lock referenced. 2607777dab0Sopenharmony_ci * @param timespec the timeout shall expire specified by abstime passes. 2617777dab0Sopenharmony_ci * @return clockrdlock result. 2627777dab0Sopenharmony_ci * @retval 0 is returned on success. 2637777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 2647777dab0Sopenharmony_ci */ 2657777dab0Sopenharmony_ciint pthread_rwlock_timedwrlock_monotonic_np(pthread_rwlock_t *__restrict, const struct timespec *__restrict); 2667777dab0Sopenharmony_ci 2677777dab0Sopenharmony_ci/** 2687777dab0Sopenharmony_ci * @brief Apply a read lock to the read-write lock referenced by rwlock as in the 2697777dab0Sopenharmony_ci * pthread_rwlock_wrlock() function. However, if the lock cannot be acquired without 2707777dab0Sopenharmony_ci * waiting for other threads to unlock the lock, this wait shall be terminated when 2717777dab0Sopenharmony_ci * the specified timeout expires. The timeout shall expire when the absolute time specified by 2727777dab0Sopenharmony_ci * abstime passes, as measured by the clock on which timeouts are based, or if the absolute time 2737777dab0Sopenharmony_ci * specified by abstime has already been passed at the time of the call. 2747777dab0Sopenharmony_ci * The timeout shall be based on the CLOCK_REALTIME or CLOCK_MONOTONIC clock. 2757777dab0Sopenharmony_ci * @param rw a read lock to the read-write lock referenced. 2767777dab0Sopenharmony_ci * @param clock_id specified CLOCK_REALTIME or CLOCK_MONOTONIC clock. 2777777dab0Sopenharmony_ci * @param timespec the timeout shall expire specified by abstime passes. 2787777dab0Sopenharmony_ci * @return clockrdlock result. 2797777dab0Sopenharmony_ci * @retval 0 is returned on success. 2807777dab0Sopenharmony_ci * @retval -1 is returned on failure, and errno is set to indicate the error. 2817777dab0Sopenharmony_ci */ 2827777dab0Sopenharmony_ciint pthread_rwlock_clockwrlock(pthread_rwlock_t *__restrict, clockid_t, const struct timespec *__restrict); 2837777dab0Sopenharmony_ci 2847777dab0Sopenharmony_ciint pthread_spin_init(pthread_spinlock_t *, int); 2857777dab0Sopenharmony_ciint pthread_spin_destroy(pthread_spinlock_t *); 2867777dab0Sopenharmony_ciint pthread_spin_lock(pthread_spinlock_t *); 2877777dab0Sopenharmony_ciint pthread_spin_trylock(pthread_spinlock_t *); 2887777dab0Sopenharmony_ciint pthread_spin_unlock(pthread_spinlock_t *); 2897777dab0Sopenharmony_ci 2907777dab0Sopenharmony_ciint pthread_barrier_init(pthread_barrier_t *__restrict, const pthread_barrierattr_t *__restrict, unsigned); 2917777dab0Sopenharmony_ciint pthread_barrier_destroy(pthread_barrier_t *); 2927777dab0Sopenharmony_ciint pthread_barrier_wait(pthread_barrier_t *); 2937777dab0Sopenharmony_ci 2947777dab0Sopenharmony_ciint pthread_key_create(pthread_key_t *, void (*)(void *)); 2957777dab0Sopenharmony_ciint pthread_key_delete(pthread_key_t); 2967777dab0Sopenharmony_civoid *pthread_getspecific(pthread_key_t); 2977777dab0Sopenharmony_ciint pthread_setspecific(pthread_key_t, const void *); 2987777dab0Sopenharmony_ci 2997777dab0Sopenharmony_ciint pthread_attr_init(pthread_attr_t *); 3007777dab0Sopenharmony_ciint pthread_attr_destroy(pthread_attr_t *); 3017777dab0Sopenharmony_ci 3027777dab0Sopenharmony_ciint pthread_attr_getguardsize(const pthread_attr_t *__restrict, size_t *__restrict); 3037777dab0Sopenharmony_ciint pthread_attr_setguardsize(pthread_attr_t *, size_t); 3047777dab0Sopenharmony_ciint pthread_attr_getstacksize(const pthread_attr_t *__restrict, size_t *__restrict); 3057777dab0Sopenharmony_ciint pthread_attr_setstacksize(pthread_attr_t *, size_t); 3067777dab0Sopenharmony_ciint pthread_attr_getdetachstate(const pthread_attr_t *, int *); 3077777dab0Sopenharmony_ciint pthread_attr_setdetachstate(pthread_attr_t *, int); 3087777dab0Sopenharmony_ciint pthread_attr_getstack(const pthread_attr_t *__restrict, void **__restrict, size_t *__restrict); 3097777dab0Sopenharmony_ciint pthread_attr_setstack(pthread_attr_t *, void *, size_t); 3107777dab0Sopenharmony_ciint pthread_attr_getscope(const pthread_attr_t *__restrict, int *__restrict); 3117777dab0Sopenharmony_ciint pthread_attr_setscope(pthread_attr_t *, int); 3127777dab0Sopenharmony_ciint pthread_attr_getschedpolicy(const pthread_attr_t *__restrict, int *__restrict); 3137777dab0Sopenharmony_ciint pthread_attr_setschedpolicy(pthread_attr_t *, int); 3147777dab0Sopenharmony_ciint pthread_attr_getschedparam(const pthread_attr_t *__restrict, struct sched_param *__restrict); 3157777dab0Sopenharmony_ciint pthread_attr_setschedparam(pthread_attr_t *__restrict, const struct sched_param *__restrict); 3167777dab0Sopenharmony_ciint pthread_attr_getinheritsched(const pthread_attr_t *__restrict, int *__restrict); 3177777dab0Sopenharmony_ciint pthread_attr_setinheritsched(pthread_attr_t *, int); 3187777dab0Sopenharmony_ci 3197777dab0Sopenharmony_ciint pthread_mutexattr_destroy(pthread_mutexattr_t *); 3207777dab0Sopenharmony_ciint pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict, int *__restrict); 3217777dab0Sopenharmony_ciint pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict, int *__restrict); 3227777dab0Sopenharmony_ciint pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict, int *__restrict); 3237777dab0Sopenharmony_ciint pthread_mutexattr_init(pthread_mutexattr_t *); 3247777dab0Sopenharmony_ciint pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); 3257777dab0Sopenharmony_ciint pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); 3267777dab0Sopenharmony_ciint pthread_mutexattr_settype(pthread_mutexattr_t *, int); 3277777dab0Sopenharmony_ci 3287777dab0Sopenharmony_ciint pthread_condattr_init(pthread_condattr_t *); 3297777dab0Sopenharmony_ciint pthread_condattr_destroy(pthread_condattr_t *); 3307777dab0Sopenharmony_ciint pthread_condattr_setclock(pthread_condattr_t *, clockid_t); 3317777dab0Sopenharmony_ciint pthread_condattr_setpshared(pthread_condattr_t *, int); 3327777dab0Sopenharmony_ciint pthread_condattr_getclock(const pthread_condattr_t *__restrict, clockid_t *__restrict); 3337777dab0Sopenharmony_ciint pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict); 3347777dab0Sopenharmony_ci 3357777dab0Sopenharmony_ciint pthread_rwlockattr_init(pthread_rwlockattr_t *); 3367777dab0Sopenharmony_ciint pthread_rwlockattr_destroy(pthread_rwlockattr_t *); 3377777dab0Sopenharmony_ciint pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); 3387777dab0Sopenharmony_ciint pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict, int *__restrict); 3397777dab0Sopenharmony_ci 3407777dab0Sopenharmony_ciint pthread_barrierattr_destroy(pthread_barrierattr_t *); 3417777dab0Sopenharmony_ciint pthread_barrierattr_getpshared(const pthread_barrierattr_t *__restrict, int *__restrict); 3427777dab0Sopenharmony_ciint pthread_barrierattr_init(pthread_barrierattr_t *); 3437777dab0Sopenharmony_ciint pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); 3447777dab0Sopenharmony_ci 3457777dab0Sopenharmony_ciint pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); 3467777dab0Sopenharmony_ci 3477777dab0Sopenharmony_ciint pthread_getcpuclockid(pthread_t, clockid_t *); 3487777dab0Sopenharmony_ci 3497777dab0Sopenharmony_cistruct __ptcb { 3507777dab0Sopenharmony_ci void (*__f)(void *); 3517777dab0Sopenharmony_ci void *__x; 3527777dab0Sopenharmony_ci struct __ptcb *__next; 3537777dab0Sopenharmony_ci}; 3547777dab0Sopenharmony_ci 3557777dab0Sopenharmony_civoid _pthread_cleanup_push(struct __ptcb *, void (*)(void *), void *); 3567777dab0Sopenharmony_civoid _pthread_cleanup_pop(struct __ptcb *, int); 3577777dab0Sopenharmony_ci 3587777dab0Sopenharmony_ci#define pthread_cleanup_push(f, x) do { struct __ptcb __cb; _pthread_cleanup_push(&__cb, f, x); 3597777dab0Sopenharmony_ci#define pthread_cleanup_pop(r) _pthread_cleanup_pop(&__cb, (r)); } while(0) 3607777dab0Sopenharmony_ci 3617777dab0Sopenharmony_ci#ifdef _GNU_SOURCE 3627777dab0Sopenharmony_cistruct cpu_set_t; 3637777dab0Sopenharmony_ciint pthread_getattr_np(pthread_t, pthread_attr_t *); 3647777dab0Sopenharmony_ciint pthread_setname_np(pthread_t, const char *); 3657777dab0Sopenharmony_ciint pthread_getname_np(pthread_t, char *, size_t); 3667777dab0Sopenharmony_ci#endif 3677777dab0Sopenharmony_ci 3687777dab0Sopenharmony_ci#if _REDIR_TIME64 3697777dab0Sopenharmony_ci__REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64); 3707777dab0Sopenharmony_ci__REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64); 3717777dab0Sopenharmony_ci__REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64); 3727777dab0Sopenharmony_ci__REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64); 3737777dab0Sopenharmony_ci#endif 3747777dab0Sopenharmony_ci 3757777dab0Sopenharmony_ci#ifdef __cplusplus 3767777dab0Sopenharmony_ci} 3777777dab0Sopenharmony_ci#endif 3787777dab0Sopenharmony_ci#endif 379