packagefs: Add va-args version ERRORV() to DebugSupport
This commit is contained in:
parent
5261923e87
commit
760dee16d1
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2003-2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -127,24 +127,29 @@ dbg_printf_end()
|
||||
|
||||
#if DEBUG_PRINT
|
||||
|
||||
|
||||
void
|
||||
dbg_printf(const char *format,...)
|
||||
dbg_vprintf(const char* format, va_list args)
|
||||
{
|
||||
if (!dbg_printf_lock())
|
||||
return;
|
||||
|
||||
char buffer[1024];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
// no vsnprintf() on PPC and in kernel
|
||||
#if defined(__INTEL__) && USER
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, format, args);
|
||||
#else
|
||||
vsprintf(buffer, format, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, format, args);
|
||||
write(out, buffer, strlen(buffer));
|
||||
|
||||
dbg_printf_unlock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
dbg_printf(const char* format,...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
dbg_vprintf(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
#endif // DEBUG_PRINT
|
||||
|
@ -44,16 +44,20 @@
|
||||
# include <stdio.h>
|
||||
# if DEBUG_PRINT
|
||||
# define __out dbg_printf
|
||||
# define __outv dbg_vprintf
|
||||
# else
|
||||
# define __out printf
|
||||
# define __outv vprintf
|
||||
# endif
|
||||
#else
|
||||
# include <KernelExport.h>
|
||||
# include <null.h>
|
||||
# if DEBUG_PRINT
|
||||
# define __out dbg_printf
|
||||
# define __outv dbg_vprintf
|
||||
# else
|
||||
# define __out dprintf
|
||||
# define __outv dvprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -74,18 +78,23 @@ status_t exit_debugging();
|
||||
void dbg_printf_begin();
|
||||
void dbg_printf_end();
|
||||
#if DEBUG_PRINT
|
||||
void dbg_printf(const char *format,...);
|
||||
void dbg_vprintf(const char* format, va_list args);
|
||||
void dbg_printf(const char* format,...);
|
||||
#else
|
||||
static inline void dbg_printf(const char *,...) {}
|
||||
static inline void dbg_vprintf(const char*, va_list) {}
|
||||
static inline void dbg_printf(const char*,...) {}
|
||||
#endif
|
||||
|
||||
|
||||
// Short overview over the debug output macros:
|
||||
// Short overview of the debug output macros:
|
||||
// PRINT()
|
||||
// is for general messages that very unlikely should appear in a release
|
||||
// build
|
||||
// general messages that shouldn't appear in a release build
|
||||
// FATAL()
|
||||
// this is for fatal messages, when something has really gone wrong
|
||||
// fatal messages, when something has really gone wrong
|
||||
// ERROR()
|
||||
// non-fatal error messages
|
||||
// WARN()
|
||||
// warning messages
|
||||
// INFORM()
|
||||
// general information, as disk size, etc.
|
||||
// REPORT_ERROR(status_t)
|
||||
@ -121,7 +130,8 @@ void dbg_printf_end();
|
||||
dbg_printf_end(); \
|
||||
}
|
||||
|
||||
#define TPRINT(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define TPRINT(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define TPRINTV(format, args) DEBUG_CONTEXT( __outv(format, args) )
|
||||
#define TREPORT_ERROR(status) \
|
||||
DEBUG_CONTEXT_LINE( __out("%s\n", strerror(status)) )
|
||||
#define TRETURN_ERROR(err) \
|
||||
@ -147,10 +157,6 @@ void dbg_printf_end();
|
||||
#define REPORT_ERROR(status) TREPORT_ERROR(status)
|
||||
#define RETURN_ERROR(err) TRETURN_ERROR(err)
|
||||
#define SET_ERROR(var, err) TSET_ERROR(var, err)
|
||||
#define FATAL(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define ERROR(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define WARN(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define INFORM(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define FUNCTION(x...) TFUNCTION(x)
|
||||
#define FUNCTION_START() TFUNCTION_START()
|
||||
#define FUNCTION_END() TFUNCTION_END()
|
||||
@ -161,10 +167,6 @@ void dbg_printf_end();
|
||||
#define REPORT_ERROR(status) ;
|
||||
#define RETURN_ERROR(status) return status;
|
||||
#define SET_ERROR(var, err) var = err;
|
||||
#define FATAL(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define ERROR(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define WARN(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define INFORM(x...) DEBUG_CONTEXT( __out(x) )
|
||||
#define FUNCTION(x...) ;
|
||||
#define FUNCTION_START() ;
|
||||
#define FUNCTION_END() ;
|
||||
@ -172,6 +174,12 @@ void dbg_printf_end();
|
||||
#define D(x) ;
|
||||
#endif
|
||||
|
||||
#define FATAL(x...) TPRINT(x)
|
||||
#define ERROR(x...) TPRINT(x)
|
||||
#define ERRORV(format, args) TPRINTV(format, args)
|
||||
#define WARN(x...) TPRINT(x)
|
||||
#define INFORM(x...) TPRINT(x)
|
||||
|
||||
#ifndef TOUCH
|
||||
#define TOUCH(var) (void)var
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user