Skip to content

Commit

Permalink
eal: fix internal ABI tag with clang
Browse files Browse the repository at this point in the history
[ upstream commit 4ab63cd ]

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: fba5af8 ("eal: add internal ABI tag definition")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
  • Loading branch information
bruce-richardson authored and bluca committed Feb 4, 2021
1 parent 364e006 commit 527f81e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/librte_eal/include/rte_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 527f81e

Please sign in to comment.