[PATCH] Re: BUG: incorrect inline assembly in asm-i386/system.h

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Thu, 27 May 1999 15:42:03 +0200


Philipp Thomas wrote:
> So could anyone with enough knowledge of gcc inline assembly tell me how the
> constraints should/could be changed in order to satisfy egcs ? :

Try this patch -- as a bonus it compiles to smaller code.
(I've been using a variant on this since before 2.2.0 and it's reliable).

Enjoy,
-- Jamie

--- linux-2.2.8/include/asm-i386/system.h.devel Wed May 12 00:44:17 1999
+++ linux-2.2.8/include/asm-i386/system.h Wed May 12 00:50:44 1999
@@ -9,24 +9,25 @@
struct task_struct; /* one of the stranger aspects of C forward declarations.. */
extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));

+/*
+ * EBP must be the last thing pushed for get_wchan() [see fs/proc/array.c].
+ * Anyway GCC ignores EBP in a clobber list.
+ */
#define switch_to(prev,next,last) do { \
- asm volatile("pushl %%esi\n\t" \
- "pushl %%edi\n\t" \
- "pushl %%ebp\n\t" \
+ asm volatile("pushl %%ebp\n\t" \
"movl %%esp,%0\n\t" /* save ESP */ \
"movl %3,%%esp\n\t" /* restore ESP */ \
"movl $1f,%1\n\t" /* save EIP */ \
"pushl %4\n\t" /* restore EIP */ \
"jmp __switch_to\n" \
"1:\t" \
- "popl %%ebp\n\t" \
- "popl %%edi\n\t" \
- "popl %%esi\n\t" \
+ "popl %%ebp" \
:"=m" (prev->tss.esp),"=m" (prev->tss.eip), \
"=b" (last) \
:"m" (next->tss.esp),"m" (next->tss.eip), \
"a" (prev), "d" (next), \
- "b" (prev)); \
+ "b" (prev) \
+ :"esi", "edi"); \
} while (0)

#define _set_base(addr,base) do { unsigned long __pr; \

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