From 098b61c3a0ef4c594773ebf84533a81205115ddc Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 31 Aug 2019 08:52:14 -0400 Subject: Add BOTAN_FORCE_INLINE and use it in BLAKE2b Closes #2089 --- src/lib/hash/blake2/blake2b.cpp | 6 +++--- src/lib/utils/compiler.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/hash/blake2/blake2b.cpp b/src/lib/hash/blake2/blake2b.cpp index a45f058d4..9617fb4fb 100644 --- a/src/lib/hash/blake2/blake2b.cpp +++ b/src/lib/hash/blake2/blake2b.cpp @@ -55,8 +55,8 @@ void BLAKE2b::state_init() namespace { -inline void G(uint64_t& a, uint64_t& b, uint64_t& c, uint64_t& d, - uint64_t M0, uint64_t M1) +BOTAN_FORCE_INLINE void G(uint64_t& a, uint64_t& b, uint64_t& c, uint64_t& d, + uint64_t M0, uint64_t M1) { a = a + b + M0; d = rotr<32>(d ^ a); @@ -70,7 +70,7 @@ inline void G(uint64_t& a, uint64_t& b, uint64_t& c, uint64_t& d, template -inline void ROUND(uint64_t* v, const uint64_t* M) +BOTAN_FORCE_INLINE void ROUND(uint64_t* v, const uint64_t* M) { G(v[ 0], v[ 4], v[ 8], v[12], M[i0], M[i1]); G(v[ 1], v[ 5], v[ 9], v[13], M[i2], M[i3]); diff --git a/src/lib/utils/compiler.h b/src/lib/utils/compiler.h index 5cf1f1f41..503cd3754 100644 --- a/src/lib/utils/compiler.h +++ b/src/lib/utils/compiler.h @@ -177,6 +177,23 @@ #endif +/* +* Define BOTAN_FORCE_INLINE +*/ +#if !defined(BOTAN_FORCE_INLINE) + + #if defined (__clang__) || defined (__GNUC__) + #define BOTAN_FORCE_INLINE __attribute__ ((__always_inline__)) + + #elif defined (_MSC_VER) + #define BOTAN_FORCE_INLINE __forceinline + + #else + #define BOTAN_FORCE_INLINE inline + #endif + +#endif + /* * Define BOTAN_PARALLEL_SIMD_FOR */ -- cgit v1.2.3