diff options
Diffstat (limited to 'include/libimobiledevice-glue/thread.h')
-rw-r--r-- | include/libimobiledevice-glue/thread.h | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/include/libimobiledevice-glue/thread.h b/include/libimobiledevice-glue/thread.h index 2aadc6e..76646b8 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> +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} @@ -53,13 +68,13 @@ typedef pthread_once_t thread_once_t; 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 #undef HAVE_THREAD_CLEANUP @@ -71,17 +86,17 @@ 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); -void thread_once(thread_once_t *once_control, void (*init_routine)(void)); +LIMD_GLUE_API void thread_once(thread_once_t *once_control, void (*init_routine)(void)); -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); +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); #endif |