From 298987058078bf4f7c8454a405aea6506a79dbd6 Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Sat, 24 Oct 2020 13:14:42 -0700 Subject: [PATCH] ASSERT_MAIN_THREAD() cleanups. --- CMakeLists.txt | 3 ++- src/musikcore/audio/Buffer.cpp | 6 ------ src/musikcube/cursespp/Window.cpp | 18 +++++++----------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ee96291d..cf384a848 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,8 @@ include(CheckAtomic) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wno-unused-result -Wno-deprecated-declarations") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -frtti -fexceptions") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g -frtti -fexceptions") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG") # enable for additional memory checking with fsanitize # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -fsanitize=address,undefined") diff --git a/src/musikcore/audio/Buffer.cpp b/src/musikcore/audio/Buffer.cpp index 62c380c9b..91ccb8f75 100644 --- a/src/musikcore/audio/Buffer.cpp +++ b/src/musikcore/audio/Buffer.cpp @@ -36,12 +36,6 @@ #include -#define DEBUG 0 - -#if DEBUG > 0 -#include -#endif - #ifdef WIN32 #define CopyFloat(dst, src, num) CopyMemory(dst, src, (num) * sizeof(float)) #else diff --git a/src/musikcube/cursespp/Window.cpp b/src/musikcube/cursespp/Window.cpp index 6ab7b0c65..f8137e0c6 100755 --- a/src/musikcube/cursespp/Window.cpp +++ b/src/musikcube/cursespp/Window.cpp @@ -59,20 +59,16 @@ static Window* focused = nullptr; static MessageQueue messageQueue; static std::shared_ptr keys; -#ifndef WIN32 - #if DEBUG - static int64_t mainThreadId = reinterpret_cast(pthread_self()); - #define ASSERT_MAIN_THREAD() assert(reinterpret_cast(pthread_self()) == mainThreadId); - #else - #define ASSERT_MAIN_THREAD() - #endif -#else - #if DEBUG - #define ASSERT_MAIN_THREAD() - #else +#ifdef DEBUG + #ifdef WIN32 static DWORD mainThreadId = GetCurrentThreadId(); #define ASSERT_MAIN_THREAD() assert(GetCurrentThreadId() == mainThreadId); + #else + static pthread_t mainThreadId = pthread_self(); + #define ASSERT_MAIN_THREAD() assert(pthread_self() == mainThreadId); #endif +#else + #define ASSERT_MAIN_THREAD() #endif const int Window::kLastReservedMessageId = INT_MAX;