summaryrefslogtreecommitdiff
path: root/src/crypto_endian.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-12-27 18:39:47 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-12-27 18:40:08 +0900
commitb1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch)
tree9ce465b42bf09372118335c7c619bb2b41869eaf /src/crypto_endian.h
parent4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff)
make clang-format using clang-format-3.6
Diffstat (limited to 'src/crypto_endian.h')
-rw-r--r--src/crypto_endian.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/crypto_endian.h b/src/crypto_endian.h
index def6e470..b282fb15 100644
--- a/src/crypto_endian.h
+++ b/src/crypto_endian.h
@@ -27,7 +27,7 @@ namespace crypto {
* - where BYTE_ORDER == LITTLE_ENDIAN or BYTE_ORDER == BIG_ENDIAN
* Failing to conform will render this implementation utterly incorrect.
*/
-#if defined(_WIN32) || defined(__INTEL_COMPILER) || defined (_MSC_VER)
+#if defined(_WIN32) || defined(__INTEL_COMPILER) || defined(_MSC_VER)
// Itanium is dead!
#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
@@ -38,7 +38,8 @@ namespace crypto {
#endif // HAVE_SYS_PARAM_H
#endif // ! defined(_WIN32) || defined(__INTEL_COMPILER) || defined (_MSC_VER)
-#if !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || !defined(BYTE_ORDER) || (LITTLE_ENDIAN != BYTE_ORDER && BIG_ENDIAN != BYTE_ORDER)
+#if !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || !defined(BYTE_ORDER) || \
+ (LITTLE_ENDIAN != BYTE_ORDER && BIG_ENDIAN != BYTE_ORDER)
#error Unsupported byte order/endianess
#endif
@@ -47,12 +48,12 @@ namespace crypto {
#if (defined(__i386__) || defined(__x86_64__)) && defined(__GNUG__)
forceinline uint32_t __crypto_bswap32(uint32_t p)
{
- __asm__ __volatile__("bswap %0" : "=r"(p) : "0"(p));
- return p;
+ __asm__ __volatile__("bswap %0" : "=r"(p) : "0"(p));
+ return p;
}
#elif defined(__GNUG__)
#define __crypto_bswap32 __builtin_bswap32
-#else // defined(__GNUG__)
+#else // defined(__GNUG__)
forceinline uint32_t __crypto_bswap32(uint32_t n)
{
n = ((n << 8) & 0xff00ff00) | ((n >> 8) & 0xff00ff);
@@ -69,7 +70,7 @@ forceinline uint64_t __crypto_bswap64(uint64_t p)
}
#elif defined(__GNUG__)
#define __crypto_bswap64 __builtin_bswap64
-#else // defined(__GNUG__)
+#else // defined(__GNUG__)
forceinline uint64_t __crypto_bswap64(uint64_t n)
{
n = ((n << 8) & 0xff00ff00ff00ff00) | ((n >> 8) & 0x00ff00ff00ff00ff);
@@ -80,20 +81,17 @@ forceinline uint64_t __crypto_bswap64(uint64_t n)
// Time for an implementation that makes reuse easier.
namespace {
-template<typename T>
-inline T __crypto_bswap(T n)
+template <typename T> inline T __crypto_bswap(T n)
{
static_assert(sizeof(T) != sizeof(T), "Not implemented");
}
-template<>
-inline uint32_t __crypto_bswap(uint32_t n)
+template <> inline uint32_t __crypto_bswap(uint32_t n)
{
return __crypto_bswap32(n);
}
-template<>
-inline uint64_t __crypto_bswap(uint64_t n)
+template <> inline uint64_t __crypto_bswap(uint64_t n)
{
return __crypto_bswap64(n);
}