summaryrefslogtreecommitdiff
path: root/src/hmac256.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-09-21 13:54:38 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-09-21 15:34:35 +0300
commitcfea5c28a3822e1e7e401e5107ebe07ba7fdcf37 (patch)
tree7aeac78031fc84f0fb239547983fbc9cbe7f2eb9 /src/hmac256.c
parent9337e03824a5bdd3bbbcb8382cabefe6d6c32e1e (diff)
downloadlibgcrypt-cfea5c28a3822e1e7e401e5107ebe07ba7fdcf37.tar.gz
Remove i386 inline assembly version of rotation functions
* cipher/bithelp.h (rol, ror): Remove i386 version, change macros to inline functions. * src/hmac256.c (ror): Ditto. -- (Current) compilers can optimize '(x << c) | (x >> (32-c))' to rotation instruction. So remove i386 specific assembly for manually doing this. Furthermore, compiler can generate faster code in case where 'c' is constant and can use rotate with immediate value rather than rotate with %cl register. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'src/hmac256.c')
-rw-r--r--src/hmac256.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/hmac256.c b/src/hmac256.c
index 2fda47bf..94a26da4 100644
--- a/src/hmac256.c
+++ b/src/hmac256.c
@@ -98,19 +98,10 @@ struct hmac256_context
/* Rotate a 32 bit word. */
-#if defined(__GNUC__) && defined(__i386__)
-static inline u32
-ror(u32 x, int n)
+static inline u32 ror(u32 x, int n)
{
- __asm__("rorl %%cl,%0"
- :"=r" (x)
- :"0" (x),"c" (n)
- :"cc");
- return x;
+ return ( ((x) >> (n)) | ((x) << (32-(n))) );
}
-#else
-#define ror(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
-#endif
#define my_wipememory2(_ptr,_set,_len) do { \
volatile char *_vptr=(volatile char *)(_ptr); \