From be2cd24b129c12007be75c291992a8290d22353b Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Tue, 22 Aug 2023 12:35:38 +0200 Subject: [PATCH] compiler.h: Don't use asm and typeof with non-GNU compilers. 'asm' is a GNU extension. Compilers without GNU extensions do not understand it: dpif-netdev-perf.h:225:5: error: use of undeclared identifier 'asm' asm volatile("rdtsc" : "=a" (l), "=d" (h)); Redefining asm as __asm__ for non-C++ compilers that do not have it defined. While at it, also add typeof definition. It doesn't need a check for C++, because it's not a keyword in C++. Acked-by: Eelco Chaudron Signed-off-by: Ilya Maximets --- include/openvswitch/compiler.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/openvswitch/compiler.h b/include/openvswitch/compiler.h index cf009f826..52614a5ac 100644 --- a/include/openvswitch/compiler.h +++ b/include/openvswitch/compiler.h @@ -37,6 +37,16 @@ #define OVS_NO_RETURN #endif +#ifndef typeof +#define typeof __typeof__ +#endif + +#ifndef __cplusplus +#ifndef asm +#define asm __asm__ +#endif +#endif + #if __GNUC__ && !__CHECKER__ #define OVS_UNUSED __attribute__((__unused__)) #define OVS_PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1)))