cygserver: Speed up non-debug scenario

_log/_vlog were always called so we always had a function call hit even
if we're not debugging.  Expand on the debugging macros so the decision
to call _log/_vlog is done in the caller already.  Also, make a log level
difference between syscall_printf and system_printf.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2017-03-24 17:26:37 +01:00
parent 4dbcfeb7d0
commit 663b4ab824
7 changed files with 30 additions and 16 deletions

View File

@ -19,12 +19,26 @@ extern tun_bool_t log_stderr;
void loginit (tun_bool_t, tun_bool_t);
void _vlog (const char *, int, int, const char *, va_list);
void _log (const char *, int, int, const char *, ...);
void _vpanic (const char *, int, const char *, va_list) __attribute__ ((noreturn));
void _panic (const char *, int, const char *, ...) __attribute__ ((noreturn));
#define vlog(l,f,a) _vlog(NULL,0,(l),(f),(a))
#define log(l,f,...) _log(NULL,0,(l),(f),##__VA_ARGS__)
#define vdebug(f,a) _vlog(__FILE__,__LINE__,LOG_DEBUG,(f),(a))
#define debug(f,...) _log(__FILE__,__LINE__,LOG_DEBUG,(f),##__VA_ARGS__)
#define _vdebug(F,L,f,a) \
do { if (log_debug == TUN_TRUE) \
_vlog((F),(L),LOG_DEBUG,(f),(a)) \
} while (0)
#define _debug(F,L,f,...) \
do { if (log_debug == TUN_TRUE) \
_log((F),(L),LOG_DEBUG,(f),##__VA_ARGS__); \
} while (0)
#define vdebug(f,a) _vdebug(__FILE__,__LINE__,(f),(a))
#define debug(f,...) _debug(__FILE__,__LINE__,(f),##__VA_ARGS__)
void _vpanic (const char *, int, const char *, va_list)
__attribute__ ((noreturn));
void _panic (const char *, int, const char *, ...) __attribute__ ((noreturn));
#define vpanic(f,a) _vpanic(__FILE__,__LINE__,(f),(a))
#define panic(f,...) _panic(__FILE__,__LINE__,(f),##__VA_ARGS__)