Fix i386/amd64 inline assembly "cc" clobbers
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Thu, 27 Jun 2013 11:40:12 +0000 (14:40 +0300)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Wed, 10 Jul 2013 19:02:08 +0000 (22:02 +0300)
* cipher/bithelp.h [__GNUC__, __i386__] (rol, ror): add "cc" globber
for inline assembly.
* cipher/cast5.c [__GNUC__, __i386__] (rol): Ditto.
* random/rndhw.c [USE_DRNG] (rdrand_long): Ditto.
* src/hmac256.c [__GNUC__, __i386__] (ror): Ditto.
* mpi/longlong.c [__i386__] (add_ssaaaa, sub_ddmmss, umul_ppmm)
(udiv_qrnnd, count_leading_zeros, count_trailing_zeros): Ditto.
--

These assembly snippets modify cflags but do not mark "cc" clobber.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/bithelp.h
cipher/cast5.c
mpi/longlong.h
random/rndhw.c
src/hmac256.c

index 1505324..785701e 100644 (file)
@@ -30,7 +30,8 @@ rol( u32 x, int n)
 {
        __asm__("roll %%cl,%0"
                :"=r" (x)
-               :"0" (x),"c" (n));
+               :"0" (x),"c" (n)
+               :"cc");
        return x;
 }
 #else
@@ -43,7 +44,8 @@ ror(u32 x, int n)
 {
        __asm__("rorl %%cl,%0"
                :"=r" (x)
-               :"0" (x),"c" (n));
+               :"0" (x),"c" (n)
+               :"cc");
        return x;
 }
 #else
index 41bc9ff..6017bf0 100644 (file)
@@ -393,7 +393,8 @@ rol(int n, u32 x)
 {
        __asm__("roll %%cl,%0"
                :"=r" (x)
-               :"0" (x),"c" (n));
+               :"0" (x),"c" (n)
+               :"cc");
        return x;
 }
 #else
index 699b6b3..773d1c7 100644 (file)
@@ -473,7 +473,8 @@ extern USItype __udiv_qrnnd ();
           : "%0" ((USItype)(ah)),                                      \
             "g" ((USItype)(bh)),                                       \
             "%1" ((USItype)(al)),                                      \
-            "g" ((USItype)(bl)))
+            "g" ((USItype)(bl))                                        \
+          __CLOBBER_CC)
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
   __asm__ ("subl %5,%1\n"                                               \
           "sbbl %3,%0"                                                 \
@@ -482,29 +483,33 @@ extern USItype __udiv_qrnnd ();
           : "0" ((USItype)(ah)),                                       \
             "g" ((USItype)(bh)),                                       \
             "1" ((USItype)(al)),                                       \
-            "g" ((USItype)(bl)))
+            "g" ((USItype)(bl))                                        \
+          __CLOBBER_CC)
 #define umul_ppmm(w1, w0, u, v) \
   __asm__ ("mull %3"                                                    \
           : "=a" ((USItype)(w0)),                                      \
             "=d" ((USItype)(w1))                                       \
           : "%0" ((USItype)(u)),                                       \
-            "rm" ((USItype)(v)))
+            "rm" ((USItype)(v))                                        \
+          __CLOBBER_CC)
 #define udiv_qrnnd(q, r, n1, n0, d) \
   __asm__ ("divl %4"                                                    \
           : "=a" ((USItype)(q)),                                       \
             "=d" ((USItype)(r))                                        \
           : "0" ((USItype)(n0)),                                       \
             "1" ((USItype)(n1)),                                       \
-            "rm" ((USItype)(d)))
+            "rm" ((USItype)(d))                                        \
+          __CLOBBER_CC)
 #define count_leading_zeros(count, x) \
   do {                                                                 \
     USItype __cbtmp;                                                   \
     __asm__ ("bsrl %1,%0"                                               \
-            : "=r" (__cbtmp) : "rm" ((USItype)(x)));                   \
+            : "=r" (__cbtmp) : "rm" ((USItype)(x))                     \
+            __CLOBBER_CC);                                             \
     (count) = __cbtmp ^ 31;                                            \
   } while (0)
 #define count_trailing_zeros(count, x) \
-  __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)))
+  __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)) __CLOBBER_CC)
 #ifndef UMUL_TIME
 #define UMUL_TIME 40
 #endif
index cbb28d1..ca99c5f 100644 (file)
@@ -138,7 +138,8 @@ rdrand_long (unsigned long *v)
                 "jnz 1b\n\t"
                 "2:"
                 : "=r" (ok), "=a" (*v)
-                : "0" (RDRAND_RETRY_LOOPS));
+                : "0" (RDRAND_RETRY_LOOPS)
+                : "cc");
   return ok;
 }
 
index 34def76..2fda47b 100644 (file)
@@ -104,7 +104,8 @@ ror(u32 x, int n)
 {
        __asm__("rorl %%cl,%0"
                :"=r" (x)
-               :"0" (x),"c" (n));
+               :"0" (x),"c" (n)
+               :"cc");
        return x;
 }
 #else