#ifndef _PTHREAD_H
#define _PTHREAD_H
#include <_types.h>
#ifndef __POSIX_LIB__
#include <pthread_impl.h>
#endif
#include <sched.h>
#include <time.h>
#ifndef _PTHREAD_ATTR_T
#define _PTHREAD_ATTR_T
typedef __darwin_pthread_attr_t pthread_attr_t;
#endif
#ifndef _PTHREAD_COND_T
#define _PTHREAD_COND_T
typedef __darwin_pthread_cond_t pthread_cond_t;
#endif
#ifndef _PTHREAD_CONDATTR_T
#define _PTHREAD_CONDATTR_T
typedef __darwin_pthread_condattr_t pthread_condattr_t;
#endif
#ifndef _PTHREAD_KEY_T
#define _PTHREAD_KEY_T
typedef __darwin_pthread_key_t pthread_key_t;
#endif
#ifndef _PTHREAD_MUTEX_T
#define _PTHREAD_MUTEX_T
typedef __darwin_pthread_mutex_t pthread_mutex_t;
#endif
#ifndef _PTHREAD_MUTEXATTR_T
#define _PTHREAD_MUTEXATTR_T
typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t;
#endif
#ifndef _PTHREAD_ONCE_T
#define _PTHREAD_ONCE_T
typedef __darwin_pthread_once_t pthread_once_t;
#endif
#ifndef _PTHREAD_RWLOCK_T
#define _PTHREAD_RWLOCK_T
typedef __darwin_pthread_rwlock_t pthread_rwlock_t;
#endif
#ifndef _PTHREAD_RWLOCKATTR_T
#define _PTHREAD_RWLOCKATTR_T
typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t;
#endif
#ifndef _PTHREAD_T
#define _PTHREAD_T
typedef __darwin_pthread_t pthread_t;
#endif
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
#ifndef _MACH_PORT_T
#define _MACH_PORT_T
typedef __darwin_mach_port_t mach_port_t;
#endif
#ifndef _SIGSET_T
#define _SIGSET_T
typedef __darwin_sigset_t sigset_t;
#endif
#endif
#include <sys/cdefs.h>
#include <Availability.h>
__BEGIN_DECLS
#define pthread_cleanup_push(func, val) \
{ \
struct __darwin_pthread_handler_rec __handler; \
pthread_t __self = pthread_self(); \
__handler.__routine = func; \
__handler.__arg = val; \
__handler.__next = __self->__cleanup_stack; \
__self->__cleanup_stack = &__handler;
#define pthread_cleanup_pop(execute) \
\
__self->__cleanup_stack = __handler.__next; \
if (execute) (__handler.__routine)(__handler.__arg); \
}
#define PTHREAD_CREATE_JOINABLE 1
#define PTHREAD_CREATE_DETACHED 2
#define PTHREAD_INHERIT_SCHED 1
#define PTHREAD_EXPLICIT_SCHED 2
#define PTHREAD_CANCEL_ENABLE 0x01
#define PTHREAD_CANCEL_DISABLE 0x00
#define PTHREAD_CANCEL_DEFERRED 0x02
#define PTHREAD_CANCEL_ASYNCHRONOUS 0x00
#define PTHREAD_CANCELED ((void *) 1)
#define PTHREAD_SCOPE_SYSTEM 1
#define PTHREAD_SCOPE_PROCESS 2
#define PTHREAD_PROCESS_SHARED 1
#define PTHREAD_PROCESS_PRIVATE 2
#define PTHREAD_PRIO_NONE 0
#define PTHREAD_PRIO_INHERIT 1
#define PTHREAD_PRIO_PROTECT 2
#define PTHREAD_MUTEX_NORMAL 0
#define PTHREAD_MUTEX_ERRORCHECK 1
#define PTHREAD_MUTEX_RECURSIVE 2
#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}}
#define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init, {0}}
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER {_PTHREAD_ERRORCHECK_MUTEX_SIG_init, {0}}
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {_PTHREAD_RECURSIVE_MUTEX_SIG_init, {0}}
#endif
#define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init, {0}}
#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}}
int pthread_atfork(void (*)(void), void (*)(void),
void (*)(void));
int pthread_attr_destroy(pthread_attr_t *);
int pthread_attr_getdetachstate(const pthread_attr_t *,
int *);
int pthread_attr_getguardsize(const pthread_attr_t * __restrict,
size_t * __restrict);
int pthread_attr_getinheritsched(const pthread_attr_t * __restrict,
int * __restrict);
int pthread_attr_getschedparam(const pthread_attr_t * __restrict,
struct sched_param * __restrict);
int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict,
int * __restrict);
int pthread_attr_getscope(const pthread_attr_t * __restrict, int * __restrict);
int pthread_attr_getstack(const pthread_attr_t * __restrict,
void ** __restrict, size_t * __restrict);
int pthread_attr_getstackaddr(const pthread_attr_t * __restrict,
void ** __restrict);
int pthread_attr_getstacksize(const pthread_attr_t * __restrict,
size_t * __restrict);
int pthread_attr_init(pthread_attr_t *);
int pthread_attr_setdetachstate(pthread_attr_t *,
int );
int pthread_attr_setguardsize(pthread_attr_t *, size_t );
int pthread_attr_setinheritsched(pthread_attr_t *,
int );
int pthread_attr_setschedparam(pthread_attr_t * __restrict,
const struct sched_param * __restrict);
int pthread_attr_setschedpolicy(pthread_attr_t *,
int );
int pthread_attr_setscope(pthread_attr_t *, int);
int pthread_attr_setstack(pthread_attr_t *,
void *, size_t );
int pthread_attr_setstackaddr(pthread_attr_t *,
void *);
int pthread_attr_setstacksize(pthread_attr_t *, size_t );
int pthread_cancel(pthread_t ) __DARWIN_ALIAS(pthread_cancel);
int pthread_cond_broadcast(pthread_cond_t *);
int pthread_cond_destroy(pthread_cond_t *);
#ifndef LIBC_ALIAS_PTHREAD_COND_INIT
int pthread_cond_init(pthread_cond_t * __restrict,
const pthread_condattr_t * __restrict) __DARWIN_ALIAS(pthread_cond_init);
#else
int pthread_cond_init(pthread_cond_t * __restrict,
const pthread_condattr_t * __restrict) LIBC_ALIAS(pthread_cond_init);
#endif
int pthread_cond_signal(pthread_cond_t *);
#ifndef LIBC_ALIAS_PTHREAD_COND_TIMEDWAIT
int pthread_cond_timedwait(pthread_cond_t * __restrict,
pthread_mutex_t * __restrict,
const struct timespec * __restrict) __DARWIN_ALIAS_C(pthread_cond_timedwait);
#else
int pthread_cond_timedwait(pthread_cond_t * __restrict,
pthread_mutex_t * __restrict,
const struct timespec * __restrict) LIBC_ALIAS_C(pthread_cond_timedwait);
#endif
#ifndef LIBC_ALIAS_PTHREAD_COND_WAIT
int pthread_cond_wait(pthread_cond_t * __restrict,
pthread_mutex_t * __restrict) __DARWIN_ALIAS_C(pthread_cond_wait);
#else
int pthread_cond_wait(pthread_cond_t * __restrict,
pthread_mutex_t * __restrict) LIBC_ALIAS_C(pthread_cond_wait);
#endif
int pthread_condattr_destroy(pthread_condattr_t *);
int pthread_condattr_init(pthread_condattr_t *);
int pthread_condattr_getpshared(const pthread_condattr_t * __restrict,
int * __restrict);
int pthread_condattr_setpshared(pthread_condattr_t *,
int );
int pthread_create(pthread_t * __restrict,
const pthread_attr_t * __restrict,
void *(*)(void *),
void * __restrict);
int pthread_detach(pthread_t );
int pthread_equal(pthread_t ,
pthread_t );
void pthread_exit(void *) __dead2;
int pthread_getconcurrency(void);
int pthread_getschedparam(pthread_t , int * __restrict, struct sched_param * __restrict);
void *pthread_getspecific(pthread_key_t );
#ifndef LIBC_ALIAS_PTHREAD_JOIN
int pthread_join(pthread_t , void **) __DARWIN_ALIAS_C(pthread_join);
#else
int pthread_join(pthread_t , void **) LIBC_ALIAS_C(pthread_join);
#endif
int pthread_key_create(pthread_key_t *, void (*)(void *));
int pthread_key_delete(pthread_key_t );
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict, int * __restrict);
int pthread_mutex_init(pthread_mutex_t * __restrict, const pthread_mutexattr_t * __restrict);
int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int, int * __restrict);
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
#ifndef LIBC_ALIAS_PTHREAD_MUTEXATTR_DESTROY
int pthread_mutexattr_destroy(pthread_mutexattr_t *) __DARWIN_ALIAS(pthread_mutexattr_destroy);
#else
int pthread_mutexattr_destroy(pthread_mutexattr_t *) LIBC_ALIAS(pthread_mutexattr_destroy);
#endif
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict, int * __restrict);
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict, int * __restrict);
int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict, int * __restrict);
int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict, int * __restrict);
int pthread_mutexattr_init(pthread_mutexattr_t *);
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int );
int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
int pthread_once(pthread_once_t *, void (*)(void));
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_DESTROY
int pthread_rwlock_destroy(pthread_rwlock_t * ) __DARWIN_ALIAS(pthread_rwlock_destroy);
#else
int pthread_rwlock_destroy(pthread_rwlock_t * ) LIBC_ALIAS(pthread_rwlock_destroy);
#endif
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_INIT
int pthread_rwlock_init(pthread_rwlock_t * __restrict, const pthread_rwlockattr_t * __restrict) __DARWIN_ALIAS(pthread_rwlock_init);
#else
int pthread_rwlock_init(pthread_rwlock_t * __restrict, const pthread_rwlockattr_t * __restrict) LIBC_ALIAS(pthread_rwlock_init);
#endif
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_RDLOCK
int pthread_rwlock_rdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_rdlock);
#else
int pthread_rwlock_rdlock(pthread_rwlock_t *) LIBC_ALIAS(pthread_rwlock_rdlock);
#endif
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_TRYRDLOCK
int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_tryrdlock);
#else
int pthread_rwlock_tryrdlock(pthread_rwlock_t *) LIBC_ALIAS(pthread_rwlock_tryrdlock);
#endif
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_TRYWRLOCK
int pthread_rwlock_trywrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_trywrlock);
#else
int pthread_rwlock_trywrlock(pthread_rwlock_t *) LIBC_ALIAS(pthread_rwlock_trywrlock);
#endif
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_WRLOCK
int pthread_rwlock_wrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_wrlock);
#else
int pthread_rwlock_wrlock(pthread_rwlock_t *) LIBC_ALIAS(pthread_rwlock_wrlock);
#endif
#ifndef LIBC_ALIAS_PTHREAD_RWLOCK_UNLOCK
int pthread_rwlock_unlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_unlock);
#else
int pthread_rwlock_unlock(pthread_rwlock_t *) LIBC_ALIAS(pthread_rwlock_unlock);
#endif
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict,
int * __restrict);
int pthread_rwlockattr_init(pthread_rwlockattr_t *);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *,
int );
pthread_t pthread_self(void);
#ifndef LIBC_ALIAS_PTHREAD_SETCANCELSTATE
int pthread_setcancelstate(int , int *) __DARWIN_ALIAS(pthread_setcancelstate);
#else
int pthread_setcancelstate(int , int *) LIBC_ALIAS(pthread_setcancelstate);
#endif
#ifndef LIBC_ALIAS_PTHREAD_SETCANCELTYPE
int pthread_setcanceltype(int , int *) __DARWIN_ALIAS(pthread_setcanceltype);
#else
int pthread_setcanceltype(int , int *) LIBC_ALIAS(pthread_setcanceltype);
#endif
int pthread_setconcurrency(int);
int pthread_setschedparam(pthread_t ,
int ,
const struct sched_param *);
int pthread_setspecific(pthread_key_t ,
const void *);
void pthread_testcancel(void) __DARWIN_ALIAS(pthread_testcancel);
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
int pthread_is_threaded_np(void);
int pthread_threadid_np(pthread_t,__uint64_t*) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
int pthread_rwlock_longrdlock_np(pthread_rwlock_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_downgrade_np(pthread_rwlock_t *);
int pthread_rwlock_upgrade_np(pthread_rwlock_t *);
int pthread_rwlock_tryupgrade_np(pthread_rwlock_t *);
int pthread_rwlock_held_np(pthread_rwlock_t *);
int pthread_rwlock_rdheld_np(pthread_rwlock_t *);
int pthread_rwlock_wrheld_np(pthread_rwlock_t *);
int pthread_getname_np(pthread_t,char*,size_t) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
int pthread_setname_np(const char*) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
int pthread_main_np(void);
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void * pthread_get_stackaddr_np(pthread_t);
int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t);
int pthread_cond_timedwait_relative_np(pthread_cond_t *,
pthread_mutex_t *,
const struct timespec *);
int pthread_create_suspended_np(pthread_t *,
const pthread_attr_t *,
void *(*)(void *),
void *);
int pthread_kill(pthread_t, int);
pthread_t pthread_from_mach_thread_np(mach_port_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
#ifndef LIBC_ALIAS_PTHREAD_SIGMASK
int pthread_sigmask(int, const sigset_t *, sigset_t *) __DARWIN_ALIAS(pthread_sigmask);
#else
int pthread_sigmask(int, const sigset_t *, sigset_t *) LIBC_ALIAS(pthread_sigmask);
#endif
void pthread_yield_np(void);
#endif
__END_DECLS
#endif