[PATCH 0/2] Fix build with glib-2.73.2

See the first patch for explanation. The second is just a cleanup so that we don't have to care about glib for some time. Michal Prívozník (2): glibcompat: Provide implementation for G_GNUC_NO_INLINE lib: Use G_NO_INLINE instead of G_GNUC_NO_INLINE docs/coding-style.rst | 2 +- scripts/cocci-macro-file.h | 2 +- scripts/mock-noinline.py | 4 ++-- src/cpu/cpu.h | 2 +- src/internal.h | 12 ------------ 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 | 21 +++++++++++++++++++++ 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 ++-- 42 files changed, 103 insertions(+), 94 deletions(-) -- 2.35.1

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/a6f8fe071e44b0145619c21f3bfbc90... Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/internal.h | 12 ------------ src/util/glibcompat.h | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/internal.h b/src/internal.h index 4cfb022b41..1e8e2908bf 100644 --- a/src/internal.h +++ b/src/internal.h @@ -109,18 +109,6 @@ # 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 * diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 1f3a6f728f..e3a8b9f6b3 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -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 -- 2.35.1

On Mon, Jul 18, 2022 at 04:03:15PM +0200, Michal Privoznik wrote:
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/a6f8fe071e44b0145619c21f3bfbc90... Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/internal.h | 12 ------------ src/util/glibcompat.h | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

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/15cd0f04612c90292792c4d123ebe84... Signed-off-by: Michal Privoznik <mprivozn@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/docs/coding-style.rst b/docs/coding-style.rst index cb23751721..bf0a80fbc5 100644 --- a/docs/coding-style.rst +++ b/docs/coding-style.rst @@ -628,7 +628,7 @@ analysis tools understand the code better: ``G_GNUC_FALLTHROUGH`` allow code reuse by multiple switch cases -``G_GNUC_NO_INLINE`` +``G_NO_INLINE`` the function is mocked in the test suite ``G_GNUC_NORETURN`` diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h index 4e6d218a97..c3112663d1 100644 --- a/scripts/cocci-macro-file.h +++ b/scripts/cocci-macro-file.h @@ -28,7 +28,7 @@ #define G_GNUC_UNUSED #define G_GNUC_NULL_TERMINATED #define G_GNUC_NORETURN -#define G_GNUC_NO_INLINE +#define G_NO_INLINE #define G_GNUC_FALLTHROUGH #define G_GNUC_PRINTF(a, b) diff --git a/scripts/mock-noinline.py b/scripts/mock-noinline.py index 13c296603d..ec617bbc2b 100644 --- a/scripts/mock-noinline.py +++ b/scripts/mock-noinline.py @@ -43,7 +43,7 @@ def scan_annotations(filename): elif line.isspace(): func = None - if "G_GNUC_NO_INLINE" in line: + if "G_NO_INLINE" in line: if func is not None: noninlined[func] = True @@ -73,7 +73,7 @@ warned = False for func in mocked.keys(): if func not in noninlined: warned = True - print("%s is mocked at %s but missing 'G_GNUC_NO_INLINE' annotation" % + print("%s is mocked at %s but missing 'G_NO_INLINE' annotation" % (func, mocked[func]), file=sys.stderr) if warned: diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 06b5858ef3..41a62ce486 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -212,7 +212,7 @@ virCPUGetHost(virArch arch, virDomainCapsCPUModels *models); virCPUDef * -virCPUProbeHost(virArch arch) G_GNUC_NO_INLINE; +virCPUProbeHost(virArch arch) G_NO_INLINE; virCPUDef * virCPUBaseline(virArch arch, diff --git a/src/libxl/libxl_capabilities.h b/src/libxl/libxl_capabilities.h index 6611786dd5..fd6332b63e 100644 --- a/src/libxl/libxl_capabilities.h +++ b/src/libxl/libxl_capabilities.h @@ -47,4 +47,4 @@ libxlMakeDomainCapabilities(virDomainCaps *domCaps, int libxlDomainGetEmulatorType(const virDomainDef *def) - G_GNUC_NO_INLINE; + G_NO_INLINE; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 67769fcfe4..d979a5ba3b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -845,7 +845,7 @@ virSEVCapability * virQEMUCapsGetSEVCapabilities(virQEMUCaps *qemuCaps); bool -virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps) G_GNUC_NO_INLINE; +virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps) G_NO_INLINE; virArch virQEMUCapsArchFromString(const char *arch); const char *virQEMUCapsArchToString(virArch arch); diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index fe24d01342..87368536ea 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -85,7 +85,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCaps *qemuCaps, virCPUDef * virQEMUCapsProbeHostCPU(virArch hostArch, - virDomainCapsCPUModels *models) G_GNUC_NO_INLINE; + virDomainCapsCPUModels *models) G_NO_INLINE; void virQEMUCapsSetGICCapabilities(virQEMUCaps *qemuCaps, diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index f8e9d71e81..6d2adcfc16 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -67,7 +67,7 @@ int qemuBuildTLSx509BackendProps(const char *tlspath, /* Open a UNIX socket for chardev FD passing */ int -qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) G_GNUC_NO_INLINE; +qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) G_NO_INLINE; virJSONValue * qemuBuildChrDeviceProps(const virDomainDef *vmdef, @@ -238,7 +238,7 @@ int qemuBuildTPMOpenBackendFDs(const char *tpmdev, int *tpmfd, int *cancelfd) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_NO_INLINE; const char * qemuAudioDriverTypeToString(virDomainAudioType type); virDomainAudioType qemuAudioDriverTypeFromString(const char *str); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 27e68370cf..6bc160de4a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5281,7 +5281,7 @@ qemuDomainResetDeviceRemoval(virDomainObj *vm) } -unsigned long long G_GNUC_NO_INLINE +unsigned long long G_NO_INLINE qemuDomainGetUnplugTimeout(virDomainObj *vm) { if (qemuDomainIsPSeries(vm->def)) diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 2b1e8085a4..f769bf6477 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -159,7 +159,7 @@ int qemuDomainSetVcpuInternal(virQEMUDriver *driver, virBitmap *vcpus, bool state); -unsigned long long qemuDomainGetUnplugTimeout(virDomainObj *vm) G_GNUC_NO_INLINE; +unsigned long long qemuDomainGetUnplugTimeout(virDomainObj *vm) G_NO_INLINE; int qemuHotplugAttachDBusVMState(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index d7ac6e6fc9..d866beb184 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -51,9 +51,9 @@ int qemuInterfaceBridgeConnect(virDomainDef *def, ATTRIBUTE_NONNULL(2); int qemuInterfaceOpenVhostNet(virDomainObj *def, - virDomainNetDef *net) G_GNUC_NO_INLINE; + virDomainNetDef *net) G_NO_INLINE; int qemuInterfacePrepareSlirp(virQEMUDriver *driver, virDomainNetDef *net); -int qemuInterfaceVDPAConnect(virDomainNetDef *net) G_GNUC_NO_INLINE; +int qemuInterfaceVDPAConnect(virDomainNetDef *net) G_NO_INLINE; diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f7e01f71fe..cc1a0bc8c9 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -435,7 +435,7 @@ int qemuMonitorSetLink(qemuMonitor *mon, /* These APIs are for use by the internal Text/JSON monitor impl code only */ char *qemuMonitorNextCommandID(qemuMonitor *mon); int qemuMonitorSend(qemuMonitor *mon, - qemuMonitorMessage *msg) G_GNUC_NO_INLINE; + qemuMonitorMessage *msg) G_NO_INLINE; int qemuMonitorUpdateVideoMemorySize(qemuMonitor *mon, virDomainVideoDef *video, const char *videoName) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 7006aa8c46..2759566892 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -31,7 +31,7 @@ int qemuMonitorJSONIOProcessLine(qemuMonitor *mon, const char *line, qemuMonitorMessage *msg) - G_GNUC_NO_INLINE; + G_NO_INLINE; int qemuMonitorJSONIOProcess(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor_priv.h b/src/qemu/qemu_monitor_priv.h index 05ac5499bb..2f7c662cef 100644 --- a/src/qemu/qemu_monitor_priv.h +++ b/src/qemu/qemu_monitor_priv.h @@ -101,4 +101,4 @@ qemuMonitorIOWriteWithFD(qemuMonitor *mon, const char *data, size_t len, int fd) - G_GNUC_NO_INLINE; + G_NO_INLINE; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 0fddae0bbb..55296e54e8 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -117,7 +117,7 @@ int qemuProcessPrepareHostHostdev(virDomainHostdevDef *hostdev); int qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm, virDomainDeviceDef *dev) - G_GNUC_NO_INLINE; + G_NO_INLINE; int qemuProcessPrepareHost(virQEMUDriver *driver, @@ -205,9 +205,9 @@ int qemuProcessRefreshDisks(virQEMUDriver *driver, virDomainObj *vm, virDomainAsyncJob asyncJob); -int qemuProcessStartManagedPRDaemon(virDomainObj *vm) G_GNUC_NO_INLINE; +int qemuProcessStartManagedPRDaemon(virDomainObj *vm) G_NO_INLINE; -void qemuProcessKillManagedPRDaemon(virDomainObj *vm) G_GNUC_NO_INLINE; +void qemuProcessKillManagedPRDaemon(virDomainObj *vm) G_NO_INLINE; typedef struct _qemuProcessQMP qemuProcessQMP; struct _qemuProcessQMP { diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h index 6fef8d30b3..fec84ca068 100644 --- a/src/rpc/virnetsocket.h +++ b/src/rpc/virnetsocket.h @@ -132,10 +132,10 @@ int virNetSocketGetUNIXIdentity(virNetSocket *sock, gid_t *gid, pid_t *pid, unsigned long long *timestamp) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virNetSocketGetSELinuxContext(virNetSocket *sock, char **context) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virNetSocketSetBlocking(virNetSocket *sock, bool blocking); 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) +# 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) */ diff --git a/src/util/vircgroupv2devices.h b/src/util/vircgroupv2devices.h index 1ff46987e8..d2d769ba5a 100644 --- a/src/util/vircgroupv2devices.h +++ b/src/util/vircgroupv2devices.h @@ -26,7 +26,7 @@ bool virCgroupV2DevicesAvailable(virCgroup *group) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virCgroupV2DevicesDetectProg(virCgroup *group); diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 21ef8ff663..c7a580e152 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -54,7 +54,7 @@ typedef enum { void virCommandPassFD(virCommand *cmd, int fd, - unsigned int flags) G_GNUC_NO_INLINE; + unsigned int flags) G_NO_INLINE; void virCommandSetPidFile(virCommand *cmd, const char *pidfile) ATTRIBUTE_NONNULL(2); diff --git a/src/util/virdevmapper.h b/src/util/virdevmapper.h index 4d8d3ccdb8..6972050bc5 100644 --- a/src/util/virdevmapper.h +++ b/src/util/virdevmapper.h @@ -24,7 +24,7 @@ int virDevMapperGetTargets(const char *path, - GSList **devPaths) G_GNUC_NO_INLINE; + GSList **devPaths) G_NO_INLINE; bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); diff --git a/src/util/virfile.h b/src/util/virfile.h index 8e378efe30..4af1ad9136 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -119,9 +119,9 @@ int virFileWrapperFdClose(virFileWrapperFd *dfd); void virFileWrapperFdFree(virFileWrapperFd *dfd); int virFileLock(int fd, bool shared, off_t start, off_t len, bool waitForLock) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virFileUnlock(int fd, off_t start, off_t len) - G_GNUC_NO_INLINE; + G_NO_INLINE; typedef int (*virFileRewriteFunc)(int fd, const char *path, @@ -188,7 +188,7 @@ int virFileIsLink(const char *linkpath) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; char *virFindFileInPath(const char *file) - G_GNUC_NO_INLINE; + G_NO_INLINE; char *virFileFindResource(const char *filename, const char *builddir, @@ -207,7 +207,7 @@ void virFileActivateDirOverrideForLib(void); off_t virFileLength(const char *path, int fd) ATTRIBUTE_NONNULL(1); bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1); -bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_GNUC_NO_INLINE; +bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_NO_INLINE; bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1); bool virFileIsRegular(const char *file) ATTRIBUTE_NONNULL(1); @@ -241,7 +241,7 @@ int virFileGetMountReverseSubtree(const char *mtabpath, size_t *nmountsret) G_GNUC_WARN_UNUSED_RESULT; char *virFileSanitizePath(const char *path); -char *virFileCanonicalizePath(const char *path) G_GNUC_NO_INLINE; +char *virFileCanonicalizePath(const char *path) G_NO_INLINE; enum { VIR_FILE_OPEN_NONE = 0, @@ -363,21 +363,21 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virFileWrapperFd, virFileWrapperFdFree); int virFileGetXAttr(const char *path, const char *name, char **value) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virFileGetXAttrQuiet(const char *path, const char *name, char **value) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virFileSetXAttr(const char *path, const char *name, const char *value) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virFileRemoveXAttr(const char *path, const char *name) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virFileDataSync(int fd); diff --git a/src/util/virhashcode.h b/src/util/virhashcode.h index 10d8451795..5c68e5a89a 100644 --- a/src/util/virhashcode.h +++ b/src/util/virhashcode.h @@ -30,4 +30,4 @@ #include "internal.h" uint32_t virHashCodeGen(const void *key, size_t len, uint32_t seed) - G_GNUC_NO_INLINE; + G_NO_INLINE; diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index 86a231daa2..b8ea7aafad 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -45,7 +45,7 @@ virBitmap *virHostCPUGetOnlineBitmap(void); virBitmap *virHostCPUGetAvailableCPUsBitmap(void); int virHostCPUGetCount(void); -int virHostCPUGetThreadsPerSubcore(virArch arch) G_GNUC_NO_INLINE; +int virHostCPUGetThreadsPerSubcore(virArch arch) G_NO_INLINE; int virHostCPUGetMap(unsigned char **cpumap, unsigned int *online, @@ -58,7 +58,7 @@ int virHostCPUGetInfo(virArch hostarch, unsigned int *cores, unsigned int *threads); -int virHostCPUGetKVMMaxVCPUs(void) G_GNUC_NO_INLINE; +int virHostCPUGetKVMMaxVCPUs(void) G_NO_INLINE; int virHostCPUStatsAssign(virNodeCPUStatsPtr param, const char *name, @@ -75,7 +75,7 @@ virBitmap *virHostCPUGetSiblingsList(unsigned int cpu); int virHostCPUGetOnline(unsigned int cpu, bool *online); unsigned int -virHostCPUGetMicrocodeVersion(virArch hostArch) G_GNUC_NO_INLINE; +virHostCPUGetMicrocodeVersion(virArch hostArch) G_NO_INLINE; int virHostCPUGetMSR(unsigned long index, uint64_t *msr); diff --git a/src/util/virhostmem.h b/src/util/virhostmem.h index c36de94f0f..79e1a300a8 100644 --- a/src/util/virhostmem.h +++ b/src/util/virhostmem.h @@ -57,4 +57,4 @@ int virHostMemAllocPages(unsigned int npages, bool add); int virHostMemGetTHPSize(unsigned long long *size) - G_GNUC_NO_INLINE; + G_NO_INLINE; diff --git a/src/util/virhostuptime.h b/src/util/virhostuptime.h index 1ac638fd6e..44a91b5b52 100644 --- a/src/util/virhostuptime.h +++ b/src/util/virhostuptime.h @@ -24,7 +24,7 @@ int virHostGetBootTime(unsigned long long *when) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virHostBootTimeInit(void); diff --git a/src/util/viridentitypriv.h b/src/util/viridentitypriv.h index e5ca8430f8..63357d891a 100644 --- a/src/util/viridentitypriv.h +++ b/src/util/viridentitypriv.h @@ -27,4 +27,4 @@ #include "viridentity.h" char * -virIdentityEnsureSystemToken(void) G_GNUC_NO_INLINE; +virIdentityEnsureSystemToken(void) G_NO_INLINE; diff --git a/src/util/virmacaddr.h b/src/util/virmacaddr.h index 1a46565fe6..f32b58805a 100644 --- a/src/util/virmacaddr.h +++ b/src/util/virmacaddr.h @@ -49,7 +49,7 @@ void virMacAddrGetRaw(const virMacAddr *src, unsigned char dst[VIR_MAC_BUFLEN]); const char *virMacAddrFormat(const virMacAddr *addr, char *str); void virMacAddrGenerate(const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN], - virMacAddr *addr) G_GNUC_NO_INLINE; + virMacAddr *addr) G_NO_INLINE; int virMacAddrParse(const char* str, virMacAddr *addr) G_GNUC_WARN_UNUSED_RESULT; int virMacAddrParseHex(const char* str, diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 790fae5f7a..05daed09e9 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -168,11 +168,11 @@ int virNetDevSetupControl(const char *ifname, G_GNUC_WARN_UNUSED_RESULT; int virNetDevExists(const char *brname) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevSetOnline(const char *ifname, bool online) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevGetOnline(const char *ifname, bool *online) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; @@ -180,7 +180,7 @@ int virNetDevGetOnline(const char *ifname, int virNetDevSetMAC(const char *ifname, const virMacAddr *macaddr) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevGetMAC(const char *ifname, virMacAddr *macaddr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; @@ -324,10 +324,10 @@ int virNetDevSysfsFile(char **pf_sysfs_device_link, const char *ifname, const char *file) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevRunEthernetScript(const char *ifname, const char *script) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virNetDevVFInterfaceStats(virPCIDeviceAddress *vfAddr, virDomainInterfaceStatsPtr stats) diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h index c82029fc0f..6d268fb119 100644 --- a/src/util/virnetdevbandwidth.h +++ b/src/util/virnetdevbandwidth.h @@ -77,4 +77,4 @@ int virNetDevBandwidthUpdateFilter(const char *ifname, int virNetDevBandwidthSetRootQDisc(const char *ifname, const char *qdisc) - G_GNUC_NO_INLINE; + G_NO_INLINE; diff --git a/src/util/virnetdevip.h b/src/util/virnetdevip.h index 136048090d..fdf116f509 100644 --- a/src/util/virnetdevip.h +++ b/src/util/virnetdevip.h @@ -59,7 +59,7 @@ int virNetDevIPAddrAdd(const char *ifname, virSocketAddr *addr, virSocketAddr *peer, unsigned int prefix) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevIPRouteAdd(const char *ifname, virSocketAddr *addr, unsigned int prefix, diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h index 405e48088f..29bb8123f4 100644 --- a/src/util/virnetdevmacvlan.h +++ b/src/util/virnetdevmacvlan.h @@ -47,7 +47,7 @@ typedef enum { } virNetDevMacVLanCreateFlags; bool virNetDevMacVLanIsMacvtap(const char *ifname) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevMacVLanCreate(const char *ifname, const virMacAddr *macaddress, diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h index b16c8fe318..e6ee985f17 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -65,7 +65,7 @@ virNetDevOpenvswitchMaybeUnescapeReply(char *reply) int virNetDevOpenvswitchGetVhostuserIfname(const char *path, bool server, char **ifname) - ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevOpenvswitchUpdateVlan(const char *ifname, const virNetDevVlan *virtVlan) diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h index 922682adae..197ea10f94 100644 --- a/src/util/virnetdevtap.h +++ b/src/util/virnetdevtap.h @@ -34,7 +34,7 @@ int virNetDevTapCreate(char **ifname, int *tapfd, size_t tapfdSize, unsigned int flags) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevTapDelete(const char *ifname, const char *tunpath) @@ -44,7 +44,7 @@ int virNetDevTapGetName(int tapfd, char **ifname) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; char* virNetDevTapGetRealDeviceName(char *ifname) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; typedef enum { VIR_NETDEV_TAP_CREATE_NONE = 0, @@ -99,7 +99,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, unsigned int *actualMTU, unsigned int flags) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) - G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; + G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; int virNetDevTapInterfaceStats(const char *ifname, virDomainInterfaceStatsPtr stats, diff --git a/src/util/virnuma.h b/src/util/virnuma.h index bc79bff891..c35acd47cb 100644 --- a/src/util/virnuma.h +++ b/src/util/virnuma.h @@ -32,20 +32,20 @@ int virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode, virBitmap *nodeset); virBitmap *virNumaGetHostMemoryNodeset(void); -bool virNumaNodesetIsAvailable(virBitmap *nodeset) G_GNUC_NO_INLINE; -bool virNumaIsAvailable(void) G_GNUC_NO_INLINE; -int virNumaGetMaxNode(void) G_GNUC_NO_INLINE; -bool virNumaNodeIsAvailable(int node) G_GNUC_NO_INLINE; +bool virNumaNodesetIsAvailable(virBitmap *nodeset) G_NO_INLINE; +bool virNumaIsAvailable(void) G_NO_INLINE; +int virNumaGetMaxNode(void) G_NO_INLINE; +bool virNumaNodeIsAvailable(int node) G_NO_INLINE; int virNumaGetDistances(int node, int **distances, - int *ndistances) G_GNUC_NO_INLINE; + int *ndistances) G_NO_INLINE; int virNumaGetNodeMemory(int node, unsigned long long *memsize, - unsigned long long *memfree) G_GNUC_NO_INLINE; + unsigned long long *memfree) G_NO_INLINE; -unsigned int virNumaGetMaxCPUs(void) G_GNUC_NO_INLINE; +unsigned int virNumaGetMaxCPUs(void) G_NO_INLINE; -int virNumaGetNodeCPUs(int node, virBitmap **cpus) G_GNUC_NO_INLINE; +int virNumaGetNodeCPUs(int node, virBitmap **cpus) G_NO_INLINE; int virNumaNodesetToCPUset(virBitmap *nodeset, virBitmap **cpuset); @@ -59,7 +59,7 @@ int virNumaGetPages(int node, unsigned long long **pages_avail, unsigned long long **pages_free, size_t *npages) - ATTRIBUTE_NONNULL(5) G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(5) G_NO_INLINE; int virNumaSetPagePoolSize(int node, unsigned int page_size, unsigned long long page_count, diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 086fbe0e4d..30b6981c73 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -77,12 +77,12 @@ int virProcessGetNamespaces(pid_t pid, int virProcessSetNamespaces(size_t nfdlist, int *fdlist); -int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes) G_GNUC_NO_INLINE; +int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes) G_NO_INLINE; int virProcessSetMaxProcesses(pid_t pid, unsigned int procs); int virProcessSetMaxFiles(pid_t pid, unsigned int files); int virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes); -int virProcessGetMaxMemLock(pid_t pid, unsigned long long *bytes) G_GNUC_NO_INLINE; +int virProcessGetMaxMemLock(pid_t pid, unsigned long long *bytes) G_NO_INLINE; /* Callback to run code within the mount namespace tied to the given * pid. This function must use only async-signal-safe functions, as @@ -110,7 +110,7 @@ typedef int (*virProcessForkCallback)(pid_t ppid, int virProcessRunInFork(virProcessForkCallback cb, void *opaque) - G_GNUC_NO_INLINE; + G_NO_INLINE; int virProcessSetupPrivateMountNS(void); diff --git a/src/util/virrandom.h b/src/util/virrandom.h index aac684ada9..8a20401954 100644 --- a/src/util/virrandom.h +++ b/src/util/virrandom.h @@ -20,10 +20,10 @@ #include "internal.h" -uint64_t virRandomBits(int nbits) G_GNUC_NO_INLINE; +uint64_t virRandomBits(int nbits) G_NO_INLINE; double virRandom(void); uint32_t virRandomInt(uint32_t max); int virRandomBytes(unsigned char *buf, size_t buflen) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE; -int virRandomGenerateWWN(char **wwn, const char *virt_type) G_GNUC_NO_INLINE; + ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE; +int virRandomGenerateWWN(char **wwn, const char *virt_type) G_NO_INLINE; char *virRandomToken(size_t len); diff --git a/src/util/virscsi.h b/src/util/virscsi.h index 65ad15ed76..ec34303bdc 100644 --- a/src/util/virscsi.h +++ b/src/util/virscsi.h @@ -34,7 +34,7 @@ char *virSCSIDeviceGetSgName(const char *sysfs_prefix, const char *adapter, unsigned int bus, unsigned int target, - unsigned long long unit) G_GNUC_NO_INLINE; + unsigned long long unit) G_NO_INLINE; char *virSCSIDeviceGetDevName(const char *sysfs_prefix, const char *adapter, unsigned int bus, diff --git a/src/util/virscsivhost.h b/src/util/virscsivhost.h index d030aea397..a7299382db 100644 --- a/src/util/virscsivhost.h +++ b/src/util/virscsivhost.h @@ -57,6 +57,6 @@ void virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevice *dev, const char **drv_name, const char **dom_name); void virSCSIVHostDeviceFree(virSCSIVHostDevice *dev); -int virSCSIVHostOpenVhostSCSI(int *vhostfd) G_GNUC_NO_INLINE; +int virSCSIVHostOpenVhostSCSI(int *vhostfd) G_NO_INLINE; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSCSIVHostDevice, virSCSIVHostDeviceFree); diff --git a/src/util/virtpm.h b/src/util/virtpm.h index bbf379a54a..89adbdf720 100644 --- a/src/util/virtpm.h +++ b/src/util/virtpm.h @@ -20,7 +20,7 @@ #pragma once -char *virTPMCreateCancelPath(const char *devpath) G_GNUC_NO_INLINE; +char *virTPMCreateCancelPath(const char *devpath) G_NO_INLINE; char *virTPMGetSwtpm(void); char *virTPMGetSwtpmSetup(void); diff --git a/src/util/virutil.h b/src/util/virutil.h index 6adebde242..ab8511bf8d 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -89,17 +89,17 @@ static inline int pthread_sigmask(int how, } #endif -char *virGetHostname(void) G_GNUC_NO_INLINE; +char *virGetHostname(void) G_NO_INLINE; char *virGetHostnameQuiet(void); char *virGetUserDirectory(void); char *virGetUserDirectoryByUID(uid_t uid); char *virGetUserConfigDirectory(void); char *virGetUserCacheDirectory(void); -char *virGetUserRuntimeDirectory(void) G_GNUC_NO_INLINE; +char *virGetUserRuntimeDirectory(void) G_NO_INLINE; char *virGetUserShell(uid_t uid); -char *virGetUserName(uid_t uid) G_GNUC_NO_INLINE; -char *virGetGroupName(gid_t gid) G_GNUC_NO_INLINE; +char *virGetUserName(uid_t uid) G_NO_INLINE; +char *virGetGroupName(gid_t gid) G_NO_INLINE; int virGetGroupList(uid_t uid, gid_t group, gid_t **groups) ATTRIBUTE_NONNULL(3); int virGetUserID(const char *name, @@ -119,16 +119,16 @@ int virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr); time_t virGetSelfLastChanged(void); void virUpdateSelfLastChanged(const char *path); -long virGetSystemPageSize(void) G_GNUC_NO_INLINE; -long virGetSystemPageSizeKB(void) G_GNUC_NO_INLINE; +long virGetSystemPageSize(void) G_NO_INLINE; +long virGetSystemPageSizeKB(void) G_NO_INLINE; unsigned long long virMemoryLimitTruncate(unsigned long long value); bool virMemoryLimitIsSet(unsigned long long value); -unsigned long long virMemoryMaxValue(bool ulong) G_GNUC_NO_INLINE; +unsigned long long virMemoryMaxValue(bool ulong) G_NO_INLINE; bool virHostHasIOMMU(void); -char *virHostGetDRMRenderNode(void) G_GNUC_NO_INLINE; +char *virHostGetDRMRenderNode(void) G_NO_INLINE; /* Kernel cmdline match and comparison strategy for arg=value pairs */ typedef enum { diff --git a/src/util/viruuid.h b/src/util/viruuid.h index b403b1906a..9667bd3200 100644 --- a/src/util/viruuid.h +++ b/src/util/viruuid.h @@ -41,11 +41,11 @@ int virSetHostUUIDStr(const char *host_uuid); -int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1) G_GNUC_NO_INLINE; +int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1) G_NO_INLINE; bool virUUIDIsValid(const unsigned char *uuid); -int virUUIDGenerate(unsigned char *uuid) G_GNUC_NO_INLINE; +int virUUIDGenerate(unsigned char *uuid) G_NO_INLINE; int virUUIDParse(const char *uuidstr, unsigned char *uuid) -- 2.35.1

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/15cd0f04612c90292792c4d123ebe84...
Signed-off-by: Michal Privoznik <mprivozn@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) */
[...]

On 7/18/22 17:01, Pavel Hrdina wrote:
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/15cd0f04612c90292792c4d123ebe84...
Signed-off-by: Michal Privoznik <mprivozn@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.
Yeah, so let's go with: #if !GLIB_CHECK_VERSION(2, 73, 2) Fixed locally. Michal

On Mon, Jul 18, 2022 at 05:11:22PM +0200, Michal Prívozník wrote:
On 7/18/22 17:01, Pavel Hrdina wrote:
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/15cd0f04612c90292792c4d123ebe84...
Signed-off-by: Michal Privoznik <mprivozn@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.
Yeah, so let's go with:
#if !GLIB_CHECK_VERSION(2, 73, 2)
Fixed locally.
Michal
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
participants (3)
-
Michal Privoznik
-
Michal Prívozník
-
Pavel Hrdina