mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-31 13:58:21 +08:00
mdbx: add mdbx_printf_args() macro.
Change-Id: I7fca72f8cc912d8644ecf149b755c78fb3cc7e23
This commit is contained in:
parent
369612a9b2
commit
58bcfb006e
9
mdbx.h
9
mdbx.h
@ -432,6 +432,15 @@ typedef mode_t mdbx_mode_t;
|
|||||||
#endif
|
#endif
|
||||||
#endif /* __noreturn */
|
#endif /* __noreturn */
|
||||||
|
|
||||||
|
#ifndef mdbx_printf_args
|
||||||
|
#if defined(__GNUC__) || __has_attribute(__format__)
|
||||||
|
#define mdbx_printf_args(format_index, first_arg) \
|
||||||
|
__attribute__((__format__(__printf__, format_index, first_arg)))
|
||||||
|
#else
|
||||||
|
#define mdbx_printf_args(format_index, first_arg)
|
||||||
|
#endif
|
||||||
|
#endif /* mdbx_printf_args */
|
||||||
|
|
||||||
#ifndef DEFINE_ENUM_FLAG_OPERATORS
|
#ifndef DEFINE_ENUM_FLAG_OPERATORS
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
/// Define operator overloads to enable bit operations on enum values that are
|
/// Define operator overloads to enable bit operations on enum values that are
|
||||||
|
@ -581,7 +581,7 @@ number_of_ovpages(const MDBX_env *env, size_t bytes) {
|
|||||||
return bytes2pgno(env, PAGEHDRSZ - 1 + bytes) + 1;
|
return bytes2pgno(env, PAGEHDRSZ - 1 + bytes) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__cold static int __printf_args(2, 3)
|
__cold static int mdbx_printf_args(2, 3)
|
||||||
bad_page(const MDBX_page *mp, const char *fmt, ...) {
|
bad_page(const MDBX_page *mp, const char *fmt, ...) {
|
||||||
if (mdbx_log_enabled(MDBX_LOG_ERROR)) {
|
if (mdbx_log_enabled(MDBX_LOG_ERROR)) {
|
||||||
static const MDBX_page *prev;
|
static const MDBX_page *prev;
|
||||||
|
@ -259,15 +259,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* unlikely */
|
#endif /* unlikely */
|
||||||
|
|
||||||
#ifndef __printf_args
|
|
||||||
# if defined(__GNUC__) || __has_attribute(__format__)
|
|
||||||
# define __printf_args(format_index, first_arg) \
|
|
||||||
__attribute__((__format__(__printf__, format_index, first_arg)))
|
|
||||||
# else
|
|
||||||
# define __printf_args(format_index, first_arg)
|
|
||||||
# endif
|
|
||||||
#endif /* __printf_args */
|
|
||||||
|
|
||||||
#ifndef __anonymous_struct_extension__
|
#ifndef __anonymous_struct_extension__
|
||||||
# if defined(__GNUC__)
|
# if defined(__GNUC__)
|
||||||
# define __anonymous_struct_extension__ __extension__
|
# define __anonymous_struct_extension__ __extension__
|
||||||
|
@ -1037,9 +1037,9 @@ extern uint8_t mdbx_runtime_flags;
|
|||||||
extern uint8_t mdbx_loglevel;
|
extern uint8_t mdbx_loglevel;
|
||||||
extern MDBX_debug_func *mdbx_debug_logger;
|
extern MDBX_debug_func *mdbx_debug_logger;
|
||||||
|
|
||||||
MDBX_INTERNAL_FUNC void __printf_args(4, 5)
|
MDBX_INTERNAL_FUNC void mdbx_printf_args(4, 5)
|
||||||
mdbx_debug_log(int level, const char *function, int line, const char *fmt,
|
mdbx_debug_log(int level, const char *function, int line, const char *fmt,
|
||||||
...) __printf_args(4, 5);
|
...) mdbx_printf_args(4, 5);
|
||||||
MDBX_INTERNAL_FUNC void mdbx_debug_log_va(int level, const char *function,
|
MDBX_INTERNAL_FUNC void mdbx_debug_log_va(int level, const char *function,
|
||||||
int line, const char *fmt,
|
int line, const char *fmt,
|
||||||
va_list args);
|
va_list args);
|
||||||
|
@ -106,7 +106,7 @@ struct problem {
|
|||||||
struct problem *problems_list;
|
struct problem *problems_list;
|
||||||
uint64_t total_problems;
|
uint64_t total_problems;
|
||||||
|
|
||||||
static void __printf_args(1, 2) print(const char *msg, ...) {
|
static void mdbx_printf_args(1, 2) print(const char *msg, ...) {
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ static void va_log(MDBX_log_level_t level, const char *msg, va_list args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __printf_args(1, 2) error(const char *msg, ...) {
|
static void mdbx_printf_args(1, 2) error(const char *msg, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
va_log(MDBX_LOG_ERROR, msg, args);
|
va_log(MDBX_LOG_ERROR, msg, args);
|
||||||
@ -216,7 +216,7 @@ static walk_dbi_t *pagemap_lookup_dbi(const char *dbi_name, bool silent) {
|
|||||||
return last = dbi;
|
return last = dbi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __printf_args(4, 5)
|
static void mdbx_printf_args(4, 5)
|
||||||
|
|
||||||
problem_add(const char *object, uint64_t entry_number, const char *msg,
|
problem_add(const char *object, uint64_t entry_number, const char *msg,
|
||||||
const char *extra, ...) {
|
const char *extra, ...) {
|
||||||
|
@ -487,7 +487,7 @@ static __maybe_unused __inline void mdbx_memory_barrier(void) {
|
|||||||
#define mdbx_asprintf asprintf
|
#define mdbx_asprintf asprintf
|
||||||
#define mdbx_vasprintf vasprintf
|
#define mdbx_vasprintf vasprintf
|
||||||
#else
|
#else
|
||||||
MDBX_INTERNAL_FUNC __printf_args(2, 3) int __maybe_unused
|
MDBX_INTERNAL_FUNC mdbx_printf_args(2, 3) int __maybe_unused
|
||||||
mdbx_asprintf(char **strp, const char *fmt, ...);
|
mdbx_asprintf(char **strp, const char *fmt, ...);
|
||||||
MDBX_INTERNAL_FUNC int mdbx_vasprintf(char **strp, const char *fmt, va_list ap);
|
MDBX_INTERNAL_FUNC int mdbx_vasprintf(char **strp, const char *fmt, va_list ap);
|
||||||
#endif
|
#endif
|
||||||
|
22
test/log.h
22
test/log.h
@ -18,7 +18,7 @@
|
|||||||
#include "chrono.h"
|
#include "chrono.h"
|
||||||
|
|
||||||
__noreturn void usage(void);
|
__noreturn void usage(void);
|
||||||
__noreturn void __printf_args(1, 2) failure(const char *fmt, ...);
|
__noreturn void mdbx_printf_args(1, 2) failure(const char *fmt, ...);
|
||||||
__noreturn void failure_perror(const char *what, int errnum);
|
__noreturn void failure_perror(const char *what, int errnum);
|
||||||
const char *test_strerror(int errnum);
|
const char *test_strerror(int errnum);
|
||||||
|
|
||||||
@ -51,12 +51,12 @@ void setlevel(loglevel priority);
|
|||||||
|
|
||||||
void output_nocheckloglevel_ap(const loglevel priority, const char *format,
|
void output_nocheckloglevel_ap(const loglevel priority, const char *format,
|
||||||
va_list ap);
|
va_list ap);
|
||||||
bool __printf_args(2, 3)
|
bool mdbx_printf_args(2, 3)
|
||||||
output(const loglevel priority, const char *format, ...);
|
output(const loglevel priority, const char *format, ...);
|
||||||
bool feed_ap(const char *format, va_list ap);
|
bool feed_ap(const char *format, va_list ap);
|
||||||
bool __printf_args(1, 2) feed(const char *format, ...);
|
bool mdbx_printf_args(1, 2) feed(const char *format, ...);
|
||||||
|
|
||||||
void inline __printf_args(2, 3)
|
void inline mdbx_printf_args(2, 3)
|
||||||
output_nocheckloglevel(const loglevel priority, const char *format, ...) {
|
output_nocheckloglevel(const loglevel priority, const char *format, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
@ -85,13 +85,13 @@ public:
|
|||||||
|
|
||||||
} // namespace logging
|
} // namespace logging
|
||||||
|
|
||||||
void __printf_args(1, 2) log_extra(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_extra(const char *msg, ...);
|
||||||
void __printf_args(1, 2) log_trace(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_trace(const char *msg, ...);
|
||||||
void __printf_args(1, 2) log_debug(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_debug(const char *msg, ...);
|
||||||
void __printf_args(1, 2) log_verbose(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_verbose(const char *msg, ...);
|
||||||
void __printf_args(1, 2) log_notice(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_notice(const char *msg, ...);
|
||||||
void __printf_args(1, 2) log_warning(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_warning(const char *msg, ...);
|
||||||
void __printf_args(1, 2) log_error(const char *msg, ...);
|
void mdbx_printf_args(1, 2) log_error(const char *msg, ...);
|
||||||
|
|
||||||
void log_trouble(const char *where, const char *what, int errnum);
|
void log_trouble(const char *where, const char *what, int errnum);
|
||||||
void log_flush(void);
|
void log_flush(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user