diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-08-22 16:28:01 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-08-23 13:03:25 -0700 |
commit | b015124e562a040f7faf361c72e8f5f457ac6cf5 (patch) | |
tree | 452f3fe6b9a7d2ef692e021a18f588490bc78441 /arch/i386/boot/tty.c | |
parent | b377fd3982ad957c796758a90e2988401a884241 (diff) |
[x86 setup] Volatilize asm() statements
asm() statements need to be volatile when:
a. They have side effects (other than value returned).
b. When the value returned can vary over time.
c. When they have ordering constraints that cannot be expressed to gcc.
In particular, the keyboard and timer reads were violating constraint (b),
which resulted in the keyboard/timeout poll getting
loop-invariant-removed when compiling with gcc 4.2.0.
Thanks to an anonymous bug reporter for pointing this out.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/i386/boot/tty.c')
-rw-r--r-- | arch/i386/boot/tty.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/i386/boot/tty.c b/arch/i386/boot/tty.c index 9c668aad351..f3f14bd2637 100644 --- a/arch/i386/boot/tty.c +++ b/arch/i386/boot/tty.c @@ -54,9 +54,9 @@ static u8 gettime(void) u16 ax = 0x0200; u16 cx, dx; - asm("int $0x1a" - : "+a" (ax), "=c" (cx), "=d" (dx) - : : "ebx", "esi", "edi"); + asm volatile("int $0x1a" + : "+a" (ax), "=c" (cx), "=d" (dx) + : : "ebx", "esi", "edi"); return dx >> 8; } @@ -67,7 +67,7 @@ static u8 gettime(void) int getchar(void) { u16 ax = 0; - asm("int $0x16" : "+a" (ax)); + asm volatile("int $0x16" : "+a" (ax)); return ax & 0xff; } @@ -75,9 +75,9 @@ int getchar(void) static int kbd_pending(void) { u8 pending; - asm("int $0x16; setnz %0" - : "=rm" (pending) - : "a" (0x0100)); + asm volatile("int $0x16; setnz %0" + : "=rm" (pending) + : "a" (0x0100)); return pending; } |