aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/boot/tty.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-08-22 19:28:01 -0400
committerH. Peter Anvin <hpa@zytor.com>2007-08-23 16:03:25 -0400
commitb015124e562a040f7faf361c72e8f5f457ac6cf5 (patch)
tree452f3fe6b9a7d2ef692e021a18f588490bc78441 /arch/i386/boot/tty.c
parentb377fd3982ad957c796758a90e2988401a884241 (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.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/i386/boot/tty.c b/arch/i386/boot/tty.c
index 9c668aad3515..f3f14bd26371 100644
--- a/arch/i386/boot/tty.c
+++ b/arch/i386/boot/tty.c
@@ -54,9 +54,9 @@ static u8 gettime(void)
54 u16 ax = 0x0200; 54 u16 ax = 0x0200;
55 u16 cx, dx; 55 u16 cx, dx;
56 56
57 asm("int $0x1a" 57 asm volatile("int $0x1a"
58 : "+a" (ax), "=c" (cx), "=d" (dx) 58 : "+a" (ax), "=c" (cx), "=d" (dx)
59 : : "ebx", "esi", "edi"); 59 : : "ebx", "esi", "edi");
60 60
61 return dx >> 8; 61 return dx >> 8;
62} 62}
@@ -67,7 +67,7 @@ static u8 gettime(void)
67int getchar(void) 67int getchar(void)
68{ 68{
69 u16 ax = 0; 69 u16 ax = 0;
70 asm("int $0x16" : "+a" (ax)); 70 asm volatile("int $0x16" : "+a" (ax));
71 71
72 return ax & 0xff; 72 return ax & 0xff;
73} 73}
@@ -75,9 +75,9 @@ int getchar(void)
75static int kbd_pending(void) 75static int kbd_pending(void)
76{ 76{
77 u8 pending; 77 u8 pending;
78 asm("int $0x16; setnz %0" 78 asm volatile("int $0x16; setnz %0"
79 : "=rm" (pending) 79 : "=rm" (pending)
80 : "a" (0x0100)); 80 : "a" (0x0100));
81 return pending; 81 return pending;
82} 82}
83 83