aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/bswap.h4
-rw-r--r--src/utils/cpuid.cpp2
-rw-r--r--src/utils/simd_32/simd_32.h17
-rw-r--r--src/utils/simd_32/simd_altivec.h8
-rw-r--r--src/utils/simd_32/simd_scalar.h8
-rw-r--r--src/utils/simd_32/simd_sse.h16
-rw-r--r--src/utils/version.cpp20
-rw-r--r--src/utils/version.h15
8 files changed, 54 insertions, 36 deletions
diff --git a/src/utils/bswap.h b/src/utils/bswap.h
index b35dbf123..6dfed0ba9 100644
--- a/src/utils/bswap.h
+++ b/src/utils/bswap.h
@@ -12,7 +12,7 @@
#include <botan/types.h>
#include <botan/rotate.h>
-#if defined(BOTAN_TARGET_CPU_HAS_SSE2)
+#if defined(BOTAN_TARGET_CPU_HAS_SSE2) && !defined(BOTAN_NO_SSE_INTRINSICS)
#include <emmintrin.h>
#endif
@@ -100,7 +100,7 @@ inline void bswap_4(T x[4])
x[3] = reverse_bytes(x[3]);
}
-#if defined(BOTAN_TARGET_CPU_HAS_SSE2)
+#if defined(BOTAN_TARGET_CPU_HAS_SSE2) && !defined(BOTAN_NO_SSE_INTRINSICS)
/**
* Swap 4 u32bits in an array using SSE2 shuffle instructions
diff --git a/src/utils/cpuid.cpp b/src/utils/cpuid.cpp
index 30f441bd0..9ea9e82ad 100644
--- a/src/utils/cpuid.cpp
+++ b/src/utils/cpuid.cpp
@@ -26,7 +26,7 @@
#include <ia32intrin.h>
#define CALL_CPUID(type, out) do { __cpuid(out, type); } while(0);
-#elif (BOTAN_GCC_VERSION >= 430) || defined(BOTAN_BUILD_COMPILER_IS_CLANG)
+#elif (BOTAN_GCC_VERSION >= 430)
// Only available starting in GCC 4.3
#include <cpuid.h>
diff --git a/src/utils/simd_32/simd_32.h b/src/utils/simd_32/simd_32.h
index 15be7713d..e2c483d20 100644
--- a/src/utils/simd_32/simd_32.h
+++ b/src/utils/simd_32/simd_32.h
@@ -9,8 +9,9 @@
#define BOTAN_SIMD_32_H__
#include <botan/types.h>
+#include <botan/rotate.h>
-#if defined(BOTAN_TARGET_CPU_HAS_SSE2)
+#if defined(BOTAN_TARGET_CPU_HAS_SSE2) && !defined(BOTAN_NO_SSE_INTRINSICS)
#include <botan/internal/simd_sse.h>
namespace Botan { typedef SIMD_SSE2 SIMD_32; }
@@ -29,16 +30,18 @@
namespace Botan {
-inline SIMD_32 rotate_left(const SIMD_32& x, u32bit rot)
+template<>
+inline SIMD_32 rotate_left(SIMD_32 x, size_t rot)
{
- SIMD_32 y = x;
- y.rotate_left(rot);
- return y;
+ x.rotate_left(rot);
+ return x;
}
-inline SIMD_32 rotate_right(const SIMD_32& x, u32bit rot)
+template<>
+inline SIMD_32 rotate_right(SIMD_32 x, size_t rot)
{
- return rotate_left(x, 32 - rot);
+ x.rotate_right(rot);
+ return x;
}
}
diff --git a/src/utils/simd_32/simd_altivec.h b/src/utils/simd_32/simd_altivec.h
index 44e2a4d2b..4c412ddec 100644
--- a/src/utils/simd_32/simd_altivec.h
+++ b/src/utils/simd_32/simd_altivec.h
@@ -97,7 +97,7 @@ class SIMD_Altivec
Botan::store_be(out, vec.R[0], vec.R[1], vec.R[2], vec.R[3]);
}
- void rotate_left(u32bit rot)
+ void rotate_left(size_t rot)
{
__vector unsigned int rot_vec =
(__vector unsigned int){rot, rot, rot, rot};
@@ -105,7 +105,7 @@ class SIMD_Altivec
reg = vec_rl(reg, rot_vec);
}
- void rotate_right(u32bit rot)
+ void rotate_right(size_t rot)
{
rotate_left(32 - rot);
}
@@ -155,7 +155,7 @@ class SIMD_Altivec
reg = vec_and(reg, other.reg);
}
- SIMD_Altivec operator<<(u32bit shift) const
+ SIMD_Altivec operator<<(size_t shift) const
{
__vector unsigned int shift_vec =
(__vector unsigned int){shift, shift, shift, shift};
@@ -163,7 +163,7 @@ class SIMD_Altivec
return vec_sl(reg, shift_vec);
}
- SIMD_Altivec operator>>(u32bit shift) const
+ SIMD_Altivec operator>>(size_t shift) const
{
__vector unsigned int shift_vec =
(__vector unsigned int){shift, shift, shift, shift};
diff --git a/src/utils/simd_32/simd_scalar.h b/src/utils/simd_32/simd_scalar.h
index 56b529025..2c68622af 100644
--- a/src/utils/simd_32/simd_scalar.h
+++ b/src/utils/simd_32/simd_scalar.h
@@ -74,7 +74,7 @@ class SIMD_Scalar
Botan::store_be(out, R0, R1, R2, R3);
}
- void rotate_left(u32bit rot)
+ void rotate_left(size_t rot)
{
R0 = Botan::rotate_left(R0, rot);
R1 = Botan::rotate_left(R1, rot);
@@ -82,7 +82,7 @@ class SIMD_Scalar
R3 = Botan::rotate_left(R3, rot);
}
- void rotate_right(u32bit rot)
+ void rotate_right(size_t rot)
{
R0 = Botan::rotate_right(R0, rot);
R1 = Botan::rotate_right(R1, rot);
@@ -162,7 +162,7 @@ class SIMD_Scalar
R3 &= other.R3;
}
- SIMD_Scalar operator<<(u32bit shift) const
+ SIMD_Scalar operator<<(size_t shift) const
{
return SIMD_Scalar(R0 << shift,
R1 << shift,
@@ -170,7 +170,7 @@ class SIMD_Scalar
R3 << shift);
}
- SIMD_Scalar operator>>(u32bit shift) const
+ SIMD_Scalar operator>>(size_t shift) const
{
return SIMD_Scalar(R0 >> shift,
R1 >> shift,
diff --git a/src/utils/simd_32/simd_sse.h b/src/utils/simd_32/simd_sse.h
index ad3857fbf..1cb52105c 100644
--- a/src/utils/simd_32/simd_sse.h
+++ b/src/utils/simd_32/simd_sse.h
@@ -55,13 +55,13 @@ class SIMD_SSE2
bswap().store_le(out);
}
- void rotate_left(u32bit rot)
+ void rotate_left(size_t rot)
{
- reg = _mm_or_si128(_mm_slli_epi32(reg, rot),
- _mm_srli_epi32(reg, 32-rot));
+ reg = _mm_or_si128(_mm_slli_epi32(reg, static_cast<int>(rot)),
+ _mm_srli_epi32(reg, static_cast<int>(32-rot)));
}
- void rotate_right(u32bit rot)
+ void rotate_right(size_t rot)
{
rotate_left(32 - rot);
}
@@ -111,14 +111,14 @@ class SIMD_SSE2
reg = _mm_and_si128(reg, other.reg);
}
- SIMD_SSE2 operator<<(u32bit shift) const
+ SIMD_SSE2 operator<<(size_t shift) const
{
- return _mm_slli_epi32(reg, shift);
+ return _mm_slli_epi32(reg, static_cast<int>(shift));
}
- SIMD_SSE2 operator>>(u32bit shift) const
+ SIMD_SSE2 operator>>(size_t shift) const
{
- return _mm_srli_epi32(reg, shift);
+ return _mm_srli_epi32(reg, static_cast<int>(shift));
}
SIMD_SSE2 operator~() const
diff --git a/src/utils/version.cpp b/src/utils/version.cpp
index ce2083bc0..cf3205d19 100644
--- a/src/utils/version.cpp
+++ b/src/utils/version.cpp
@@ -1,12 +1,13 @@
/*
* Version Information
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2011 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/version.h>
#include <botan/parsing.h>
+#include <sstream>
namespace Botan {
@@ -21,9 +22,20 @@ namespace Botan {
*/
std::string version_string()
{
- return std::to_string(version_major()) + "." +
- std::to_string(version_minor()) + "." +
- std::to_string(version_patch());
+ std::ostringstream out;
+
+ out << "Botan " << version_major() << "."
+ << version_minor() << "."
+ << version_patch() << " (";
+
+ if(BOTAN_VERSION_DATESTAMP == 0)
+ out << "unreleased version";
+ else
+ out << "released " << version_datestamp();
+
+ out << ", distribution " << BOTAN_DISTRIBUTION_INFO << ")";
+
+ return out.str();
}
u32bit version_datestamp() { return BOTAN_VERSION_DATESTAMP; }
diff --git a/src/utils/version.h b/src/utils/version.h
index 13d0ac8bb..219c261a5 100644
--- a/src/utils/version.h
+++ b/src/utils/version.h
@@ -1,6 +1,6 @@
/*
* Version Information
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2011 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -18,16 +18,19 @@ namespace Botan {
*/
/**
-* Get the version string identifying the version of Botan.
+* Get a human-readable string identifying the version of Botan.
+* No particular format should be assumed.
* @return version string
*/
BOTAN_DLL std::string version_string();
/**
-* Return the date this version of botan was released, in an
-* integer of the form YYYYMMDD. For instance a version released
-* on May 21, 2013 would return the integer 20130521
-* @return release date
+* Return the date this version of botan was released, in an integer of
+* the form YYYYMMDD. For instance a version released on May 21, 2013
+* would return the integer 20130521. If the currently running version
+* is not an official release, this function will return 0 instead.
+*
+* @return release date, or zero if unreleased
*/
BOTAN_DLL u32bit version_datestamp();