From: Oliver Kurth Date: Sun, 21 Jul 2019 00:15:19 +0000 (-0700) Subject: Make DEBUG_ONLY work with toplevel commas (Change part 3) X-Git-Tag: stable-11.1.0~311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4896361913c59b59d39212c02b8cd1421734efa;p=thirdparty%2Fopen-vm-tools.git Make DEBUG_ONLY work with toplevel commas (Change part 3) Now that all the C pre-processors in use support variadic macros, make DEBUG_ONLY work with toplevel commas (i.e. commas which are outside of any parentheses pair). This is useful in at least 2 ways: In C code, to easily pass debug arguments to functions in debug builds without any overhead in non-debug builds. void foo(DEBUG_ONLY(int debugArg,) // IN int nonDebugArg) // IN { ASSERT(DebugFunc(debugArg)); NonDebugFunc(nonDebugArg); } foo(DEBUG_ONLY(debugArg,) nonDebugArg); In asm code. DEBUG_ONLY(mov x0, #0) --- diff --git a/open-vm-tools/lib/include/vm_basic_defs.h b/open-vm-tools/lib/include/vm_basic_defs.h index e75fb2550..aa9396fe4 100644 --- a/open-vm-tools/lib/include/vm_basic_defs.h +++ b/open-vm-tools/lib/include/vm_basic_defs.h @@ -593,10 +593,10 @@ typedef int pid_t; #undef DEBUG_ONLY #ifdef VMX86_DEBUG #define vmx86_debug 1 -#define DEBUG_ONLY(x) x +#define DEBUG_ONLY(...) __VA_ARGS__ #else #define vmx86_debug 0 -#define DEBUG_ONLY(x) +#define DEBUG_ONLY(...) #endif #ifdef VMX86_STATS