aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-13 15:28:30 -0400
committerJack Lloyd <[email protected]>2016-10-13 15:28:30 -0400
commit20f7e4ecb33aeafaf15adb9373f50b451e1fcf1e (patch)
treeeac4a527a1f1eeec8e83216e5727b81283dd1b5b /src
parent704d754be3fb3e62c05f4c64bcb82a456ebb1b94 (diff)
util: Some simple constexpr uses
Remove unused and empty get_byte.h
Diffstat (limited to 'src')
-rw-r--r--src/lib/utils/get_byte.h18
-rw-r--r--src/lib/utils/loadstor.h10
-rw-r--r--src/lib/utils/rotate.h12
3 files changed, 9 insertions, 31 deletions
diff --git a/src/lib/utils/get_byte.h b/src/lib/utils/get_byte.h
deleted file mode 100644
index 14f55b97b..000000000
--- a/src/lib/utils/get_byte.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-* Read out bytes
-* (C) 1999-2007 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_GET_BYTE_H__
-#define BOTAN_GET_BYTE_H__
-
-#include <botan/types.h>
-
-namespace Botan {
-
-
-}
-
-#endif
diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h
index 9ae9fda0e..ebef45665 100644
--- a/src/lib/utils/loadstor.h
+++ b/src/lib/utils/loadstor.h
@@ -44,7 +44,7 @@ namespace Botan {
* @param input the value to extract from
* @return byte byte_num of input
*/
-template<typename T> inline byte get_byte(size_t byte_num, T input)
+template<typename T> inline constexpr byte get_byte(size_t byte_num, T input)
{
return static_cast<byte>(
input >> (((~byte_num)&(sizeof(T)-1)) << 3)
@@ -57,7 +57,7 @@ template<typename T> inline byte get_byte(size_t byte_num, T input)
* @param i1 the second byte
* @return i0 || i1
*/
-inline u16bit make_u16bit(byte i0, byte i1)
+inline constexpr u16bit make_u16bit(byte i0, byte i1)
{
return ((static_cast<u16bit>(i0) << 8) | i1);
}
@@ -70,7 +70,7 @@ inline u16bit make_u16bit(byte i0, byte i1)
* @param i3 the fourth byte
* @return i0 || i1 || i2 || i3
*/
-inline u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3)
+inline constexpr u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3)
{
return ((static_cast<u32bit>(i0) << 24) |
(static_cast<u32bit>(i1) << 16) |
@@ -90,8 +90,8 @@ inline u32bit make_u32bit(byte i0, byte i1, byte i2, byte i3)
* @param i7 the eighth byte
* @return i0 || i1 || i2 || i3 || i4 || i5 || i6 || i7
*/
-inline u64bit make_u64bit(byte i0, byte i1, byte i2, byte i3,
- byte i4, byte i5, byte i6, byte i7)
+inline constexpr u64bit make_u64bit(byte i0, byte i1, byte i2, byte i3,
+ byte i4, byte i5, byte i6, byte i7)
{
return ((static_cast<u64bit>(i0) << 56) |
(static_cast<u64bit>(i1) << 48) |
diff --git a/src/lib/utils/rotate.h b/src/lib/utils/rotate.h
index 9313a2d18..126a49314 100644
--- a/src/lib/utils/rotate.h
+++ b/src/lib/utils/rotate.h
@@ -18,11 +18,9 @@ namespace Botan {
* @param rot the number of bits to rotate
* @return input rotated left by rot bits
*/
-template<typename T> inline T rotate_left(T input, size_t rot)
+template<typename T> inline constexpr T rotate_left(T input, size_t rot)
{
- if(rot == 0)
- return input;
- return static_cast<T>((input << rot) | (input >> (8*sizeof(T)-rot)));;
+ return (rot == 0) ? input : static_cast<T>((input << rot) | (input >> (8*sizeof(T)-rot)));;
}
/**
@@ -31,11 +29,9 @@ template<typename T> inline T rotate_left(T input, size_t rot)
* @param rot the number of bits to rotate
* @return input rotated right by rot bits
*/
-template<typename T> inline T rotate_right(T input, size_t rot)
+template<typename T> inline constexpr T rotate_right(T input, size_t rot)
{
- if(rot == 0)
- return input;
- return static_cast<T>((input >> rot) | (input << (8*sizeof(T)-rot)));
+ return (rot == 0) ? input : static_cast<T>((input >> rot) | (input << (8*sizeof(T)-rot)));
}
}