Re: asm (lidt) question

From: Randy.Dunlap (rddunlap@osdl.org)
Date: Thu Jul 17 2003 - 18:31:03 EST


On Thu, 17 Jul 2003 16:18:06 -0700 (PDT) Davide Libenzi <davidel@xmailserver.org> wrote:

| On Thu, 17 Jul 2003, Davide Libenzi wrote:
|
| > On Thu, 17 Jul 2003, Randy.Dunlap wrote:
| >
| > >
| > > In arch/i386/kernel, inline asm for loading IDT (lidt) is used a few
| > > times, but with slightly different constraints and output/input
| > > definitions. Are these OK, equivalent, or what?
| > >
| > > [rddunlap@dragon kernel]$ findc lidt
| > > ./cpu/common.c:484: __asm__ __volatile__("lidt %0": "=m" (idt_descr));
| > > ./traps.c:783: __asm__ __volatile__("lidt %0": "=m" (idt_descr));
| > >
| > > vs.
| > >
| > > ./reboot.c:186: __asm__ __volatile__ ("lidt %0" : : "m" (real_mode_idt));
| > > ./reboot.c:261: __asm__ __volatile__("lidt %0": :"m" (no_idt));
| > > ./suspend.c:95: asm volatile ("lidt %0" :: "m" (saved_context.idt_limit));
| >
| > I'd have said no looking at the syntax (input/output), but they indeed
| > generate the same code (just checked).
|
| Randy, I'd say that this :
|
| __asm__ __volatile__("lidt %0": "=m" (var));
|
| is better then :
|
| __asm__ __volatile__("lidt %0": :"m" (var));
|
| IMHO, since "var" is really an output parameter.

Yes, I agree, var is output and should be listed after the first ':'
IMHO also.

Thanks for checking that they generate the same code, though.

I'll buy you a beer... No, wait, I already did that. :)

--
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jul 23 2003 - 22:00:31 EST