mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-common
synced 2026-08-10 18:43:29 +00:00
Avoid usage of GCC extension for __VA_ARGS__ where possible
The "##" before __VA_ARGS__ is a GCC extension. Try to limit its usage where necessary. Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Acked-by: Uri Lublin <uril@redhat.com>
This commit is contained in:
parent
ca1016eb15
commit
b843d02a1b
@ -216,12 +216,12 @@ typedef struct SpiceEmptyStruct {
|
||||
|
||||
#define record(Name, ...) RECORD_MACRO(Name, __VA_ARGS__)
|
||||
#define RECORD(Name,...) RECORD_MACRO(Name, __VA_ARGS__)
|
||||
#define RECORD_MACRO(Name, Format,...) \
|
||||
RECORD_(RECORD,RECORD_COUNT_(__VA_ARGS__),Name,Format,##__VA_ARGS__)
|
||||
#define RECORD_(RECORD,RCOUNT,Name,Format,...) \
|
||||
RECORD__(RECORD,RCOUNT,Name,Format,## __VA_ARGS__)
|
||||
#define RECORD__(RECORD,RCOUNT,Name,Format,...) \
|
||||
RECORD##RCOUNT(Name,Format,##__VA_ARGS__)
|
||||
#define RECORD_MACRO(Name, ...) \
|
||||
RECORD_(RECORD,RECORD_COUNT_(__VA_ARGS__),Name,__VA_ARGS__)
|
||||
#define RECORD_(RECORD,RCOUNT,Name,...) \
|
||||
RECORD__(RECORD,RCOUNT,Name,__VA_ARGS__)
|
||||
#define RECORD__(RECORD,RCOUNT,Name,...) \
|
||||
RECORD##RCOUNT(Name,__VA_ARGS__)
|
||||
#define RECORD_COUNT_(...) RECORD_COUNT__(Dummy,##__VA_ARGS__,_X,_X,_12,_11,_10,_9,_8,_7,_6,_5,_4,_3,_2,_1,_0)
|
||||
#define RECORD_COUNT__(Dummy,_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_N,...) _N
|
||||
|
||||
@ -368,7 +368,7 @@ typedef struct SpiceEmptyStruct {
|
||||
RECORDER_ARG(j), \
|
||||
RECORDER_ARG(k), \
|
||||
RECORDER_ARG(l))
|
||||
#define RECORD_X(Name, Format, ...) RECORD_TOO_MANY_ARGS(printf(Format, __VA_ARGS__))
|
||||
#define RECORD_X(Name, ...) RECORD_TOO_MANY_ARGS(printf(__VA_ARGS__))
|
||||
|
||||
|
||||
// Some ugly macro drudgery to make things easy to use. Adjust type.
|
||||
|
||||
24
common/log.h
24
common/log.h
@ -59,26 +59,26 @@ void spice_log(GLogLevelFlags log_level,
|
||||
spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "should not be reached"); \
|
||||
} G_STMT_END
|
||||
|
||||
#define spice_info(format, ...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
|
||||
#define spice_info(...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, "" __VA_ARGS__); \
|
||||
} G_STMT_END
|
||||
|
||||
#define spice_debug(format, ...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
|
||||
#define spice_debug(...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, "" __VA_ARGS__); \
|
||||
} G_STMT_END
|
||||
|
||||
#define spice_warning(format, ...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
|
||||
#define spice_warning(...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "" __VA_ARGS__); \
|
||||
} G_STMT_END
|
||||
|
||||
#define spice_critical(format, ...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
|
||||
SPICE_UNREACHABLE; \
|
||||
#define spice_critical(...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" __VA_ARGS__); \
|
||||
SPICE_UNREACHABLE; \
|
||||
} G_STMT_END
|
||||
|
||||
#define spice_error(format, ...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
|
||||
SPICE_UNREACHABLE; \
|
||||
#define spice_error(...) G_STMT_START { \
|
||||
spice_log(G_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, "" __VA_ARGS__); \
|
||||
SPICE_UNREACHABLE; \
|
||||
} G_STMT_END
|
||||
|
||||
#define spice_warn_if_fail(x) G_STMT_START { \
|
||||
|
||||
@ -22,9 +22,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifndef MALLOC_ERROR
|
||||
#define MALLOC_ERROR(format, ...) SPICE_STMT_START { \
|
||||
spice_error(format, ## __VA_ARGS__); \
|
||||
abort(); \
|
||||
#define MALLOC_ERROR(...) SPICE_STMT_START { \
|
||||
spice_error(__VA_ARGS__); \
|
||||
abort(); \
|
||||
} SPICE_STMT_END
|
||||
#endif
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
#define COMPRESS_IMP
|
||||
|
||||
#if defined(ONE_BYTE) || defined(FOUR_BYTE)
|
||||
# define FARGS_DECL(arg1, ...) (Encoder *encoder, Channel *channel_a, arg1, ##__VA_ARGS__)
|
||||
# define FARGS_CALL(arg1, ...) (encoder, channel_a, arg1, ##__VA_ARGS__)
|
||||
# define FARGS_DECL(...) (Encoder *encoder, Channel *channel_a, __VA_ARGS__)
|
||||
# define FARGS_CALL(...) (encoder, channel_a, __VA_ARGS__)
|
||||
# define UNCOMPRESS_PIX_START(row) do { } while (0)
|
||||
# define SET_a(pix, val) ((pix)->a = val)
|
||||
# define GET_a(pix) ((pix)->a)
|
||||
@ -35,8 +35,8 @@
|
||||
# define APPLY_ALL_COMP(macro, ...) \
|
||||
macro(a, ## __VA_ARGS__)
|
||||
#else
|
||||
# define FARGS_DECL(arg1, ...) (Encoder *encoder, arg1, ##__VA_ARGS__)
|
||||
# define FARGS_CALL(arg1, ...) (encoder, arg1, ##__VA_ARGS__)
|
||||
# define FARGS_DECL(...) (Encoder *encoder, __VA_ARGS__)
|
||||
# define FARGS_CALL(...) (encoder, __VA_ARGS__)
|
||||
# define SAME_PIXEL(p1, p2) \
|
||||
(GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \
|
||||
GET_b(p1) == GET_b(p2))
|
||||
|
||||
@ -62,8 +62,8 @@ typedef struct SpiceDummyTweak {
|
||||
const SpiceDummyTweak spice_recorder_tweak_ ## rec = { (value) }
|
||||
#define RECORDER_TWEAK(rec) \
|
||||
((spice_recorder_tweak_ ## rec).tweak_value)
|
||||
#define RECORD(rec, format, ...) do { \
|
||||
if (sizeof((spice_recorder_ ## rec).dummy)) printf(format, ##__VA_ARGS__); \
|
||||
#define RECORD(rec, ...) do { \
|
||||
if (sizeof((spice_recorder_ ## rec).dummy)) printf(__VA_ARGS__); \
|
||||
} while(0)
|
||||
#define RECORD_TIMING_BEGIN(rec) \
|
||||
do { RECORD(rec, "begin");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user