41 #include <sys/param.h>
45 #include "UpnpUniStd.h"
53 #if defined(BSD) && !defined(__GNU__)
54 #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
57 #if defined(PTHREAD_MUTEX_RECURSIVE) || defined(__DragonFly__)
61 #define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_NORMAL
62 #define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
63 #define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK
65 #define ITHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_FAST_NP
66 #define ITHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE_NP
67 #define ITHREAD_MUTEX_ERRORCHECK_NP PTHREAD_MUTEX_ERRORCHECK_NP
70 #define ITHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
71 #define ITHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
73 #define ITHREAD_CANCELED PTHREAD_CANCELED
75 #define ITHREAD_STACK_MIN PTHREAD_STACK_MIN
76 #define ITHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
77 #define ITHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
87 typedef pthread_t ithread_t;
97 typedef pthread_attr_t ithread_attr_t;
106 typedef void (*start_routine)(
void *arg);
116 typedef pthread_cond_t ithread_cond_t;
126 typedef pthread_mutexattr_t ithread_mutexattr_t;
136 typedef pthread_mutex_t ithread_mutex_t;
147 typedef pthread_condattr_t ithread_condattr_t;
158 typedef pthread_rwlockattr_t ithread_rwlockattr_t;
170 typedef pthread_rwlock_t ithread_rwlock_t;
173 typedef ithread_mutex_t ithread_rwlock_t;
187 static UPNP_INLINE int ithread_initialize_library(
void)
205 static UPNP_INLINE int ithread_cleanup_library(
void)
223 static UPNP_INLINE int ithread_initialize_thread(
void)
227 #if defined(_WIN32) && defined(PTW32_STATIC_LIB)
228 ret = !pthread_win32_thread_attach_np();
245 static UPNP_INLINE int ithread_cleanup_thread(
void)
249 #if defined(_WIN32) && defined(PTW32_STATIC_LIB)
250 ret = !pthread_win32_thread_detach_np();
270 #define ithread_mutexattr_init pthread_mutexattr_init
286 #define ithread_mutexattr_destroy pthread_mutexattr_destroy
307 #define ithread_mutexattr_setkind_np pthread_mutexattr_settype
308 #define ithread_mutexattr_settype pthread_mutexattr_settype
329 #define ithread_mutexattr_getkind_np pthread_mutexattr_gettype
330 #define ithread_mutexattr_gettype pthread_mutexattr_gettype
350 #define ithread_mutex_init pthread_mutex_init
367 #define ithread_mutex_lock pthread_mutex_lock
384 #define ithread_mutex_unlock pthread_mutex_unlock
403 #define ithread_mutex_destroy pthread_mutex_destroy
419 #define ithread_rwlockattr_init pthread_rwlockattr_init
436 #define ithread_rwlockattr_destroy pthread_rwlockattr_destroy
458 #define ithread_rwlockatttr_setpshared pthread_rwlockatttr_setpshared
480 #define ithread_rwlockatttr_getpshared pthread_rwlockatttr_getpshared
501 #define ithread_rwlock_init pthread_rwlock_init
504 #define ithread_rwlock_init ithread_mutex_init
522 #define ithread_rwlock_rdlock pthread_rwlock_rdlock
525 #define ithread_rwlock_rdlock ithread_mutex_lock
543 #define ithread_rwlock_wrlock pthread_rwlock_wrlock
546 #define ithread_rwlock_wrlock ithread_mutex_lock
565 #define ithread_rwlock_unlock pthread_rwlock_unlock
568 #define ithread_rwlock_unlock ithread_mutex_unlock
591 #define ithread_rwlock_destroy pthread_rwlock_destroy
594 #define ithread_rwlock_destroy ithread_mutex_destroy
610 #define ithread_cond_init pthread_cond_init
626 #define ithread_cond_signal pthread_cond_signal
642 #define ithread_cond_broadcast pthread_cond_broadcast
662 #define ithread_cond_wait pthread_cond_wait
685 #define ithread_cond_timedwait pthread_cond_timedwait
701 #define ithread_cond_destroy pthread_cond_destroy
715 #define ithread_attr_init pthread_attr_init
729 #define ithread_attr_destroy pthread_attr_destroy
745 #define ithread_attr_setstacksize pthread_attr_setstacksize
761 #define ithread_attr_setdetachstate pthread_attr_setdetachstate
780 #define ithread_create pthread_create
793 #define ithread_cancel pthread_cancel
805 #define ithread_exit pthread_exit
816 #define ithread_get_current_thread_id pthread_self
827 #define ithread_self pthread_self
840 #define ithread_detach pthread_detach
858 #define ithread_join pthread_join
874 #define isleep(x) Sleep((x)*1000)
893 #define imillisleep Sleep
895 #if _POSIX_C_SOURCE < 200809L
896 #define imillisleep(x) usleep(1000 * x)
898 #define imillisleep(x) \
900 const struct timespec req = { \
901 0, x * 1000 * 1000}; \
902 nanosleep(&req, NULL); \
907 #if !defined(PTHREAD_MUTEX_RECURSIVE) && !defined(__DragonFly__) && \
908 !defined(UPNP_USE_MSVCPP)
913 pthread_mutexattr_t *attr,
int kind);
Defines constants that for some reason are not defined on some systems.
#define UPNP_EXPORT_SPEC
Export functions on WIN32 DLLs.
Definition: UpnpGlobal.h:98
#define UPNP_INLINE
Declares an inline function.
Definition: UpnpGlobal.h:112