Grovel timeval and timespec struct definitions rather than hard-coding.
[sbcl.git] / src / runtime / ppc-arch.h
1 #ifndef _PPC_ARCH_H
2 #define _PPC_ARCH_H
3
4 static inline long
5 get_spinlock(lispobj *word,long value)
6 {
7 #ifdef LISP_FEATURE_SB_THREAD
8     long temp;
9
10     asm volatile("1: lwarx %0,0,%1;"
11                  "   cmpwi %0,0;"
12                  "   bne- 1b;"
13                  "   stwcx. %2,0,%1;"
14                  "   bne- 1b;"
15                  "   isync"
16                  : "=&r" (temp)
17                  : "r" (word), "r" (value)
18                  : "cr0", "memory");
19     return temp;
20 #else
21     *word=value;
22     return 0;
23 #endif
24 }
25
26 static inline void
27 release_spinlock(lispobj *word)
28 {
29 #ifdef LISP_FEATURE_SB_THREAD
30     asm volatile ("sync" : : : "memory");
31 #endif
32     *word=0;
33 }
34
35 #ifdef LISP_FEATURE_SB_THREAD
36 static inline lispobj
37 swap_lispobjs(volatile lispobj *dest, lispobj value)
38 {
39     lispobj old_value;
40     asm volatile ("1: lwarx %0,0,%1;"
41                   "   stwcx. %2,0,%1;"
42                   "   bne- 1b;"
43                   "   isync"
44          : "=&r" (old_value)
45          : "r" (dest), "r" (value)
46          : "cr0", "memory");
47     return old_value;
48 }
49 #endif
50
51 #define ARCH_HAS_LINK_REGISTER
52
53 extern void ppc_flush_icache(os_vm_address_t address, os_vm_size_t length);
54
55 os_context_register_t *os_context_ctr_addr(os_context_t *context);
56 os_context_register_t *os_context_cr_addr(os_context_t *context);
57
58 #endif /* _PPC_ARCH_H */