Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEBUG switch to control defines #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ QUIET =
SAY =
endif

ifeq ($(DEBUG), "pedantic")
$(eval CFLAGS_$(1) = $(CFLAGS_$(1)) -DDEBUG_PEDANTIC)
else ifeq ($(DEBUG), "none")
$(eval CFLAGS_$(1) = $(CFLAGS_$(1)) -DNDEBUG)
endif

# Do not override this here! Override this in localconfig.mk.
ifeq ($(shell uname -s),Darwin)
PEBBLE_TOOLCHAIN_PATH ?= /usr/local/Cellar/pebble-toolchain/2.0/arm-cs-tools/bin
Expand Down
12 changes: 11 additions & 1 deletion lib/minilib/qalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
#include <debug.h>

/* XXX: when we have debug/release builds, we should have this only in debug builds */
#ifndef NDEBUG

#define HEAP_INTEGRITY
//#define HEAP_PARANOID

#ifdef DEBUG_PEDANTIC
#define HEAP_PARANOID
#endif

#endif

#define MINBSZ 4

Expand Down Expand Up @@ -123,8 +130,11 @@ void qfree(qarena_t *arena, void *ptr) {
#endif

BLK_FREE(blk);

#ifdef HEAP_INTEGRITY
blk->cookie0 = BLK_COOKIE(arena, blk);
blk->cookie1 = ~BLK_COOKIE(arena, blk);
#endif
qjoin(arena);
}

Expand Down