X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fppc-arch.h;h=515335f7b52e1cb38ac157643e0c78a233c49b7a;hb=c8617f57d0413beb2890e94dabe227cef9c5ddad;hp=be871d8c3e7055ceedf902f177bc1ae621217498;hpb=4023b1bec2412344e5eea4a33cd85dd662149c67;p=sbcl.git diff --git a/src/runtime/ppc-arch.h b/src/runtime/ppc-arch.h index be871d8..515335f 100644 --- a/src/runtime/ppc-arch.h +++ b/src/runtime/ppc-arch.h @@ -1,21 +1,58 @@ #ifndef _PPC_ARCH_H #define _PPC_ARCH_H -static inline void +static inline long get_spinlock(lispobj *word,long value) { - *word=value; /* FIXME for threads */ +#ifdef LISP_FEATURE_SB_THREAD + long temp; + + asm volatile("1: lwarx %0,0,%1;" + " cmpwi %0,0;" + " bne- 1b;" + " stwcx. %2,0,%1;" + " bne- 1b;" + " isync" + : "=&r" (temp) + : "r" (word), "r" (value) + : "cr0", "memory"); + return temp; +#else + *word=value; + return 0; +#endif } static inline void release_spinlock(lispobj *word) { +#ifdef LISP_FEATURE_SB_THREAD + asm volatile ("sync" : : : "memory"); +#endif *word=0; } +#ifdef LISP_FEATURE_SB_THREAD +static inline lispobj +swap_lispobjs(volatile lispobj *dest, lispobj value) +{ + lispobj old_value; + asm volatile ("1: lwarx %0,0,%1;" + " stwcx. %2,0,%1;" + " bne- 1b;" + " isync" + : "=&r" (old_value) + : "r" (dest), "r" (value) + : "cr0", "memory"); + return old_value; +} +#endif #define ARCH_HAS_LINK_REGISTER extern void ppc_flush_icache(os_vm_address_t address, os_vm_size_t length); +os_context_register_t *os_context_ctr_addr(os_context_t *context); +os_context_register_t *os_context_cr_addr(os_context_t *context); + #endif /* _PPC_ARCH_H */