27 #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX)
31 #include <freetds/pushvis.h>
34 #define TDS_RAW_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
38 pthread_mutex_lock(
mtx);
43 return pthread_mutex_trylock(
mtx);
48 pthread_mutex_unlock(
mtx);
53 return pthread_mutex_init(
mtx,
NULL);
58 pthread_mutex_destroy(
mtx);
66 return pthread_cond_destroy(cond);
70 return pthread_cond_signal(cond);
74 return pthread_cond_wait(cond,
mtx);
78 #define TDS_HAVE_MUTEX 1
82 typedef void *(*tds_thread_proc)(
void *arg);
83 #define TDS_THREAD_PROC_DECLARE(name, arg) \
88 return pthread_create(ret,
NULL,
proc, arg);
94 int ret = pthread_create(&
th,
NULL,
proc, arg);
102 return pthread_join(
th, ret);
107 return pthread_self();
112 return pthread_equal(
th, pthread_self());
115 #include <freetds/popvis.h>
117 #elif defined(_WIN32)
124 CRITICAL_SECTION crit;
127 #define TDS_RAW_MUTEX_INITIALIZER { NULL, 0 }
142 EnterCriticalSection(&(
mtx)->crit);
144 tds_win_mutex_lock(
mtx);
151 LeaveCriticalSection(&(
mtx)->crit);
157 DeleteCriticalSection(&(
mtx)->crit);
162 #define TDS_HAVE_MUTEX 1
165 typedef void *TDS_CONDITION_VARIABLE;
168 TDS_CONDITION_VARIABLE cv;
183 #define TDS_THREAD_PROC_DECLARE(name, arg) \
184 DWORD name(void *arg)
189 return *ret !=
NULL ? 0 : 11 ;
203 if (WaitForSingleObject(
th, INFINITE) == WAIT_OBJECT_0) {
205 if (ret && GetExitCodeThread(
th, &
r))
206 *ret = (
void*) (((
char*)0) +
r);
217 return GetCurrentThreadId();
222 return th == GetCurrentThreadId();
231 #define TDS_RAW_MUTEX_INITIALIZER {}
266 #define tds_raw_cond_signal(cond) \
267 FreeTDS_Condition_not_compiled
269 #define tds_raw_cond_wait(cond, mtx) \
270 FreeTDS_Condition_not_compiled
272 #define tds_raw_cond_timedwait(cond, mtx, timeout_sec) \
273 FreeTDS_Condition_not_compiled
279 typedef void *(*tds_thread_proc)(
void *arg);
280 #define TDS_THREAD_PROC_DECLARE(name, arg) \
281 void *name(void *arg)
283 #define tds_thread_create(ret, proc, arg) \
284 FreeTDS_Thread_not_compiled
286 #define tds_thread_create_detached(proc, arg) \
287 FreeTDS_Thread_not_compiled
289 #define tds_thread_join(th, ret) \
290 FreeTDS_Thread_not_compiled
305 #ifdef TDS_HAVE_MUTEX
306 # define tds_cond_init tds_raw_cond_init
307 # define tds_cond_destroy tds_raw_cond_destroy
308 # define tds_cond_signal tds_raw_cond_signal
309 # if !ENABLE_EXTRA_CHECKS
310 # define TDS_MUTEX_INITIALIZER TDS_RAW_MUTEX_INITIALIZER
311 # define tds_mutex tds_raw_mutex
312 # define tds_mutex_lock tds_raw_mutex_lock
313 # define tds_mutex_trylock tds_raw_mutex_trylock
314 # define tds_mutex_unlock tds_raw_mutex_unlock
315 # define tds_mutex_check_owned(mtx) do {} while(0)
316 # define tds_mutex_init tds_raw_mutex_init
317 # define tds_mutex_free tds_raw_mutex_free
318 # define tds_cond_wait tds_raw_cond_wait
319 # define tds_cond_timedwait tds_raw_cond_timedwait
330 # define TDS_MUTEX_INITIALIZER { TDS_RAW_MUTEX_INITIALIZER, 0 }
419 # define tds_mutex_free(x) do {} while (0)
420 # define tds_mutex_init(x) tds_mutex_noop()
421 # define tds_mutex_lock(x) tds_mutex_noop()
422 # define tds_mutex_trylock(x) tds_mutex_noop()
423 # define tds_mutex_unlock(x) do {} while (0)
#define tds_raw_cond_timedwait(cond, mtx, timeout_sec)
static tds_thread_id tds_thread_get_current_id(void)
#define tds_mutex_trylock(x)
#define tds_thread_create(ret, proc, arg)
static void tds_raw_mutex_free(tds_raw_mutex *mtx)
#define tds_mutex_free(x)
void *(* tds_thread_proc)(void *arg)
static int tds_raw_mutex_init(tds_raw_mutex *mtx)
#define tds_mutex_lock(x)
static int tds_thread_is_current(tds_thread_id th)
static void tds_raw_mutex_unlock(tds_raw_mutex *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)
static int tds_mutex_noop(void)
#define tds_mutex_unlock(x)
#define tds_thread_create_detached(proc, arg)
#define tds_raw_cond_wait(cond, mtx)
#define tds_mutex_init(x)
#define tds_thread_join(th, ret)
static int tds_raw_cond_init(tds_condition *cond)
#define tds_cond_timedwait
#define tds_mutex_check_owned(mtx)
#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