platform: make nm_platform_kernel_support_get() macro an inline function

clang (3.4.2-9.el7) on CentOS 7.6 fails related to nm_hash_update_vals().

I am not even quoting the error message, it's totally non-understandable.

nm_hash_update_vals() uses typeof(), and in some obscure cases, clang dislikes
when the argument itself is some complex macro. I didn't fully understand why,
but this works around it.

I would prefer to fix nm_hash_update_vals() to not have this limitation.
But I don't know how.

There is probably no downside to have this an inline function instead of
a macro.
This commit is contained in:
Thomas Haller 2019-05-28 14:56:50 +02:00
parent 3d42b2f1fa
commit ad06cc78dc

View file

@ -919,28 +919,28 @@ extern volatile int _nm_platform_kernel_support_state[_NM_PLATFORM_KERNEL_SUPPOR
int _nm_platform_kernel_support_init (NMPlatformKernelSupportType type,
int value);
#define _nm_platform_kernel_support_detected(type) \
G_LIKELY (({ \
const NMPlatformKernelSupportType _type = (type); \
\
nm_assert (_NM_INT_NOT_NEGATIVE (_type) && _type < G_N_ELEMENTS (_nm_platform_kernel_support_state)); \
\
(_nm_platform_kernel_support_state[_type] != 0); \
}))
static inline gboolean
_nm_platform_kernel_support_detected (NMPlatformKernelSupportType type)
{
nm_assert ( _NM_INT_NOT_NEGATIVE (type)
&& type < G_N_ELEMENTS (_nm_platform_kernel_support_state));
#define nm_platform_kernel_support_get(type) \
({ \
const NMPlatformKernelSupportType _type = (type); \
int _v; \
\
nm_assert (_NM_INT_NOT_NEGATIVE (_type) && _type < G_N_ELEMENTS (_nm_platform_kernel_support_state)); \
\
_v = _nm_platform_kernel_support_state[_type]; \
if (G_UNLIKELY (_v == 0)) \
_v = _nm_platform_kernel_support_init (_type, 0); \
\
(_v >= 0); \
})
return G_LIKELY (_nm_platform_kernel_support_state[type] != 0);
}
static inline gboolean
nm_platform_kernel_support_get (NMPlatformKernelSupportType type)
{
int v;
nm_assert (_NM_INT_NOT_NEGATIVE (type)
&& type < G_N_ELEMENTS (_nm_platform_kernel_support_state));
v = _nm_platform_kernel_support_state[type];
if (G_UNLIKELY (v == 0))
v = _nm_platform_kernel_support_init (type, 0);
return (v >= 0);
}
/*****************************************************************************/