]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
glibcompat: Provide implementation for G_GNUC_NO_INLINE
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 18 Jul 2022 10:48:32 +0000 (12:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 18 Jul 2022 15:23:15 +0000 (17:23 +0200)
Currently, we require glib-2.56.0 at minimum (because of RHEL-8)
but we use G_GNUC_NO_INLINE which was introduced in 2.58.0. While
we provide an implementation for older versions, where the macro
does not exists, it's a bit more tricky than that. Since we
define GLIB_VERSION_MAX_ALLOWED we would get a compile time error
when trying to use something too new, except for G_GNUC_NO_INLINE
which was intentionally not marked as
GLIB_AVAILABLE_MACRO_IN_2_58. But this is about to change with
glib-2.73.2 (which contains commit [1]).

At the same time, we can't just bump glib and thus we have to
provide an alternative implementation without the version
annotation.

1: https://gitlab.gnome.org/GNOME/glib/-/commit/a6f8fe071e44b0145619c21f3bfbc90c56ab805e
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/internal.h
src/util/glibcompat.h

index 4cfb022b41b5e77f7d048afb5c25d5bae176cd81..1e8e2908bfa579307efdc8199661e5f871f29e11 100644 (file)
 # endif
 #endif
 
-/**
- * G_GNUC_NO_INLINE:
- *
- * Force compiler not to inline a method. Should be used if
- * the method need to be overridable by test mocks.
- *
- * TODO: Remove after upgrading to GLib >= 2.58
- */
-#ifndef G_GNUC_NO_INLINE
-# define G_GNUC_NO_INLINE __attribute__((__noinline__))
-#endif
-
 /**
  * ATTRIBUTE_PACKED
  *
index 1f3a6f728faf74f73b4ab71243a5abe85b376140..e3a8b9f6b34fd05243f68262297b657e02059dac 100644 (file)
@@ -94,3 +94,12 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args)
 #define g_fsync vir_g_fsync
 
 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