From feda786fecdae0c2851312f16adb3b91e477e9f7 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 28 Oct 2004 05:40:00 +0000 Subject: [PATCH] * k5-thread.h (return_after_yield, k5_mutex_lock) [__GNUC__]: Add macro versions so debugging line numbers will be useful. (DEBUG_THREADS_SLOW): Don't define. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16842 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/ChangeLog | 6 ++++++ src/include/k5-thread.h | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 9be4bbbf41..f3e2ae9e3f 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,9 @@ +2004-10-28 Ken Raeburn + + * k5-thread.h (return_after_yield, k5_mutex_lock) [__GNUC__]: Add + macro versions so debugging line numbers will be useful. + (DEBUG_THREADS_SLOW): Don't define. + 2004-10-05 Ken Raeburn * fake-addrinfo.h (AI_ADDRCONFIG, AI_V4MAPPED, AI_ALL): If not diff --git a/src/include/k5-thread.h b/src/include/k5-thread.h index 5d13093102..5fecf08275 100644 --- a/src/include/k5-thread.h +++ b/src/include/k5-thread.h @@ -139,7 +139,7 @@ #define DEBUG_THREADS #define DEBUG_THREADS_LOC -#define DEBUG_THREADS_SLOW /* permit debugging stuff that'll slow things down */ +#undef DEBUG_THREADS_SLOW /* debugging stuff that'll slow things down? */ #undef DEBUG_THREADS_STATS #include @@ -464,11 +464,20 @@ static inline void k5_pthread_assert_locked(pthread_mutex_t *m) { } the invoking site via a macro; once it returns, the inline function is called (with messed-up line-number info for gdb hopefully localized to just that call). */ +#ifdef __GNUC__ +#define return_after_yield(R) \ + __extension__ ({ \ + int _r = (R); \ + MAYBE_SCHED_YIELD(); \ + _r; \ + }) +#else static inline int return_after_yield(int r) { MAYBE_SCHED_YIELD(); return r; } +#endif #ifdef USE_PTHREAD_LOCK_ONLY_IF_LOADED @@ -607,6 +616,16 @@ static inline int k5_mutex_finish_init_1(k5_mutex_t *m, k5_debug_loc l) (k5_os_mutex_assert_unlocked(&(M)->os), \ (M)->loc_last = K5_DEBUG_LOC, \ k5_os_mutex_destroy(&(M)->os)) +#ifdef __GNUC__ +#define k5_mutex_lock(M) \ + __extension__ ({ \ + int _err = 0; \ + k5_mutex_t *_m = (M); \ + _err = k5_os_mutex_lock(&_m->os); \ + if (_err == 0) _m->loc_last = K5_DEBUG_LOC; \ + _err; \ + }) +#else static inline int k5_mutex_lock_1(k5_mutex_t *m, k5_debug_loc l) { int err = 0; @@ -617,6 +636,7 @@ static inline int k5_mutex_lock_1(k5_mutex_t *m, k5_debug_loc l) return err; } #define k5_mutex_lock(M) k5_mutex_lock_1(M, K5_DEBUG_LOC) +#endif static inline int k5_mutex_unlock_1(k5_mutex_t *m, k5_debug_loc l) { int err = 0; -- 2.47.3