diff --git a/apps/shared/expiring_pointer.h b/apps/shared/expiring_pointer.h index 7184aab50..4dd7dd06b 100644 --- a/apps/shared/expiring_pointer.h +++ b/apps/shared/expiring_pointer.h @@ -11,31 +11,31 @@ class ExpiringPointer { friend class ExpiringPointer; public: ExpiringPointer(T * rawPointer) : m_rawPointer(rawPointer) { -#if DEBUG +#ifndef NDEBUG s_global = rawPointer; #endif } T * pointer() { return m_rawPointer; } T *operator->() { -#if DEBUG +#ifndef NDEBUG assert(m_rawPointer != nullptr && m_rawPointer == s_global); #endif return m_rawPointer; } T &operator*() { -#if DEBUG +#ifndef NDEBUG assert(m_rawPointer != nullptr && m_rawPointer == s_global); #endif return *m_rawPointer; } private: -#if DEBUG +#ifndef NDEBUG static T * s_global; #endif T * m_rawPointer; }; -#if DEBUG +#ifndef NDEBUG template T * ExpiringPointer::s_global = nullptr; #endif diff --git a/apps/solver/test/equation_store.cpp b/apps/solver/test/equation_store.cpp index 786d35eeb..24063863e 100644 --- a/apps/solver/test/equation_store.cpp +++ b/apps/solver/test/equation_store.cpp @@ -14,7 +14,7 @@ namespace Solver { void addEquationWithText(EquationStore * equationStore, const char * text, Context * context) { Ion::Storage::Record::ErrorStatus err = equationStore->addEmptyModel(); quiz_assert_print_if_failure(err == Ion::Storage::Record::ErrorStatus::None, text); - (void) err; // Silence warning in DEBUG=0 + (void) err; // Silence warning in release mode Ion::Storage::Record record = equationStore->recordAtIndex(equationStore->numberOfModels()-1); Shared::ExpiringPointer model = equationStore->modelForRecord(record); model->setContent(text, context); diff --git a/build/defaults.mak b/build/defaults.mak index 628550f3d..237a9a6da 100644 --- a/build/defaults.mak +++ b/build/defaults.mak @@ -2,7 +2,6 @@ HOSTCC = gcc HOSTCXX = g++ PYTHON = python3 -SFLAGS = -DDEBUG=$(DEBUG) SFLAGS += -DEPSILON_GETOPT=$(EPSILON_GETOPT) SFLAGS += -DEPSILON_TELEMETRY=$(EPSILON_TELEMETRY) SFLAGS += -DESCHER_LOG_EVENTS_BINARY=$(ESCHER_LOG_EVENTS_BINARY) @@ -16,6 +15,7 @@ ifeq ($(DEBUG),1) SFLAGS += -O0 -g else SFLAGS += -Os +SFLAGS += -DNDEBUG endif ifeq ($(ASAN),1) diff --git a/build/platform.blackbox.mak b/build/platform.blackbox.mak index 244c172ad..235feb87a 100644 --- a/build/platform.blackbox.mak +++ b/build/platform.blackbox.mak @@ -1,9 +1,4 @@ TOOLCHAIN ?= host-gcc USE_LIBA ?= 0 ION_KEYBOARD_LAYOUT = layout_B2 -EXE = bin - -ifeq ($(DEBUG),1) -else -SFLAGS += -DNDEBUG -endif +EXE = bin \ No newline at end of file diff --git a/build/platform.simulator.mak b/build/platform.simulator.mak index c6a904e30..e25beb0b8 100644 --- a/build/platform.simulator.mak +++ b/build/platform.simulator.mak @@ -17,4 +17,4 @@ SFLAGS += -DEPSILON_SIMULATOR_HAS_LIBPNG=$(EPSILON_SIMULATOR_HAS_LIBPNG) ifeq ($(EPSILON_SIMULATOR_HAS_LIBPNG),1) SFLAGS += `libpng-config --cflags` LDFLAGS += `libpng-config --ldflags` -endif +endif \ No newline at end of file diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index a20873e44..fa7db1e3f 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -18,7 +18,7 @@ public: constexpr Event(int i) : m_id(i){} // TODO: Assert here that i>=0 && i<255 constexpr explicit operator uint8_t() const { return m_id; } -#if DEBUG +#ifndef NDEBUG const char * name() const; #endif Event(Keyboard::Key key, bool shift, bool alpha, bool lock); diff --git a/ion/include/ion/keyboard/layout_B2/layout_events.h b/ion/include/ion/keyboard/layout_B2/layout_events.h index 0ad8a8228..d0621d3d6 100644 --- a/ion/include/ion/keyboard/layout_B2/layout_events.h +++ b/ion/include/ion/keyboard/layout_B2/layout_events.h @@ -51,7 +51,7 @@ static constexpr EventData s_dataForEvent[4*Event::PageSize] = { U(), U(), U(), U(), U(), U(), }; -#if DEBUG +#ifndef NDEBUG static constexpr const char * s_nameForEvent[255] = { // Plain diff --git a/ion/include/ion/keyboard/layout_B3/layout_events.h b/ion/include/ion/keyboard/layout_B3/layout_events.h index 5ef49875f..0bdd59e56 100644 --- a/ion/include/ion/keyboard/layout_B3/layout_events.h +++ b/ion/include/ion/keyboard/layout_B3/layout_events.h @@ -51,7 +51,7 @@ static constexpr EventData s_dataForEvent[4*Event::PageSize] = { U(), U(), U(), U(), U(), U(), }; -#if DEBUG +#ifndef NDEBUG static constexpr const char * s_nameForEvent[255] = { // Plain diff --git a/ion/src/blackbox/events.cpp b/ion/src/blackbox/events.cpp index 1c9f730f3..6dd8cde71 100644 --- a/ion/src/blackbox/events.cpp +++ b/ion/src/blackbox/events.cpp @@ -25,7 +25,7 @@ Event getEvent(int * timeout) { char filename[32]; sprintf(filename, "event%d.png", sEventCount); Ion::Display::Blackbox::writeFrameBufferToFile(filename); -#if DEBUG +#ifndef NDEBUG printf("Event %d is %s\n", sEventCount, event.name()); #endif } diff --git a/ion/src/device/shared/boot/rt0.cpp b/ion/src/device/shared/boot/rt0.cpp index 45a003f40..38ad5e9e6 100644 --- a/ion/src/device/shared/boot/rt0.cpp +++ b/ion/src/device/shared/boot/rt0.cpp @@ -19,11 +19,11 @@ extern "C" { } void __attribute__((noinline)) abort() { -#if DEBUG +#ifdef NDEBUG + Ion::Device::Reset::core(); +#else while (1) { } -#else - Ion::Device::Reset::core(); #endif } diff --git a/ion/src/shared/tools/Makefile b/ion/src/shared/tools/Makefile index 081339af1..b9976d268 100644 --- a/ion/src/shared/tools/Makefile +++ b/ion/src/shared/tools/Makefile @@ -1,3 +1,3 @@ $(BUILD_DIR)/ion/src/shared/tools/event_%: ion/src/shared/tools/event_%.cpp ion/src/shared/events.cpp @echo "HOSTCXX $@" - @$(HOSTCXX) -std=c++11 -Iion/include -DDEBUG=1 $^ -o $@ + @$(HOSTCXX) -std=c++11 -Iion/include $^ -o $@ diff --git a/ion/src/simulator/shared/events_stdin.cpp b/ion/src/simulator/shared/events_stdin.cpp index 4aaa96093..053118b23 100644 --- a/ion/src/simulator/shared/events_stdin.cpp +++ b/ion/src/simulator/shared/events_stdin.cpp @@ -34,7 +34,7 @@ Event getPlatformEvent() { char filename[32]; sprintf(filename, "event%d.png", sEventCount); Ion::Simulator::Framebuffer::writeToFile(filename); -#if DEBUG +#ifndef NDEBUG printf("Event %d is %s\n", sEventCount, event.name()); #endif } diff --git a/ion/src/simulator/shared/main_headless.cpp b/ion/src/simulator/shared/main_headless.cpp index 0f1fee2de..15cf095d6 100644 --- a/ion/src/simulator/shared/main_headless.cpp +++ b/ion/src/simulator/shared/main_headless.cpp @@ -14,10 +14,10 @@ #endif constexpr int kHeapSize = 131072; -#if DEBUG -constexpr int kStackSize = 32768*2; // In DEBUG mode, we increase the stack to be able to pass the tests -#else +#ifdef NDEBUG constexpr int kStackSize = 32768; +#else +constexpr int kStackSize = 32768*2; // In DEBUG mode, we increase the stack to be able to pass the tests #endif char heap[kHeapSize]; diff --git a/liba/include/assert.h b/liba/include/assert.h index e9d717ab9..ccbf4d8a3 100644 --- a/liba/include/assert.h +++ b/liba/include/assert.h @@ -3,10 +3,10 @@ #include "private/macros.h" -#if DEBUG -#define assert(e) ((void) ((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__))) -#else +#ifdef NDEBUG #define assert(e) ((void)0) +#else +#define assert(e) ((void) ((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__))) #endif LIBA_BEGIN_DECLS