|
|
@@ -36,7 +36,11 @@
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
-#ifdef BADVPN_THREAD_SAFE
|
|
|
+#if !defined(BADVPN_THREAD_SAFE) || (BADVPN_THREAD_SAFE != 0 && BADVPN_THREAD_SAFE != 1)
|
|
|
+#error BADVPN_THREAD_SAFE is not defined or incorrect
|
|
|
+#endif
|
|
|
+
|
|
|
+#if BADVPN_THREAD_SAFE
|
|
|
#include <pthread.h>
|
|
|
#endif
|
|
|
|
|
|
@@ -83,7 +87,7 @@ static void DebugObjectGlobal_Finish (void);
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
extern DebugCounter debugobject_counter;
|
|
|
-#ifdef BADVPN_THREAD_SAFE
|
|
|
+#if BADVPN_THREAD_SAFE
|
|
|
extern pthread_mutex_t debugobject_mutex;
|
|
|
#endif
|
|
|
#endif
|
|
|
@@ -94,13 +98,13 @@ void DebugObject_Init (DebugObject *obj)
|
|
|
|
|
|
obj->c = DEBUGOBJECT_VALID;
|
|
|
|
|
|
- #ifdef BADVPN_THREAD_SAFE
|
|
|
+ #if BADVPN_THREAD_SAFE
|
|
|
ASSERT_FORCE(pthread_mutex_lock(&debugobject_mutex) == 0)
|
|
|
#endif
|
|
|
|
|
|
DebugCounter_Increment(&debugobject_counter);
|
|
|
|
|
|
- #ifdef BADVPN_THREAD_SAFE
|
|
|
+ #if BADVPN_THREAD_SAFE
|
|
|
ASSERT_FORCE(pthread_mutex_unlock(&debugobject_mutex) == 0)
|
|
|
#endif
|
|
|
|
|
|
@@ -115,13 +119,13 @@ void DebugObject_Free (DebugObject *obj)
|
|
|
|
|
|
obj->c = 0;
|
|
|
|
|
|
- #ifdef BADVPN_THREAD_SAFE
|
|
|
+ #if BADVPN_THREAD_SAFE
|
|
|
ASSERT_FORCE(pthread_mutex_lock(&debugobject_mutex) == 0)
|
|
|
#endif
|
|
|
|
|
|
DebugCounter_Decrement(&debugobject_counter);
|
|
|
|
|
|
- #ifdef BADVPN_THREAD_SAFE
|
|
|
+ #if BADVPN_THREAD_SAFE
|
|
|
ASSERT_FORCE(pthread_mutex_unlock(&debugobject_mutex) == 0)
|
|
|
#endif
|
|
|
|