diff lwasm/debug.c @ 338:5d401d1eb3e9

Allow disabling debugging messages. Add test for LWASM_NODEBUG symbol to disable compiling the actual debug message handling code. Also, prevent building the debug message arguments if the debug level is not going to display the message anyway. This comes at the possible expense of larger code due to wrapping the debug_mesage() function in a macro that tests the debug level directly. This should prevent calling expensive things like building a dump of an expression when it is not required.
author William Astle <lost@l-w.ca>
date Tue, 05 Aug 2014 22:04:23 -0600
parents 3132b1742eca
children
line wrap: on
line diff
--- a/lwasm/debug.c	Sat Aug 02 10:08:01 2014 -0600
+++ b/lwasm/debug.c	Tue Aug 05 22:04:23 2014 -0600
@@ -19,6 +19,8 @@
 this program. If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifndef LWASM_NODEBUG
+
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
@@ -72,7 +74,7 @@
 	}
 }
 
-void debug_message(asmstate_t *as, int level, const char *fmt, ...)
+void real_debug_message(asmstate_t *as, int level, const char *fmt, ...)
 {
 	va_list args;
 
@@ -90,3 +92,5 @@
 
 	va_end(args);
 }
+
+#endif