From 23cb020493a4f93c3edf9395b71754855c3c1d22 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 27 Apr 2010 15:32:50 +0200 Subject: [PATCH] Fix thread flag code to compile with gnu99 --- src/tm-threads.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/tm-threads.h | 45 +++------------------------------------------ 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/tm-threads.c b/src/tm-threads.c index 713d4b0e1f..bbc8dadd12 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -76,6 +76,49 @@ typedef struct TmVarSlot_ { TmSlot *s; } TmVarSlot; +/** + * \brief Check if a thread flag is set + * + * \retval 1 flag is set + * \retval 0 flag is not set + */ +int TmThreadsCheckFlag(ThreadVars *tv, uint8_t flag) { + int r; + if (SCSpinLock(&(tv)->flags_spinlock) != 0) { + SCLogError(SC_ERR_SPINLOCK,"spin lock errno=%d",errno); + return 0; + } + r = (tv->flags & flag); + SCSpinUnlock(&tv->flags_spinlock); + return r; +} + +/** + * \brief Set a thread flag + */ +void TmThreadsSetFlag(ThreadVars *tv, uint8_t flag) { + if (SCSpinLock(&tv->flags_spinlock) != 0) { + SCLogError(SC_ERR_SPINLOCK,"spin lock errno=%d",errno); + return; + } + + tv->flags |= flag; + SCSpinUnlock(&tv->flags_spinlock); +} + +/** + * \brief Unset a thread flag + */ +void TmThreadsUnsetFlag(ThreadVars *tv, uint8_t flag) { + if (SCSpinLock(&tv->flags_spinlock) != 0) { + SCLogError(SC_ERR_SPINLOCK,"spin lock errno=%d",errno); + return; + } + + tv->flags &= ~flag; + SCSpinUnlock(&tv->flags_spinlock); +} + /* 1 slot functions */ void *TmThreadsSlot1NoIn(void *td) { diff --git a/src/tm-threads.h b/src/tm-threads.h index fd5799de47..33274d67b2 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -44,49 +44,10 @@ void TmThreadCheckThreadState(void); TmEcode TmThreadWaitOnThreadInit(void); ThreadVars *TmThreadsGetCallingThread(void); -/** - * \brief Check if a thread flag is set - * - * \retval 1 flag is set - * \retval 0 flag is not set - */ -static inline int TmThreadsCheckFlag(ThreadVars *tv, uint8_t flag) { \ - int r; - if (SCSpinLock(&tv->flags_spinlock) != 0) { - SCLogError(SC_ERR_SPINLOCK,"spin lock errno=%d",errno); - return 0; - } +int TmThreadsCheckFlag(ThreadVars *, uint8_t); +void TmThreadsSetFlag(ThreadVars *, uint8_t); +void TmThreadsUnsetFlag(ThreadVars *, uint8_t); - r = (tv->flags & flag); - SCSpinUnlock(&tv->flags_spinlock); - return r; -} - -/** - * \brief Set a thread flag - */ -static inline void TmThreadsSetFlag(ThreadVars *tv, uint8_t flag) { - if (SCSpinLock(&tv->flags_spinlock) != 0) { - SCLogError(SC_ERR_SPINLOCK,"spin lock errno=%d",errno); - return; - } - - tv->flags |= flag; - SCSpinUnlock(&tv->flags_spinlock); -} - -/** - * \brief Unset a thread flag - */ -static inline void TmThreadsUnsetFlag(ThreadVars *tv, uint8_t flag) { - if (SCSpinLock(&tv->flags_spinlock) != 0) { - SCLogError(SC_ERR_SPINLOCK,"spin lock errno=%d",errno); - return; - } - - tv->flags &= ~flag; - SCSpinUnlock(&tv->flags_spinlock); -} #endif /* __TM_THREADS_H__ */