#ifndef _TOOLKIT_WIN_HEADER_H_ #define _TOOLKIT_WIN_HEADER_H_ #ifdef _WIN32 #ifdef __cplusplus extern "C" { #endif typedef struct { DWORD tls_index; } toolkit_key_t; typedef CRITICAL_SECTION toolkit_mutex_t; typedef struct toolkit_once_s { unsigned char ran; HANDLE event; } toolkit_once_t; #define TOOLKIT_ONCE_INIT { 0, NULL } typedef HANDLE toolkit_thread_t; typedef struct { HMODULE handle; char* errmsg; } toolkit_lib_t; typedef HANDLE toolkit_sem_t; typedef int toolkit_pid_t; /* This condition variable implementation is based on the SetEvent solution * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html * We could not use the SignalObjectAndWait solution (section 3.4) because * it want the 2nd argument (type toolkit_mutex_t) of toolkit_cond_wait() and * toolkit_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. */ typedef union { CONDITION_VARIABLE cond_var; struct { unsigned int waiters_count; CRITICAL_SECTION waiters_count_lock; HANDLE signal_event; HANDLE broadcast_event; } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */ } toolkit_cond_t; typedef union { struct { unsigned int num_readers_; CRITICAL_SECTION num_readers_lock_; HANDLE write_semaphore_; } state_; /* TODO: remove me in v2.x. */ struct { SRWLOCK unused_; } unused1_; /* TODO: remove me in v2.x. */ struct { toolkit_mutex_t unused1_; toolkit_mutex_t unused2_; } unused2_; } toolkit_rwlock_t; typedef struct { unsigned int n; unsigned int count; toolkit_mutex_t mutex; toolkit_sem_t turnstile1; toolkit_sem_t turnstile2; } toolkit_barrier_t; int snprintf(char* buf, size_t len, const char* fmt, ...); #ifdef __cplusplus } // extern "C" { #endif #endif //_WIN32 #endif //_TOOLKIT_WIN_HEADER_H_