diff options
Diffstat (limited to 'include/libimobiledevice-glue/thread.h')
-rw-r--r-- | include/libimobiledevice-glue/thread.h | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/include/libimobiledevice-glue/thread.h b/include/libimobiledevice-glue/thread.h index 2aadc6e..d04dae7 100644 --- a/include/libimobiledevice-glue/thread.h +++ b/include/libimobiledevice-glue/thread.h @@ -23,16 +23,31 @@ #define __THREAD_H #include <stddef.h> +#include <libimobiledevice-glue/glue.h> -#ifdef WIN32 -#include <windows.h> +#ifdef _WIN32 +typedef void* HANDLE; typedef HANDLE THREAD_T; -typedef CRITICAL_SECTION mutex_t; +#pragma pack(push, 8) +struct _CRITICAL_SECTION_ST { + void* DebugInfo; + long LockCount; + long RecursionCount; + HANDLE OwningThread; + HANDLE LockSemaphore; +#if defined(_WIN64) + unsigned __int64 SpinCount; +#else + unsigned long SpinCount; +#endif +}; +#pragma pack(pop) +typedef struct _CRITICAL_SECTION_ST mutex_t; typedef struct { HANDLE sem; } cond_t; typedef volatile struct { - LONG lock; + long lock; int state; } thread_once_t; #define THREAD_ONCE_INIT {0, 0} @@ -51,17 +66,21 @@ typedef pthread_once_t thread_once_t; #define THREAD_T_NULL (THREAD_T)NULL #endif +#ifdef __cplusplus +extern "C" { +#endif + typedef void* (*thread_func_t)(void* data); -int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data); -void thread_detach(THREAD_T thread); -void thread_free(THREAD_T thread); -int thread_join(THREAD_T thread); -int thread_alive(THREAD_T thread); +LIMD_GLUE_API int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data); +LIMD_GLUE_API void thread_detach(THREAD_T thread); +LIMD_GLUE_API void thread_free(THREAD_T thread); +LIMD_GLUE_API int thread_join(THREAD_T thread); +LIMD_GLUE_API int thread_alive(THREAD_T thread); -int thread_cancel(THREAD_T thread); +LIMD_GLUE_API int thread_cancel(THREAD_T thread); -#ifdef WIN32 +#ifdef _WIN32 #undef HAVE_THREAD_CLEANUP #else #ifdef HAVE_PTHREAD_CANCEL @@ -71,17 +90,21 @@ int thread_cancel(THREAD_T thread); #endif #endif -void mutex_init(mutex_t* mutex); -void mutex_destroy(mutex_t* mutex); -void mutex_lock(mutex_t* mutex); -void mutex_unlock(mutex_t* mutex); +LIMD_GLUE_API void mutex_init(mutex_t* mutex); +LIMD_GLUE_API void mutex_destroy(mutex_t* mutex); +LIMD_GLUE_API void mutex_lock(mutex_t* mutex); +LIMD_GLUE_API void mutex_unlock(mutex_t* mutex); + +LIMD_GLUE_API void thread_once(thread_once_t *once_control, void (*init_routine)(void)); -void thread_once(thread_once_t *once_control, void (*init_routine)(void)); +LIMD_GLUE_API void cond_init(cond_t* cond); +LIMD_GLUE_API void cond_destroy(cond_t* cond); +LIMD_GLUE_API int cond_signal(cond_t* cond); +LIMD_GLUE_API int cond_wait(cond_t* cond, mutex_t* mutex); +LIMD_GLUE_API int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms); -void cond_init(cond_t* cond); -void cond_destroy(cond_t* cond); -int cond_signal(cond_t* cond); -int cond_wait(cond_t* cond, mutex_t* mutex); -int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms); +#ifdef __cplusplus +} +#endif #endif |