aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-08-31 08:52:14 -0400
committerJack Lloyd <[email protected]>2019-08-31 08:52:14 -0400
commit098b61c3a0ef4c594773ebf84533a81205115ddc (patch)
tree4b427bd350a051413d5bfea451011f52d4e67deb
parentbaac1a8497533c1f2f0e699cc6ddc5f8b263adfc (diff)
Add BOTAN_FORCE_INLINE and use it in BLAKE2b
Closes #2089
-rw-r--r--src/lib/hash/blake2/blake2b.cpp6
-rw-r--r--src/lib/utils/compiler.h17
2 files changed, 20 insertions, 3 deletions
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<size_t i0, size_t i1, size_t i2, size_t i3, size_t i4, size_t i5, size_t i6, size_t i7,
size_t i8, size_t i9, size_t iA, size_t iB, size_t iC, size_t iD, size_t iE, size_t iF>
-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
@@ -178,6 +178,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
*/
#if !defined(BOTAN_PARALLEL_SIMD_FOR)