Change scope of debugging macros.
This commit is contained in:
parent
b649dc7d3b
commit
30b89d7808
2 changed files with 22 additions and 22 deletions
|
@ -229,23 +229,6 @@ static TPool* G_TPOOL_GENERAL = NULL;
|
|||
static TPool* G_TPOOL_TXNS = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Helpful macros
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
# define DBG(...) bdberl_dbg(__VA_ARGS__)
|
||||
# define DBGCMD(P, ...) bdberl_dbgcmd(P, __VA_ARGS__)
|
||||
# define DBGCMDRC(P, ...) bdberl_dbgcmdrc(P, __VA_ARGS__)
|
||||
static void bdberl_dbg(const char * fmt, ...);
|
||||
static void bdberl_dbgcmd(PortData *d, const char *fmt, ...);
|
||||
static void bdberl_dbgcmdrc(PortData *d, int rc);
|
||||
#else
|
||||
# define DBG(arg1,...)
|
||||
# define DBGCMD(d, fmt, ...)
|
||||
# define DBGCMDRC(d, rc) { while (0) { rc++; } } // otherwise get unused variable error
|
||||
#endif
|
||||
|
||||
|
||||
#define LOCK_DATABASES(P) \
|
||||
do \
|
||||
{ \
|
||||
|
@ -2494,7 +2477,7 @@ static void send_log_message(ErlDrvTermData* msg, int elements)
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void bdberl_dbg(const char *fmt, ...)
|
||||
void bdberl_dbg(const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
@ -2503,11 +2486,11 @@ static void bdberl_dbg(const char *fmt, ...)
|
|||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
(void)fprintf(stderr, "%s\n", buf);
|
||||
(void)fprintf(stderr, "%s", buf);
|
||||
(void)fflush(stderr);
|
||||
}
|
||||
|
||||
static void bdberl_dbgcmd(PortData *d, const char *fmt, ...)
|
||||
void bdberl_dbgcmd(PortData *d, const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
@ -2516,11 +2499,11 @@ static void bdberl_dbgcmd(PortData *d, const char *fmt, ...)
|
|||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
(void)fprintf(stderr, "threadid %p port %p: %s\n", erl_drv_thread_self(), d->port, buf);
|
||||
(void)fprintf(stderr, "threadid %p port %p: %s", erl_drv_thread_self(), d->port, buf);
|
||||
(void)fflush(stderr);
|
||||
}
|
||||
|
||||
static void bdberl_dbgcmdrc(PortData *d, int rc)
|
||||
void bdberl_dbgcmdrc(PortData *d, int rc)
|
||||
{
|
||||
(void)fprintf(stderr, "threadid %p port %p: rc = %s (%d)\n",
|
||||
erl_drv_thread_self(), d->port, rc == 0 ? "ok" : bdberl_rc_to_atom_str(rc), rc);
|
||||
|
|
|
@ -250,4 +250,21 @@ void bdberl_txn_tpool_run(TPoolJobFunc main_fn, PortData* d, TPoolJobFunc cance
|
|||
RETURN_INT(0, outbuf); \
|
||||
}}
|
||||
|
||||
|
||||
/**
|
||||
* Helpful macros
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
# define DBG(...) bdberl_dbg(__VA_ARGS__)
|
||||
# define DBGCMD(P, ...) bdberl_dbgcmd(P, __VA_ARGS__)
|
||||
# define DBGCMDRC(P, ...) bdberl_dbgcmdrc(P, __VA_ARGS__)
|
||||
extern void bdberl_dbg(const char * fmt, ...);
|
||||
extern void bdberl_dbgcmd(PortData *d, const char *fmt, ...);
|
||||
extern void bdberl_dbgcmdrc(PortData *d, int rc);
|
||||
#else
|
||||
# define DBG(arg1,...)
|
||||
# define DBGCMD(d, fmt, ...)
|
||||
# define DBGCMDRC(d, rc) { while (0) { rc++; } } // otherwise get unused variable error
|
||||
#endif
|
||||
|
||||
#endif //_BDBERL_DRV
|
||||
|
|
Loading…
Reference in a new issue