diff options
author | Roland McGrath <mcgrathr@google.com> | 2023-05-16 14:53:03 -0700 |
---|---|---|
committer | Roland McGrath <mcgrathr@google.com> | 2023-05-16 15:11:37 -0700 |
commit | 2c874d2128e35bb38817f349cfdfe9eca7281c9d (patch) | |
tree | a7f49d54d08d515bb7dce43d3e2947742692bde9 | |
parent | ede83e0eb8d1a4ca5279ed57c1d9f54f42fa8342 (diff) | |
download | llvm-2c874d2128e35bb38817f349cfdfe9eca7281c9d.tar.gz |
[libc] Fix definition and use of LIBC_INLINE macro
LIBC_INLINE was doubly defined in two headers. Define it only in
one place. Also update a few uses to make sure it's always placed
where a function attribute is valid and is used consistently on
every declaration of the same function in case the attributes used
in its definition must match on declarations and definitions.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D150731
-rw-r--r-- | libc/src/__support/endian.h | 4 | ||||
-rw-r--r-- | libc/src/__support/macros/config.h | 2 | ||||
-rw-r--r-- | libc/src/__support/macros/optimization.h | 3 |
3 files changed, 4 insertions, 5 deletions
diff --git a/libc/src/__support/endian.h b/libc/src/__support/endian.h index 1bdccd855a48..cc4eaa29ff34 100644 --- a/libc/src/__support/endian.h +++ b/libc/src/__support/endian.h @@ -32,8 +32,8 @@ namespace internal { template <unsigned ORDER> struct Endian { static constexpr const bool IS_LITTLE = ORDER == __ORDER_LITTLE_ENDIAN__; static constexpr const bool IS_BIG = ORDER == __ORDER_BIG_ENDIAN__; - template <typename T> static T to_big_endian(T value); - template <typename T> static T to_little_endian(T value); + template <typename T> LIBC_INLINE static T to_big_endian(T value); + template <typename T> LIBC_INLINE static T to_little_endian(T value); }; // Little Endian specializations diff --git a/libc/src/__support/macros/config.h b/libc/src/__support/macros/config.h index 3aeac327074c..dcc4a3086fb6 100644 --- a/libc/src/__support/macros/config.h +++ b/libc/src/__support/macros/config.h @@ -13,8 +13,6 @@ #ifndef LLVM_LIBC_SUPPORT_MACROS_CONFIG_H #define LLVM_LIBC_SUPPORT_MACROS_CONFIG_H -#define LIBC_INLINE inline - // LIBC_HAS_BUILTIN() // // Checks whether the compiler supports a Clang Feature Checking Macro, and if diff --git a/libc/src/__support/macros/optimization.h b/libc/src/__support/macros/optimization.h index 707ecd44a00f..ba4441090cde 100644 --- a/libc/src/__support/macros/optimization.h +++ b/libc/src/__support/macros/optimization.h @@ -10,6 +10,7 @@ #ifndef LLVM_LIBC_SRC_SUPPORT_MACROS_OPTIMIZATION_H #define LLVM_LIBC_SRC_SUPPORT_MACROS_OPTIMIZATION_H +#include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN #include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG @@ -17,7 +18,7 @@ // accidentally pass an integer. namespace __llvm_libc::details { template <typename T> -constexpr LIBC_INLINE bool expects_bool_condition(T value, T expected) { +LIBC_INLINE constexpr bool expects_bool_condition(T value, T expected) { return __builtin_expect(value, expected); } } // namespace __llvm_libc::details |