From 9edc6313da34699ebd2bae4573ea22339b26450a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 20 Feb 2022 20:39:25 +0400 Subject: Replace GCC_FMT_ATTR with G_GNUC_PRINTF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually. Signed-off-by: Marc-André Lureau Reviewed-by: Richard W.M. Jones --- include/qemu/compiler.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'include/qemu/compiler.h') diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 3baa5e3790..f2bd050e3b 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -79,19 +79,12 @@ #define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \ sizeof(QEMU_BUILD_BUG_ON_STRUCT(x))) -#if defined(__clang__) -/* clang doesn't support gnu_printf, so use printf. */ -# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) -#else -/* Use gnu_printf (qemu uses standard format strings). */ -# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) -# if defined(_WIN32) +#if !defined(__clang__) && defined(_WIN32) /* * Map __printf__ to __gnu_printf__ because we want standard format strings even * when MinGW or GLib include files use __printf__. */ -# define __printf__ __gnu_printf__ -# endif +# define __printf__ __gnu_printf__ #endif #ifndef __has_warning -- cgit 1.4.1 From c08401793a1f298b4d52410835b01ca9b64c313a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 24 Feb 2022 00:58:22 +0400 Subject: compiler.h: replace QEMU_WARN_UNUSED_RESULT with G_GNUC_WARN_UNUSED_RESULT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually. Signed-off-by: Marc-André Lureau Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- block/qcow2-refcount.c | 20 +++++++++++--------- include/qemu-common.h | 2 +- include/qemu/compiler.h | 2 -- include/qemu/range.h | 4 ++-- scripts/checkpatch.pl | 2 +- scripts/cocci-macro-file.h | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'include/qemu/compiler.h') diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 94033972be..b91499410c 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -33,9 +33,11 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size, uint64_t max); -static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, - int64_t offset, int64_t length, uint64_t addend, - bool decrease, enum qcow2_discard_type type); + +G_GNUC_WARN_UNUSED_RESULT +static int update_refcount(BlockDriverState *bs, + int64_t offset, int64_t length, uint64_t addend, + bool decrease, enum qcow2_discard_type type); static uint64_t get_refcount_ro0(const void *refcount_array, uint64_t index); static uint64_t get_refcount_ro1(const void *refcount_array, uint64_t index); @@ -803,12 +805,12 @@ found: /* XXX: cache several refcount block clusters ? */ /* @addend is the absolute value of the addend; if @decrease is set, @addend * will be subtracted from the current refcount, otherwise it will be added */ -static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, - int64_t offset, - int64_t length, - uint64_t addend, - bool decrease, - enum qcow2_discard_type type) +static int update_refcount(BlockDriverState *bs, + int64_t offset, + int64_t length, + uint64_t addend, + bool decrease, + enum qcow2_discard_type type) { BDRVQcow2State *s = bs->opaque; int64_t start, last, cluster_offset; diff --git a/include/qemu-common.h b/include/qemu-common.h index 9c04fa94e8..19e254dbe5 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -27,7 +27,7 @@ int qemu_main(int argc, char **argv, char **envp); #endif ssize_t qemu_write_full(int fd, const void *buf, size_t count) - QEMU_WARN_UNUSED_RESULT; + G_GNUC_WARN_UNUSED_RESULT; #ifndef _WIN32 int qemu_pipe(int pipefd[2]); diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index f2bd050e3b..8385e477c1 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -19,8 +19,6 @@ #define QEMU_NORETURN __attribute__ ((__noreturn__)) -#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) - #define QEMU_SENTINEL __attribute__((sentinel)) #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) diff --git a/include/qemu/range.h b/include/qemu/range.h index f62b363e0d..7e2b1cc447 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -114,8 +114,8 @@ static inline uint64_t range_upb(Range *range) * @size may be 0. If the range would overflow, returns -ERANGE, otherwise * 0. */ -static inline int QEMU_WARN_UNUSED_RESULT range_init(Range *range, uint64_t lob, - uint64_t size) +G_GNUC_WARN_UNUSED_RESULT +static inline int range_init(Range *range, uint64_t lob, uint64_t size) { if (lob + size < lob) { return -ERANGE; diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a07f0effb5..797738a8e8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -224,7 +224,7 @@ our $Attribute = qr{ const| volatile| QEMU_NORETURN| - QEMU_WARN_UNUSED_RESULT| + G_GNUC_WARN_UNUSED_RESULT| QEMU_SENTINEL| QEMU_PACKED| G_GNUC_PRINTF diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h index c2fcea8e77..9daec24d78 100644 --- a/scripts/cocci-macro-file.h +++ b/scripts/cocci-macro-file.h @@ -20,7 +20,7 @@ /* From qemu/compiler.h */ #define QEMU_NORETURN __attribute__ ((__noreturn__)) -#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #define QEMU_SENTINEL __attribute__((sentinel)) #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) -- cgit 1.4.1 From 887ce500ef0046d35e613e40f7beb647a797b3e7 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 24 Feb 2022 00:58:22 +0400 Subject: compiler.h: replace QEMU_SENTINEL with G_GNUC_NULL_TERMINATED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually. Signed-off-by: Marc-André Lureau Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/compiler.h | 2 -- include/qom/object.h | 6 +++--- scripts/checkpatch.pl | 2 +- scripts/cocci-macro-file.h | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) (limited to 'include/qemu/compiler.h') diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 8385e477c1..0a5e67fb97 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -19,8 +19,6 @@ #define QEMU_NORETURN __attribute__ ((__noreturn__)) -#define QEMU_SENTINEL __attribute__((sentinel)) - #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) # define QEMU_PACKED __attribute__((gcc_struct, packed)) #else diff --git a/include/qom/object.h b/include/qom/object.h index fae096f51c..5f3d5b5bf5 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -616,7 +616,7 @@ Object *object_new_with_props(const char *typename, Object *parent, const char *id, Error **errp, - ...) QEMU_SENTINEL; + ...) G_GNUC_NULL_TERMINATED; /** * object_new_with_propv: @@ -676,7 +676,7 @@ void object_apply_compat_props(Object *obj); * * Returns: %true on success, %false on error. */ -bool object_set_props(Object *obj, Error **errp, ...) QEMU_SENTINEL; +bool object_set_props(Object *obj, Error **errp, ...) G_GNUC_NULL_TERMINATED; /** * object_set_propv: @@ -728,7 +728,7 @@ void object_initialize(void *obj, size_t size, const char *typename); bool object_initialize_child_with_props(Object *parentobj, const char *propname, void *childobj, size_t size, const char *type, - Error **errp, ...) QEMU_SENTINEL; + Error **errp, ...) G_GNUC_NULL_TERMINATED; /** * object_initialize_child_with_propsv: diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 797738a8e8..ddc6003de2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -225,7 +225,7 @@ our $Attribute = qr{ volatile| QEMU_NORETURN| G_GNUC_WARN_UNUSED_RESULT| - QEMU_SENTINEL| + G_GNUC_NULL_TERMINATED| QEMU_PACKED| G_GNUC_PRINTF }x; diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h index 9daec24d78..3d1e9b5091 100644 --- a/scripts/cocci-macro-file.h +++ b/scripts/cocci-macro-file.h @@ -21,7 +21,7 @@ /* From qemu/compiler.h */ #define QEMU_NORETURN __attribute__ ((__noreturn__)) #define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#define QEMU_SENTINEL __attribute__((sentinel)) +#define G_GNUC_NULL_TERMINATED __attribute__((sentinel)) #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) # define QEMU_PACKED __attribute__((gcc_struct, packed)) -- cgit 1.4.1 From 519655970ebeb7a0dfe5ad3c1d1dc17a02b7faa6 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 24 Feb 2022 18:49:53 +0400 Subject: Move HOST_LONG_BITS to compiler.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help to make common code independent. Signed-off-by: Marc-André Lureau Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/compiler.h | 5 +++++ include/qemu/osdep.h | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'include/qemu/compiler.h') diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 0a5e67fb97..d9359859d4 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -7,6 +7,11 @@ #ifndef COMPILER_H #define COMPILER_H +#define HOST_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + +/* HOST_LONG_BITS is the size of a native pointer in bits. */ +#define HOST_LONG_BITS (__SIZEOF_POINTER__ * 8) + #if defined __clang_analyzer__ || defined __COVERITY__ #define QEMU_STATIC_ANALYSIS 1 #endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 8b070dee21..9f06bf536f 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -244,9 +244,6 @@ extern "C" { #define TIME_MAX TYPE_MAXIMUM(time_t) #endif -/* HOST_LONG_BITS is the size of a native pointer in bits. */ -#define HOST_LONG_BITS (__SIZEOF_POINTER__ * 8) - /* Mac OSX has a bug that incorrectly defines SIZE_MAX with * the wrong type. Our replacement isn't usable in preprocessor * expressions, but it is sufficient for our needs. */ -- cgit 1.4.1