18 #error "orconfig.h didn't define WINVER"
21 #error "orconfig.h didn't define _WIN32_WINNT"
24 #error "winver too low"
26 #if _WIN32_WINNT < 0x0600
27 #error "winver too low"
52 rv = (int)_beginthread(func, 0, data);
75 return (
unsigned long)GetCurrentThreadId();
81 InitializeConditionVariable(&cond->cond);
93 WakeConditionVariable(&cond->cond);
98 WakeAllConditionVariable(&cond->cond);
104 threadlocal->index = TlsAlloc();
105 return (threadlocal->index == TLS_OUT_OF_INDEXES) ? -1 : 0;
111 TlsFree(threadlocal->index);
118 void *value = TlsGetValue(threadlocal->index);
120 DWORD err = GetLastError();
121 if (err != ERROR_SUCCESS) {
122 char *msg = format_win32_error(err);
123 log_err(
LD_GENERAL,
"Error retrieving thread-local value: %s", msg);
134 BOOL ok = TlsSetValue(threadlocal->index, value);
136 DWORD err = GetLastError();
137 char *msg = format_win32_error(err);
138 log_err(
LD_GENERAL,
"Error adjusting thread-local value: %s", msg);
151 SRWLOCK *lock = &lock_->mutex;
154 ms = tv->tv_sec*1000 + (tv->tv_usec+999)/1000;
157 BOOL ok = SleepConditionVariableSRW(&cond->cond, lock, ms, 0);
159 DWORD err = GetLastError();
160 if (err == ERROR_TIMEOUT) {
163 char *msg = format_win32_error(err);
164 log_err(
LD_GENERAL,
"Error waiting for condition variable: %s", msg);
void tor_cond_signal_all(tor_cond_t *cond)
void * tor_threadlocal_get(tor_threadlocal_t *threadlocal)
int tor_cond_init(tor_cond_t *cond)
int spawn_func(void(*func)(void *), void *data)
void tor_threadlocal_destroy(tor_threadlocal_t *threadlocal)
void tor_threadlocal_set(tor_threadlocal_t *threadlocal, void *value)
void tor_threads_init(void)
void tor_cond_uninit(tor_cond_t *cond)
void tor_cond_signal_one(tor_cond_t *cond)
int tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex, const struct timeval *tv)
int tor_threadlocal_init(tor_threadlocal_t *threadlocal)
unsigned long tor_get_thread_id(void)
void set_main_thread(void)
Definitions for timing-related constants.
Macros to manage assertions, fatal and non-fatal.