27 #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX)
29 #include <tds_sysdep_public.h>
34 #include <freetds/pushvis.h>
37 #define TDS_RAW_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
41 pthread_mutex_lock(
mtx);
46 return pthread_mutex_trylock(
mtx);
51 pthread_mutex_unlock(
mtx);
56 return pthread_mutex_init(
mtx,
NULL);
61 pthread_mutex_destroy(
mtx);
69 return pthread_cond_destroy(cond);
73 return pthread_cond_signal(cond);
77 return pthread_cond_wait(cond,
mtx);
81 #define TDS_HAVE_MUTEX 1
85 typedef void *(*tds_thread_proc)(
void *arg);
86 #define TDS_THREAD_PROC_DECLARE(name, arg) \
88 #define TDS_THREAD_RESULT(n) ((void*)(TDS_INTPTR)(n))
92 return pthread_create(ret,
NULL,
proc, arg);
98 int ret = pthread_create(&
th,
NULL,
proc, arg);
106 return pthread_join(
th, ret);
111 return pthread_self();
116 return pthread_equal(
th, pthread_self());
119 #include <freetds/popvis.h>
121 #elif defined(_WIN32)
128 #define ETIMEDOUT 138
137 CRITICAL_SECTION crit;
140 #define TDS_RAW_MUTEX_INITIALIZER { NULL, 0, 0 }
156 EnterCriticalSection(&
mtx->crit);
157 mtx->thread_id = GetCurrentThreadId();
159 tds_win_mutex_lock(
mtx);
168 LeaveCriticalSection(&
mtx->crit);
174 DeleteCriticalSection(&
mtx->crit);
179 #define TDS_HAVE_MUTEX 1
182 typedef void *TDS_CONDITION_VARIABLE;
185 TDS_CONDITION_VARIABLE cv;
200 #define TDS_THREAD_PROC_DECLARE(name, arg) \
201 DWORD WINAPI name(void *arg)
202 #define TDS_THREAD_RESULT(n) ((DWORD)(int)(n))
207 return *ret !=
NULL ? 0 : 11 ;
221 if (WaitForSingleObject(
th, INFINITE) == WAIT_OBJECT_0) {
224 if (!GetExitCodeThread(
th, &
r))
226 *ret = (
void*) (((
char*)0) +
r);
238 return GetCurrentThreadId();
243 return th == GetCurrentThreadId();
248 #include <tds_sysdep_public.h>
255 #define TDS_RAW_MUTEX_INITIALIZER {}
291 #define tds_raw_cond_signal(cond) \
292 FreeTDS_Condition_not_compiled
294 #define tds_raw_cond_wait(cond, mtx) \
295 FreeTDS_Condition_not_compiled
297 #define tds_raw_cond_timedwait(cond, mtx, timeout_sec) \
298 FreeTDS_Condition_not_compiled
305 typedef void *(*tds_thread_proc)(
void *arg);
306 #define TDS_THREAD_PROC_DECLARE(name, arg) \
307 void *name(void *arg)
308 #define TDS_THREAD_RESULT(n) ((void*)(TDS_INTPTR)(n))
310 #define tds_thread_create(ret, proc, arg) \
311 FreeTDS_Thread_not_compiled
313 #define tds_thread_create_detached(proc, arg) \
314 FreeTDS_Thread_not_compiled
316 #define tds_thread_join(th, ret) \
317 FreeTDS_Thread_not_compiled
331 # define tds_cond_init tds_raw_cond_init
332 # define tds_cond_destroy tds_raw_cond_destroy
333 # define tds_cond_signal tds_raw_cond_signal
334 # if !ENABLE_EXTRA_CHECKS || !defined(TDS_HAVE_MUTEX)
335 # define TDS_MUTEX_INITIALIZER TDS_RAW_MUTEX_INITIALIZER
336 # define tds_mutex tds_raw_mutex
337 # define tds_mutex_lock tds_raw_mutex_lock
338 # define tds_mutex_trylock tds_raw_mutex_trylock
339 # define tds_mutex_unlock tds_raw_mutex_unlock
340 # define tds_mutex_check_owned(mtx) do {} while(0)
341 # define tds_mutex_init tds_raw_mutex_init
342 # define tds_mutex_free tds_raw_mutex_free
343 # define tds_cond_wait tds_raw_cond_wait
344 # define tds_cond_timedwait tds_raw_cond_timedwait
355 # define TDS_MUTEX_INITIALIZER { TDS_RAW_MUTEX_INITIALIZER, 0 }
void *(* tds_thread_proc)(void *arg)
#define tds_mutex_trylock
#define tds_cond_timedwait
#define tds_raw_cond_timedwait(cond, mtx, timeout_sec)
static tds_thread_id tds_thread_get_current_id(void)
#define tds_thread_create(ret, proc, arg)
static void tds_raw_mutex_free(tds_raw_mutex *mtx)
static int tds_raw_mutex_init(tds_raw_mutex *mtx)
static int tds_thread_is_current(tds_thread_id th)
static void tds_raw_mutex_unlock(tds_raw_mutex *mtx)
#define tds_mutex_check_owned(mtx)
static void tds_raw_mutex_lock(tds_raw_mutex *mtx)
static int tds_raw_mutex_trylock(tds_raw_mutex *mtx)
#define tds_raw_cond_signal(cond)
static int tds_raw_cond_destroy(tds_condition *cond)
#define tds_thread_create_detached(proc, arg)
#define tds_raw_cond_wait(cond, mtx)
#define tds_thread_join(th, ret)
static int tds_raw_cond_init(tds_condition *cond)
#define HANDLE
An abstraction for a file handle.
unsigned int
A callback function used to compare two keys in a database.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n th
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
struct ptw32_mcs_node_t_ ** lock