[PATCH 2/2] lib: Use G_NO_INLINE instead of G_GNUC_NO_INLINE

Pavel Hrdina phrdina at redhat.com
Mon Jul 18 15:01:26 UTC 2022


On Mon, Jul 18, 2022 at 04:03:16PM +0200, Michal Privoznik wrote:
> The G_GNUC_NO_INLINE macro will eventually be marked as
> deprecated [1] and we are recommended to use G_NO_INLINE instead.
> Do the switch now, rather than waiting for compile time warning
> to occur.
> 
> 1: https://gitlab.gnome.org/GNOME/glib/-/commit/15cd0f04612c90292792c4d123ebe84bf4bf93a6
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  docs/coding-style.rst           |  2 +-
>  scripts/cocci-macro-file.h      |  2 +-
>  scripts/mock-noinline.py        |  4 ++--
>  src/cpu/cpu.h                   |  2 +-
>  src/libxl/libxl_capabilities.h  |  2 +-
>  src/qemu/qemu_capabilities.h    |  2 +-
>  src/qemu/qemu_capspriv.h        |  2 +-
>  src/qemu/qemu_command.h         |  4 ++--
>  src/qemu/qemu_hotplug.c         |  2 +-
>  src/qemu/qemu_hotplug.h         |  2 +-
>  src/qemu/qemu_interface.h       |  4 ++--
>  src/qemu/qemu_monitor.h         |  2 +-
>  src/qemu/qemu_monitor_json.h    |  2 +-
>  src/qemu/qemu_monitor_priv.h    |  2 +-
>  src/qemu/qemu_process.h         |  6 +++---
>  src/rpc/virnetsocket.h          |  4 ++--
>  src/util/glibcompat.h           | 28 ++++++++++++++++++++--------
>  src/util/vircgroupv2devices.h   |  2 +-
>  src/util/vircommand.h           |  2 +-
>  src/util/virdevmapper.h         |  2 +-
>  src/util/virfile.h              | 18 +++++++++---------
>  src/util/virhashcode.h          |  2 +-
>  src/util/virhostcpu.h           |  6 +++---
>  src/util/virhostmem.h           |  2 +-
>  src/util/virhostuptime.h        |  2 +-
>  src/util/viridentitypriv.h      |  2 +-
>  src/util/virmacaddr.h           |  2 +-
>  src/util/virnetdev.h            | 10 +++++-----
>  src/util/virnetdevbandwidth.h   |  2 +-
>  src/util/virnetdevip.h          |  2 +-
>  src/util/virnetdevmacvlan.h     |  2 +-
>  src/util/virnetdevopenvswitch.h |  2 +-
>  src/util/virnetdevtap.h         |  6 +++---
>  src/util/virnuma.h              | 18 +++++++++---------
>  src/util/virprocess.h           |  6 +++---
>  src/util/virrandom.h            |  6 +++---
>  src/util/virscsi.h              |  2 +-
>  src/util/virscsivhost.h         |  2 +-
>  src/util/virtpm.h               |  2 +-
>  src/util/virutil.h              | 16 ++++++++--------
>  src/util/viruuid.h              |  4 ++--
>  41 files changed, 102 insertions(+), 90 deletions(-)

[...]

> diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
> index e3a8b9f6b3..02f8ec090c 100644
> --- a/src/util/glibcompat.h
> +++ b/src/util/glibcompat.h
> @@ -95,11 +95,23 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args)
>  
>  void vir_g_source_unref(GSource *src, GMainContext *ctx);
>  
> -/* Intentionally redefine macro so that it's not marked as available in 2.58
> - * and newer. Drop when bumping to 2.58 or newer. */
> -#undef G_GNUC_NO_INLINE
> -#if g_macro__has_attribute(__noinline__)
> -# define G_GNUC_NO_INLINE __attribute__ ((__noinline__))
> -#else
> -# define G_GNUC_NO_INLINE
> -#endif
> +#if !GLIB_CHECK_VERSION(2, 73, 0)

Not sure if this check is correct. Documentation for that macro
mentions that it is introduced in 2.74 but I can see it in 2.73.2 as
well but this check is for 2.73.0 and if I understand the
GLIB_CHECK_VERSION() correctly our own implementation would be used only
with glib older then 2.73.0.

That means based on my understanding that with glib 2.73.0 and 2.73.1
libvirt would failed to compile as there would not be any implementation
for G_NO_INLINE.

Pavel

> +# if (defined(__has_attribute) && __has_attribute(__noinline__)) || G_GNUC_CHECK_VERSION (2, 96)
> +#  if defined (__cplusplus) && __cplusplus >= 201103L
> +    /* Use ISO C++11 syntax when the compiler supports it. */
> +#   define G_NO_INLINE [[gnu::noinline]]
> +#  else
> +#   define G_NO_INLINE __attribute__ ((__noinline__))
> +#  endif
> +# elif defined (_MSC_VER) && (1200 <= _MSC_VER)
> +   /* Use MSVC specific syntax.  */
> +#  if defined (__cplusplus) && __cplusplus >= 201103L
> +    /* Use ISO C++11 syntax when the compiler supports it. */
> +#   define G_NO_INLINE [[msvc::noinline]]
> +#  else
> +#   define G_NO_INLINE __declspec (noinline)
> +#  endif
> +# else
> +#  define G_NO_INLINE /* empty */
> +# endif
> +#endif /* GLIB_CHECK_VERSION(2, 73, 0) */

[...]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220718/68285d47/attachment.sig>


More information about the libvir-list mailing list