32 #ifndef SCHEDULER_LOCKS_H
33 #define SCHEDULER_LOCKS_H
41 #define LOCKRET(func) do { \
43 if ( (err=(func)) != 0) \
44 ods_log_error("%s at %d could not " #func ": %s", \
45 __FILE__, __LINE__, strerror(err)); \
48 #if defined(HAVE_PTHREAD)
55 typedef pthread_cond_t cond_basic_type;
58 #define lock_basic_init(lock) LOCKRET(pthread_mutex_init(lock, NULL))
59 #define lock_basic_destroy(lock) LOCKRET(pthread_mutex_destroy(lock))
60 #define lock_basic_lock(lock) LOCKRET(pthread_mutex_lock(lock))
61 #define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
64 #define lock_basic_set(cond) LOCKRET(pthread_cond_init(cond, NULL))
65 #define lock_basic_sleep(cond, lock, sleep) LOCKRET(ods_thread_wait(cond, lock, sleep))
66 #define lock_basic_alarm(cond) LOCKRET(pthread_cond_signal(cond))
67 #define lock_basic_broadcast(cond) LOCKRET(pthread_cond_broadcast(cond))
68 #define lock_basic_off(cond) LOCKRET(pthread_cond_destroy(cond))
70 int ods_thread_wait(cond_basic_type* cond,
lock_basic_type* lock, time_t wait);
75 #define ods_thread_create(thr, func, arg) LOCKRET(pthread_create(thr, NULL, func, arg))
76 #define ods_thread_detach(thr) LOCKRET(pthread_detach(thr))
77 #define ods_thread_self() pthread_self()
78 #define ods_thread_join(thr) LOCKRET(pthread_join(thr, NULL))
79 #define ods_thread_kill(thr, sig) LOCKRET(pthread_kill(thr, sig))
80 int ods_thread_wait(cond_basic_type* cond,
lock_basic_type* lock, time_t wait);
86 #define PTHREADS_DISABLED 1
89 #define lock_basic_init(lock)
90 #define lock_basic_destroy(lock)
91 #define lock_basic_lock(lock)
92 #define lock_basic_unlock(lock)
94 #define lock_basic_set(cond)
95 #define lock_basic_sleep(cond, lock, sleep)
96 #define lock_basic_alarm(cond)
97 #define lock_basic_broadcast(cond)
98 #define lock_basic_off(cond)
101 #define ods_thread_create(thr, func, arg) ods_thr_fork_create(thr, func, arg)
102 #define ods_thread_detach(thr)
103 #define ods_thread_self() getpid()
104 #define ods_thread_join(thr) ods_thr_fork_wait(thr)
void ods_thread_blocksigs(void)
void ods_thr_fork_create(ods_thread_type *thr, void *(*func)(void *), void *arg)
void ods_thr_fork_wait(ods_thread_type thread)