瀏覽代碼

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.
Patrick Pelletier 14 年之前
父節點
當前提交
cefff85550
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/headers/tomcrypt_macros.h

+ 2 - 2
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