[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 08/13] compiler.h: explicit case for Clang printf attribut
|
From: |
Peter Maydell |
|
Subject: |
Re: [PATCH v2 08/13] compiler.h: explicit case for Clang printf attribute |
|
Date: |
Thu, 26 Nov 2020 12:00:45 +0000 |
On Thu, 26 Nov 2020 at 11:30, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Since commit efc6c07 ("configure: Add a test for the minimum compiler
> version"), QEMU explicitely depends on GCC >= 4.8, we could thus drop
> earlier version checks. Except clang advertizes itself as GCC 4.2.1.
>
> Since clang doesn't support gnu_printf, make that case explicitely and
> drop GCC version check.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/qemu/compiler.h | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index ae3e0df34c..108bfdb391 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -90,18 +90,16 @@
> #define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \
> sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
>
> -#if defined __GNUC__
> -# if !G_GNUC_CHECK_VERSION(4, 4)
> - /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
> -# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
> -# else
> - /* Use gnu_printf when supported (qemu uses standard format strings). */
> -# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
> -# if 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
> +#if defined(__clang__)
> + /* clang doesn't support gnu_printf, so use printf. */
> +# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
> +#elif defined(__GNUC__)
> + /* Use gnu_printf (qemu uses standard format strings). */
> +# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
> +# if 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
checkpatch probably warns about the block comment style so you might
as well fix it while touching that line, but otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
- Re: [PATCH v2 04/13] compiler.h: remove GCC < 3 __builtin_expect fallback, (continued)
[PATCH v2 06/13] tests: remove GCC < 4 fallbacks, marcandre . lureau, 2020/11/26
[PATCH v2 07/13] virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON, marcandre . lureau, 2020/11/26
[PATCH v2 08/13] compiler.h: explicit case for Clang printf attribute, marcandre . lureau, 2020/11/26
- Re: [PATCH v2 08/13] compiler.h: explicit case for Clang printf attribute,
Peter Maydell <=
[PATCH v2 09/13] audio: remove GNUC & MSVC check, marcandre . lureau, 2020/11/26
[PATCH v2 10/13] poison: remove GNUC check, marcandre . lureau, 2020/11/26
[PATCH v2 11/13] xen: remove GNUC check, marcandre . lureau, 2020/11/26
[PATCH v2 12/13] compiler: remove GNUC check, marcandre . lureau, 2020/11/26