diff options
| author | Nils Maier <maierman@web.de> | 2014-07-11 02:28:15 +0200 |
|---|---|---|
| committer | Nils Maier <maierman@web.de> | 2014-07-11 04:11:03 +0200 |
| commit | 84bd18b9a12d284ee0f0a354fff97ba53caec0a8 (patch) | |
| tree | 26728a78ebab77a5273f0daab2f1521d4be75630 /src/crypto_endian.h | |
| parent | 1da3af8869517f729d269ee87c1c0870de38f864 (diff) | |
Merge crypto_* from upstream
Revert "Fix typo"
This reverts commit 4dfd8b884775737f85783976958f4e976b65a5fb.
Revert "MinGW: Fix compiler warning with -Wstrict-aliasing"
This reverts commit 897f0e87f4bd69bf6703a12feb326aeba53b0dcd.
Diffstat (limited to 'src/crypto_endian.h')
| -rw-r--r-- | src/crypto_endian.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/crypto_endian.h b/src/crypto_endian.h index 55b32d80..def6e470 100644 --- a/src/crypto_endian.h +++ b/src/crypto_endian.h @@ -45,12 +45,11 @@ namespace crypto { // Lets spend some quality time mucking around with byte swap and endian-ness. // First bswap32: #if (defined(__i386__) || defined(__x86_64__)) && defined(__GNUG__) -#define __crypto_bswap32(p) \ - ({ \ - uint32_t t = p; \ - __asm__ __volatile__("bswap %0" : "=r"(t) : "0"(t)); \ - t; \ - }) +forceinline uint32_t __crypto_bswap32(uint32_t p) +{ + __asm__ __volatile__("bswap %0" : "=r"(p) : "0"(p)); + return p; +} #elif defined(__GNUG__) #define __crypto_bswap32 __builtin_bswap32 #else // defined(__GNUG__) @@ -63,13 +62,11 @@ forceinline uint32_t __crypto_bswap32(uint32_t n) // Next up: bswap64 #if defined(__x86_64__) && defined(__GNUG__) -#define __crypto_bswap64(p) \ - ({ \ - uint64_t t = p; \ - __asm__ __volatile__("bswapq %q0" : "=r"(t) : "0"(t)); \ - t; \ - }) - +forceinline uint64_t __crypto_bswap64(uint64_t p) +{ + __asm__ __volatile__("bswapq %q0" : "=r"(p) : "0"(p)); + return p; +} #elif defined(__GNUG__) #define __crypto_bswap64 __builtin_bswap64 #else // defined(__GNUG__) @@ -109,7 +106,7 @@ inline uint64_t __crypto_bswap(uint64_t n) #else // LITTLE_ENDIAN != WORD_ORDER #define __crypto_be(n) (n) #define __crypto_le(n) __crypto_bswap(n) -#endif +#endif // LITTLE_ENDIAN != WORD_ORDER } // namespace crypto |
