X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fruntime%2Fx86-arch.h;h=582bfc7e016b668ee47b33285b5eecea099e36b9;hb=ba39d165a0bb6fabba6d6feb9b6fb88ae4d544ff;hp=1200ef1435578ad196bda0a0be0f7535799360bd;hpb=b71ea3ac652d67b53d415378ed27da80cc90806f;p=sbcl.git diff --git a/src/runtime/x86-arch.h b/src/runtime/x86-arch.h index 1200ef1..582bfc7 100644 --- a/src/runtime/x86-arch.h +++ b/src/runtime/x86-arch.h @@ -21,6 +21,17 @@ #define COMPILER_BARRIER \ do { __asm__ __volatile__ ( "" : : : "memory"); } while (0) +#ifdef LISP_FEATURE_WIN32 +extern int os_number_of_processors; +#define yield_on_uniprocessor() \ + do { if (os_number_of_processors<=1) SwitchToThread(); } while(0) +#else +/* Stubs are better than ifdef EVERYWHERE. */ +#define yield_on_uniprocessor() \ + do {} while(0) +#endif + + static inline void get_spinlock(volatile lispobj *word, unsigned long value) { @@ -36,13 +47,16 @@ get_spinlock(volatile lispobj *word, unsigned long value) : "r" (value), "m" (*word) : "memory", "cc"); #else + if (eax!=0) { + asm volatile("rep; nop"); + } asm volatile ("xor %0,%0\n\ lock cmpxchg %1,%2" : "=a" (eax) : "r" (value), "m" (*word) : "memory", "cc"); #endif - + yield_on_uniprocessor(); } while(eax!=0); #else *word=value;