unsigned long *bottom = (unsigned long *)(thread->stack + STACK_SIZE);
unsigned long *pointer = (unsigned long *)thread->sp;
int count;
- if(thread == current)
- {
-#ifdef __i386__
- asm("movl %%esp,%0"
- : "=r"(pointer));
-#else
- asm("movq %%rsp,%0"
- : "=r"(pointer));
-#endif
- }
+
+ if ( thread == current )
+ asm ( "mov %%"ASM_SP",%0" : "=r" (pointer) );
+
printk("The stack for \"%s\"\n", thread->name);
for(count = 0; count < 25 && pointer < bottom; count ++)
{
void run_idle_thread(void)
{
- /* Switch stacks and run the thread */
-#if defined(__i386__)
- __asm__ __volatile__("mov %0,%%esp\n\t"
- "push %1\n\t"
- "ret"
- :"=m" (idle_thread->sp)
- :"m" (idle_thread->ip));
-#elif defined(__x86_64__)
- __asm__ __volatile__("mov %0,%%rsp\n\t"
- "push %1\n\t"
- "ret"
- :"=m" (idle_thread->sp)
- :"m" (idle_thread->ip));
-#endif
+ /* Switch stacks and run the thread */
+ asm volatile ( "mov %[sp], %%"ASM_SP"\n\t"
+ "jmp *%[ip]\n\t"
+ :
+ : [sp] "m" (idle_thread->sp),
+ [ip] "m" (idle_thread->ip) );
}
unsigned long __local_irq_save(void)
#define TRAP_deferred_nmi 31
#define TRAP_xen_callback 32
+#if defined(__i386__)
+#define __SZ "l"
+#define __REG "e"
+#else
+#define __SZ "q"
+#define __REG "r"
+#endif
+
+#define ASM_SP __REG"sp"
+
/* Everything below this point is not included by assembler (.S) files. */
#ifndef __ASSEMBLY__
#else
-#if defined(__i386__)
-#define __SZ "l"
-#define __REG "e"
-#else
-#define __SZ "q"
-#define __REG "r"
-#endif
-
#define __cli() asm volatile ( "cli" : : : "memory" )
#define __sti() asm volatile ( "sti" : : : "memory" )