diff options
Diffstat (limited to 'include/my_pthread.h')
-rw-r--r-- | include/my_pthread.h | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h index 3a3f304dcff..0be821586a1 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -138,6 +138,7 @@ int pthread_cancel(pthread_t thread); #define pthread_mutex_destroy(A) (DeleteCriticalSection(A), 0) #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) + /* Dummy defines for easier code */ #define pthread_attr_setdetachstate(A,B) pthread_dummy(0) #define pthread_attr_setscope(A,B) @@ -313,7 +314,6 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); for calculating an absolute time at which pthread_cond_timedwait should timeout */ - #define set_timespec(ABSTIME,SEC) set_timespec_nsec((ABSTIME),(SEC)*1000000000ULL) #ifndef set_timespec_nsec @@ -418,24 +418,6 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp); #define MYF_NO_DEADLOCK_DETECTION 2 #ifdef SAFE_MUTEX -#undef pthread_mutex_init -#undef pthread_mutex_lock -#undef pthread_mutex_unlock -#undef pthread_mutex_destroy -#undef pthread_mutex_wait -#undef pthread_mutex_timedwait -#undef pthread_mutex_t -#undef pthread_cond_wait -#undef pthread_cond_timedwait -#undef pthread_mutex_trylock -#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),#A,__FILE__,__LINE__) -#define pthread_mutex_lock(A) safe_mutex_lock((A),0,__FILE__, __LINE__) -#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__) -#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__) -#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__) -#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) -#define pthread_mutex_trylock(A) safe_mutex_lock((A), MYF_TRY_LOCK, __FILE__, __LINE__) -#define pthread_mutex_t safe_mutex_t #define safe_mutex_assert_owner(mp) \ DBUG_ASSERT((mp)->count > 0 && \ pthread_equal(pthread_self(), (mp)->thread)) @@ -443,13 +425,22 @@ void safe_mutex_free_deadlock_data(safe_mutex_t *mp); DBUG_ASSERT(! (mp)->count || \ ! pthread_equal(pthread_self(), (mp)->thread)) #define safe_mutex_setflags(mp, F) do { (mp)->create_flags|= (F); } while (0) +#define my_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__) +#define my_cond_wait(A,B) safe_cond_wait((A), (B), __FILE__, __LINE__) #else -#define my_pthread_mutex_init(A,B,C,D) pthread_mutex_init((A),(B)) -#define safe_mutex_assert_owner(mp) do {} while(0) -#define safe_mutex_assert_not_owner(mp) do {} while(0) -#define safe_mutex_free_deadlock_data(mp) do {} while(0) + +#define safe_mutex_assert_owner(mp) do {} while (0) +#define safe_mutex_assert_not_owner(mp) do {} while (0) #define safe_mutex_setflags(mp, F) do {} while (0) -#endif /* SAFE_MUTEX */ + +#if defined(MY_PTHREAD_FASTMUTEX) +#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A), &(B)->mutex, (C)) +#define my_cond_wait(A,B) pthread_cond_wait((A), &(B)->mutex) +#else +#define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A),(B),(C)) +#define my_cond_wait(A,B) pthread_cond_wait((A), (B)) +#endif /* MY_PTHREAD_FASTMUTEX */ +#endif /* !SAFE_MUTEX */ #if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) typedef struct st_my_pthread_fastmutex_t @@ -464,24 +455,6 @@ int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp, const pthread_mutexattr_t *attr); int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp); -#undef pthread_mutex_init -#undef pthread_mutex_lock -#undef pthread_mutex_unlock -#undef pthread_mutex_destroy -#undef pthread_mutex_wait -#undef pthread_mutex_timedwait -#undef pthread_mutex_t -#undef pthread_cond_wait -#undef pthread_cond_timedwait -#undef pthread_mutex_trylock -#define pthread_mutex_init(A,B) my_pthread_fastmutex_init((A),(B)) -#define pthread_mutex_lock(A) my_pthread_fastmutex_lock(A) -#define pthread_mutex_unlock(A) pthread_mutex_unlock(&(A)->mutex) -#define pthread_mutex_destroy(A) pthread_mutex_destroy(&(A)->mutex) -#define pthread_cond_wait(A,B) pthread_cond_wait((A),&(B)->mutex) -#define pthread_cond_timedwait(A,B,C) pthread_cond_timedwait((A),&(B)->mutex,(C)) -#define pthread_mutex_trylock(A) pthread_mutex_trylock(&(A)->mutex) -#define pthread_mutex_t my_pthread_fastmutex_t #endif /* defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) */ /* READ-WRITE thread locking */ |