Use G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE

Define the macro for older GLib versions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2019-10-15 13:24:34 +02:00
parent ec96b74041
commit d54153fde3
24 changed files with 58 additions and 56 deletions

View File

@ -46,7 +46,7 @@ sub scan_annotations {
} elsif (/^\s*$/) {
$func = undef;
}
if (/ATTRIBUTE_NOINLINE/) {
if (/G_GNUC_NO_INLINE/) {
if (defined $func) {
$noninlined{$func} = 1;
}

View File

@ -629,7 +629,7 @@ sc_avoid_g_gnuc_unused_in_header:
$(_sc_search_regexp)
sc_prohibit_attribute_macros:
@prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK)' \
@prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK|NOINLINE)' \
in_vc_files='\.[ch]$$' \
halt='use GLib macros: G_GNUC_<ATTRIBUTE_SUFFIX> for most' \
$(_sc_search_regexp)

View File

@ -94,13 +94,15 @@
#define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
/**
* ATTRIBUTE_NOINLINE:
* 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 ATTRIBUTE_NOINLINE
# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
#ifndef G_GNUC_NO_INLINE
# define G_GNUC_NO_INLINE __attribute__((__noinline__))
#endif
/**

View File

@ -83,7 +83,7 @@ virQEMUCapsGetCPUModelX86Data(virQEMUCapsPtr qemuCaps,
virCPUDefPtr
virQEMUCapsProbeHostCPU(virArch hostArch,
virDomainCapsCPUModelsPtr models) ATTRIBUTE_NOINLINE;
virDomainCapsCPUModelsPtr models) G_GNUC_NO_INLINE;
void
virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,

View File

@ -136,10 +136,10 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
gid_t *gid,
pid_t *pid,
unsigned long long *timestamp)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virNetSocketGetSELinuxContext(virNetSocketPtr sock,
char **context)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virNetSocketSetBlocking(virNetSocketPtr sock,
bool blocking);

View File

@ -58,7 +58,7 @@ typedef enum {
void virCommandPassFD(virCommandPtr cmd,
int fd,
unsigned int flags) ATTRIBUTE_NOINLINE;
unsigned int flags) G_GNUC_NO_INLINE;
int virCommandPassFDGetFDIndex(virCommandPtr cmd,
int fd);

View File

@ -114,9 +114,9 @@ int virFileWrapperFdClose(virFileWrapperFdPtr dfd);
void virFileWrapperFdFree(virFileWrapperFdPtr dfd);
int virFileLock(int fd, bool shared, off_t start, off_t len, bool waitForLock)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virFileUnlock(int fd, off_t start, off_t len)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virFileFlock(int fd, bool lock, bool shared);
@ -199,7 +199,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) ATTRIBUTE_NOINLINE;
bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_GNUC_NO_INLINE;
bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1);
bool virFileIsRegular(const char *file) ATTRIBUTE_NONNULL(1);
@ -231,7 +231,7 @@ int virFileGetMountReverseSubtree(const char *mtabpath,
size_t *nmountsret) G_GNUC_WARN_UNUSED_RESULT;
char *virFileSanitizePath(const char *path);
char *virFileCanonicalizePath(const char *path) ATTRIBUTE_NOINLINE;
char *virFileCanonicalizePath(const char *path) G_GNUC_NO_INLINE;
enum {
VIR_FILE_OPEN_NONE = 0,
@ -383,18 +383,18 @@ VIR_DEFINE_AUTOPTR_FUNC(virFileWrapperFd, virFileWrapperFdFree);
int virFileGetXAttr(const char *path,
const char *name,
char **value)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virFileGetXAttrQuiet(const char *path,
const char *name,
char **value)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virFileSetXAttr(const char *path,
const char *name,
const char *value)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virFileRemoveXAttr(const char *path,
const char *name)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;

View File

@ -30,4 +30,4 @@
#include "internal.h"
uint32_t virHashCodeGen(const void *key, size_t len, uint32_t seed)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;

View File

@ -44,7 +44,7 @@ bool virHostCPUHasBitmap(void);
virBitmapPtr virHostCPUGetPresentBitmap(void);
virBitmapPtr virHostCPUGetOnlineBitmap(void);
int virHostCPUGetCount(void);
int virHostCPUGetThreadsPerSubcore(virArch arch) ATTRIBUTE_NOINLINE;
int virHostCPUGetThreadsPerSubcore(virArch arch) G_GNUC_NO_INLINE;
int virHostCPUGetMap(unsigned char **cpumap,
unsigned int *online,
@ -57,7 +57,7 @@ int virHostCPUGetInfo(virArch hostarch,
unsigned int *cores,
unsigned int *threads);
int virHostCPUGetKVMMaxVCPUs(void) ATTRIBUTE_NOINLINE;
int virHostCPUGetKVMMaxVCPUs(void) G_GNUC_NO_INLINE;
int virHostCPUStatsAssign(virNodeCPUStatsPtr param,
const char *name,

View File

@ -24,4 +24,4 @@
int
virHostGetBootTime(unsigned long long *when)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;

View File

@ -52,7 +52,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],
virMacAddrPtr addr) ATTRIBUTE_NOINLINE;
virMacAddrPtr addr) G_GNUC_NO_INLINE;
int virMacAddrParse(const char* str,
virMacAddrPtr addr) G_GNUC_WARN_UNUSED_RESULT;
int virMacAddrParseHex(const char* str,

View File

@ -150,11 +150,11 @@ int virNetDevSetupControl(const char *ifname,
G_GNUC_WARN_UNUSED_RESULT;
int virNetDevExists(const char *brname)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevSetOnline(const char *ifname,
bool online)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevGetOnline(const char *ifname,
bool *online)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
@ -162,7 +162,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 ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevGetMAC(const char *ifname,
virMacAddrPtr macaddr)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
@ -306,9 +306,9 @@ 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 ATTRIBUTE_NOINLINE;
G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevRunEthernetScript(const char *ifname, const char *script)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
VIR_DEFINE_AUTOPTR_FUNC(virNetDevRxFilter, virNetDevRxFilterFree);

View File

@ -63,7 +63,7 @@ int virNetDevIPAddrAdd(const char *ifname,
virSocketAddr *addr,
virSocketAddr *peer,
unsigned int prefix)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevIPRouteAdd(const char *ifname,
virSocketAddrPtr addr,
unsigned int prefix,

View File

@ -58,7 +58,7 @@ int virNetDevMacVLanReserveName(const char *name, bool quietfail);
int virNetDevMacVLanReleaseName(const char *name);
bool virNetDevMacVLanIsMacvtap(const char *ifname)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevMacVLanCreate(const char *ifname,
const char *type,

View File

@ -62,7 +62,7 @@ int virNetDevOpenvswitchInterfaceGetMaster(const char *ifname, char **master)
int virNetDevOpenvswitchGetVhostuserIfname(const char *path,
char **ifname)
ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevOpenvswitchUpdateVlan(const char *ifname,
virNetDevVlanPtr virtVlan)

View File

@ -34,7 +34,7 @@ int virNetDevTapCreate(char **ifname,
int *tapfd,
size_t tapfdSize,
unsigned int flags)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_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 ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
typedef enum {
VIR_NETDEV_TAP_CREATE_NONE = 0,
@ -96,7 +96,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 ATTRIBUTE_NOINLINE;
G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virNetDevTapInterfaceStats(const char *ifname,
virDomainInterfaceStatsPtr stats,

View File

@ -33,20 +33,20 @@ int virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode,
virBitmapPtr nodeset);
virBitmapPtr virNumaGetHostMemoryNodeset(void);
bool virNumaNodesetIsAvailable(virBitmapPtr nodeset) ATTRIBUTE_NOINLINE;
bool virNumaIsAvailable(void) ATTRIBUTE_NOINLINE;
int virNumaGetMaxNode(void) ATTRIBUTE_NOINLINE;
bool virNumaNodeIsAvailable(int node) ATTRIBUTE_NOINLINE;
bool virNumaNodesetIsAvailable(virBitmapPtr 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;
int virNumaGetDistances(int node,
int **distances,
int *ndistances) ATTRIBUTE_NOINLINE;
int *ndistances) G_GNUC_NO_INLINE;
int virNumaGetNodeMemory(int node,
unsigned long long *memsize,
unsigned long long *memfree) ATTRIBUTE_NOINLINE;
unsigned long long *memfree) G_GNUC_NO_INLINE;
unsigned int virNumaGetMaxCPUs(void);
int virNumaGetNodeCPUs(int node, virBitmapPtr *cpus) ATTRIBUTE_NOINLINE;
int virNumaGetNodeCPUs(int node, virBitmapPtr *cpus) G_GNUC_NO_INLINE;
int virNumaNodesetToCPUset(virBitmapPtr nodeset,
virBitmapPtr *cpuset);
@ -60,7 +60,7 @@ int virNumaGetPages(int node,
unsigned long long **pages_avail,
unsigned long long **pages_free,
size_t *npages)
ATTRIBUTE_NONNULL(5) ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(5) G_GNUC_NO_INLINE;
int virNumaSetPagePoolSize(int node,
unsigned int page_size,
unsigned long long page_count,

View File

@ -75,7 +75,7 @@ int virProcessGetNamespaces(pid_t pid,
int virProcessSetNamespaces(size_t nfdlist,
int *fdlist);
int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes) ATTRIBUTE_NOINLINE;
int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes) G_GNUC_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);
@ -108,7 +108,7 @@ typedef int (*virProcessForkCallback)(pid_t ppid,
int virProcessRunInFork(virProcessForkCallback cb,
void *opaque)
ATTRIBUTE_NOINLINE;
G_GNUC_NO_INLINE;
int virProcessSetupPrivateMountNS(void);

View File

@ -20,9 +20,9 @@
#include "internal.h"
uint64_t virRandomBits(int nbits) ATTRIBUTE_NOINLINE;
uint64_t virRandomBits(int nbits) G_GNUC_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 ATTRIBUTE_NOINLINE;
int virRandomGenerateWWN(char **wwn, const char *virt_type) ATTRIBUTE_NOINLINE;
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
int virRandomGenerateWWN(char **wwn, const char *virt_type) G_GNUC_NO_INLINE;

View File

@ -37,7 +37,7 @@ char *virSCSIDeviceGetSgName(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,
unsigned int target,
unsigned long long unit) ATTRIBUTE_NOINLINE;
unsigned long long unit) G_GNUC_NO_INLINE;
char *virSCSIDeviceGetDevName(const char *sysfs_prefix,
const char *adapter,
unsigned int bus,

View File

@ -61,6 +61,6 @@ void virSCSIVHostDeviceGetUsedBy(virSCSIVHostDevicePtr dev,
const char **drv_name,
const char **dom_name);
void virSCSIVHostDeviceFree(virSCSIVHostDevicePtr dev);
int virSCSIVHostOpenVhostSCSI(int *vhostfd) ATTRIBUTE_NOINLINE;
int virSCSIVHostOpenVhostSCSI(int *vhostfd) G_GNUC_NO_INLINE;
VIR_DEFINE_AUTOPTR_FUNC(virSCSIVHostDevice, virSCSIVHostDeviceFree);

View File

@ -20,7 +20,7 @@
#pragma once
char *virTPMCreateCancelPath(const char *devpath) ATTRIBUTE_NOINLINE;
char *virTPMCreateCancelPath(const char *devpath) G_GNUC_NO_INLINE;
char *virTPMGetSwtpm(void);
char *virTPMGetSwtpmSetup(void);

View File

@ -103,8 +103,8 @@ char *virGetUserConfigDirectory(void);
char *virGetUserCacheDirectory(void);
char *virGetUserRuntimeDirectory(void);
char *virGetUserShell(uid_t uid);
char *virGetUserName(uid_t uid) ATTRIBUTE_NOINLINE;
char *virGetGroupName(gid_t gid) ATTRIBUTE_NOINLINE;
char *virGetUserName(uid_t uid) G_GNUC_NO_INLINE;
char *virGetGroupName(gid_t gid) G_GNUC_NO_INLINE;
int virGetGroupList(uid_t uid, gid_t group, gid_t **groups)
ATTRIBUTE_NONNULL(3);
int virGetUserID(const char *name,
@ -138,16 +138,16 @@ int virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr);
time_t virGetSelfLastChanged(void);
void virUpdateSelfLastChanged(const char *path);
long virGetSystemPageSize(void) ATTRIBUTE_NOINLINE;
long virGetSystemPageSizeKB(void) ATTRIBUTE_NOINLINE;
long virGetSystemPageSize(void) G_GNUC_NO_INLINE;
long virGetSystemPageSizeKB(void) G_GNUC_NO_INLINE;
unsigned long long virMemoryLimitTruncate(unsigned long long value);
bool virMemoryLimitIsSet(unsigned long long value);
unsigned long long virMemoryMaxValue(bool ulong) ATTRIBUTE_NOINLINE;
unsigned long long virMemoryMaxValue(bool ulong) G_GNUC_NO_INLINE;
bool virHostHasIOMMU(void);
char *virHostGetDRMRenderNode(void) ATTRIBUTE_NOINLINE;
char *virHostGetDRMRenderNode(void) G_GNUC_NO_INLINE;
/**
* VIR_ASSIGN_IS_OVERFLOW:

View File

@ -45,7 +45,7 @@ int virGetHostUUID(unsigned char *host_uuid) ATTRIBUTE_NONNULL(1);
int virUUIDIsValid(unsigned char *uuid);
int virUUIDGenerate(unsigned char *uuid) ATTRIBUTE_NOINLINE;
int virUUIDGenerate(unsigned char *uuid) G_GNUC_NO_INLINE;
int virUUIDParse(const char *uuidstr,
unsigned char *uuid)