From cefff85550786ec869b39c0cb4a5904e88c84319 Mon Sep 17 00:00:00 2001 From: Patrick Pelletier Date: Sun, 25 Sep 2011 17:11:25 -0700 Subject: [PATCH] Add "memory" as a clobber for bswap inline assembly. This had been causing Camellia (the only cipher that uses these macros) to fail when compiling "out-of-the-box" with gcc version "4.3.3-5ubuntu4". I think because the compiler had no idea any memory access was going on in these macros. Adding "memory" as a clobber solves the problem, but is probably overkill. I suspect that if we specify the constraint for y differently, we could get rid of both "memory" and __volatile__, which would allow the compiler to optimize much more. Also, in gcc versions that support it, we should probably use the bswap builtins instead. --- src/headers/tomcrypt_macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/headers/tomcrypt_macros.h b/src/headers/tomcrypt_macros.h index 6e4d757..52a1719 100644 --- a/src/headers/tomcrypt_macros.h +++ b/src/headers/tomcrypt_macros.h @@ -105,13 +105,13 @@ asm __volatile__ ( \ "bswapq %0 \n\t" \ "movq %0,(%1)\n\t" \ "bswapq %0 \n\t" \ - ::"r"(x), "r"(y)); + ::"r"(x), "r"(y): "memory"); #define LOAD64H(x, y) \ asm __volatile__ ( \ "movq (%1),%0\n\t" \ "bswapq %0\n\t" \ - :"=r"(x): "r"(y)); + :"=r"(x): "r"(y): "memory"); #else