aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-10-12 05:45:46 +0000
committerlloyd <[email protected]>2008-10-12 05:45:46 +0000
commitb90900b6dc19d709b71e87b9afc02b5877896d5c (patch)
treefc6fb442422ae60d7178919dd7fe73f19cb5e7d5 /src
parentcce13a5ffcfa5d248eb9ff69ff2ecd60794517ff (diff)
Add an implementation of bswap for Visual C++ in x86 inline asm,
written by Yves Jerschow (sent to me in a personal email 2007-10-23).
Diffstat (limited to 'src')
-rw-r--r--src/utils/bswap.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/bswap.h b/src/utils/bswap.h
index b322b9d9b..c1f03c9fd 100644
--- a/src/utils/bswap.h
+++ b/src/utils/bswap.h
@@ -1,6 +1,7 @@
/*************************************************
* Byte Swapping Operations Header File *
* (C) 1999-2008 Jack Lloyd *
+* (C) 2007 Yves Jerschow *
*************************************************/
#ifndef BOTAN_BYTE_SWAP_H__
@@ -24,9 +25,17 @@ inline u32bit reverse_bytes(u32bit input)
#if BOTAN_COMPILER_HAS_GCC_INLINE_ASM && \
(defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64))
+ /* GCC-style inline assembly for x86 or x86-64 */
asm("bswapl %0" : "=r" (input) : "0" (input));
return input;
+
+#elif defined(_MSC_VER) && defined(BOTAN_TARGER_ARCH_IS_IA32)
+ /* Visual C++ inline asm for 32-bit x86, by Yves Jerschow */
+ __asm mov eax, x;
+ __asm bswap eax;
+
#else
+ /* Generic implementation */
input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8);
return rotate_left(input, 16);
#endif