git » libfiu » commit 2c0cea6

preload/posix: Add a POSIX_TRACE build flag

author Alberto Bertogli
2014-06-15 14:54:35 UTC
committer Alberto Bertogli
2014-06-15 14:54:35 UTC
parent 2d3c20e0d6a86d078f5354cd5eb9fc8412a98a56

preload/posix: Add a POSIX_TRACE build flag

To make it easier to turn tracing on and off in the posix profile, this patch
adds a build-time flag for it.

It's only useful for debugging.

preload/posix/Makefile +6 -1
preload/posix/codegen.h +1 -1

diff --git a/preload/posix/Makefile b/preload/posix/Makefile
index a05c93b..adc9b4b 100644
--- a/preload/posix/Makefile
+++ b/preload/posix/Makefile
@@ -12,6 +12,11 @@ ifdef PROFILE
 ALL_CFLAGS += -g -pg -fprofile-arcs -ftest-coverage
 endif
 
+ifdef POSIX_TRACE
+    ALL_CFLAGS += -DFIU_POSIX_TRACE=1
+endif
+
+
 # prefix for installing the binaries
 PREFIX=/usr/local
 
@@ -63,7 +68,7 @@ $(OBJS): build-flags
 
 # We define _GNU_SOURCE to get RTLD_NEXT if available; on non-GNU
 # platforms it should be harmless.
-codegen.o: codegen.c
+codegen.o: codegen.c build-flags
 	$(NICE_CC) $(ALL_CFLAGS) -D_GNU_SOURCE -c $< -o $@
 
 # some platforms do not have libdl, we only use it if available
diff --git a/preload/posix/codegen.h b/preload/posix/codegen.h
index efee7bc..2885da1 100644
--- a/preload/posix/codegen.h
+++ b/preload/posix/codegen.h
@@ -29,7 +29,7 @@ void *libc_symbol(const char *symbol);
 #endif
 
 /* Useful macros for recursion and debugging */
-#if 1
+#ifndef FIU_POSIX_TRACE
 	#define rec_inc() do { _fiu_called++; } while(0)
 	#define rec_dec() do { _fiu_called--; } while(0)
 	#define printd(...) do { } while(0)