base/dispatch.c: Fix operand constraints in `setflags'.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 5 Jul 2017 20:30:20 +0000 (21:30 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 5 Jul 2017 20:30:20 +0000 (21:30 +0100)
It wasn't correct to use `g' here.  Clang legitimately used sp-relative
memory locations, which broke really badly because the stack pointer
moves during the code sequence.  Force the operands into registers to
avoid this problem.

base/dispatch.c

index b70d44b..50c9438 100644 (file)
@@ -72,8 +72,8 @@ static __inline__ unsigned setflags(unsigned f)
 {
   unsigned ff;
   __asm__ ("pushf; pushl %1; popf; pushf; popl %0; popf"
-          : "=g" (ff)
-          : "g" (f));
+          : "=r" (ff)
+          : "r" (f));
   return (ff);
 }
 #  else
@@ -83,8 +83,8 @@ static __inline__ unsigned long long setflags(unsigned long f)
 {
   unsigned long ff;
   __asm__ ("pushf; pushq %1; popf; pushf; popq %0; popf"
-          : "=g" (ff)
-          : "g" (f));
+          : "=r" (ff)
+          : "r" (f));
   return (ff);
 }
 #  endif