Skip to contentSkip to conversation

Optimize get_current()

PATCH New Samuel Thibault 1 participant 1 message Nov 23, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Optimize get_current()

Let gcc perform the computation with SP itself, leading to yet better code.

extras/mini-os/include/x86/arch_sched.h +3 -2
diff -r 2e05a6173be0 extras/mini-os/include/x86/arch_sched.h
@@ -7,10 +7,11 @@
 {
     struct thread **current;
 #ifdef __i386__    
-    __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
+    register unsigned long sp asm("esp");
 #else
-    __asm__("andq %%rsp,%0; ":"=r" (current) : "0" (~8191UL));
+    register unsigned long sp asm("rsp");
 #endif 
+    current = (void *)(sp & ~8191UL);
     return *current;
 }