From: Bruce Richardson Date: Fri, 29 Jan 2021 16:48:16 +0000 (+0000) Subject: eal: fix internal ABI tag with clang X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4ab63cd60ceb343db43da8ed060e45e165393dae;p=dpdk.git eal: fix internal ABI tag with clang Clang does not have an "error" attribute for functions, so for marking internal functions we need to check for the error attribute, and provide a fallback if it is not present. For clang, we can use "diagnose_if" attribute, similarly checking for its presence before use. Fixes: fba5af82adc8 ("eal: add internal ABI tag definition") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson --- diff --git a/lib/librte_eal/include/rte_compat.h b/lib/librte_eal/include/rte_compat.h index 4cd8f68d68..2718612cce 100644 --- a/lib/librte_eal/include/rte_compat.h +++ b/lib/librte_eal/include/rte_compat.h @@ -19,12 +19,23 @@ __attribute__((section(".text.experimental"))) #endif -#ifndef ALLOW_INTERNAL_API +#ifndef __has_attribute +/* if no has_attribute assume no support for attribute too */ +#define __has_attribute(x) 0 +#endif + +#if !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */ #define __rte_internal \ __attribute__((error("Symbol is not public ABI"), \ section(".text.internal"))) +#elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */ + +#define __rte_internal \ +__attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \ +section(".text.internal"))) + #else #define __rte_internal \