1.0.5.37: cleanup a small thinko from previous x86-assem.S refactoring
[sbcl.git] / src / runtime / pseudo-atomic.h
1 /*
2  * macros for manipulating pseudo-atomic flags (per thread)
3  */
4
5 /*
6  * This software is part of the SBCL system. See the README file for
7  * more information.
8  *
9  * This software is derived from the CMU CL system, which was
10  * written at Carnegie Mellon University and released into the
11  * public domain. The software is in the public domain and is
12  * provided with absolutely no warranty. See the COPYING and CREDITS
13  * files for more information.
14  */
15
16 #ifndef PSEUDO_ATOMIC_H
17 #define PSEUDO_ATOMIC_H
18
19 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
20
21 #define set_alloc_pointer(value)                \
22     SetSymbolValue(ALLOCATION_POINTER, value, 0)
23 #define get_alloc_pointer()                     \
24     SymbolValue(ALLOCATION_POINTER, 0)
25 #define get_binding_stack_pointer(thread)       \
26     SymbolValue(BINDING_STACK_POINTER, thread)
27 #define get_pseudo_atomic_atomic(thread)        \
28     (fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) & make_fixnum(1)))
29 #define set_pseudo_atomic_atomic(thread)                                \
30     { \
31         lispobj bits = SymbolValue(PSEUDO_ATOMIC_BITS, thread); \
32         SetSymbolValue(PSEUDO_ATOMIC_BITS, bits | make_fixnum(1), thread); \
33     }
34 #define clear_pseudo_atomic_atomic(thread)                      \
35     { \
36         lispobj bits = SymbolValue(PSEUDO_ATOMIC_BITS, thread);       \
37         SetSymbolValue(PSEUDO_ATOMIC_BITS, bits & ~make_fixnum(1), thread); \
38     }
39 #define get_pseudo_atomic_interrupted(thread)                   \
40     (fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) & make_fixnum(2)))
41 #define clear_pseudo_atomic_interrupted(thread)                         \
42     { \
43         lispobj bits = SymbolValue(PSEUDO_ATOMIC_BITS, thread);       \
44         SetSymbolValue(PSEUDO_ATOMIC_BITS, bits & ~make_fixnum(2), thread); \
45     }
46
47 #define set_pseudo_atomic_interrupted(thread)                           \
48     { \
49         lispobj bits = SymbolValue(PSEUDO_ATOMIC_BITS, thread); \
50         SetSymbolValue(PSEUDO_ATOMIC_BITS, bits | make_fixnum(2), thread); \
51     }
52
53 #elif defined(LISP_FEATURE_PPC) && defined(LISP_FEATURE_GENCGC)
54
55 #define set_alloc_pointer(value) \
56     (dynamic_space_free_pointer =                                       \
57      (value) | (((unsigned long)dynamic_space_free_pointer) & LOWTAG_MASK))
58
59 #define get_alloc_pointer()                                     \
60     ((unsigned long) dynamic_space_free_pointer & ~LOWTAG_MASK)
61 #define get_binding_stack_pointer(thread)       \
62     (current_binding_stack_pointer)
63 #define get_pseudo_atomic_atomic(thread)                                \
64     ((unsigned long)dynamic_space_free_pointer & flag_PseudoAtomic)
65 #define set_pseudo_atomic_atomic(thread)                                \
66     (dynamic_space_free_pointer                                         \
67      = (lispobj*) ((unsigned long)dynamic_space_free_pointer | flag_PseudoAtomic))
68 #define clear_pseudo_atomic_atomic(thread)                              \
69     (dynamic_space_free_pointer                                         \
70      = (lispobj*) ((unsigned long) dynamic_space_free_pointer & ~flag_PseudoAtomic))
71 #define get_pseudo_atomic_interrupted(thread)                           \
72     ((unsigned long) dynamic_space_free_pointer & flag_PseudoAtomicInterrupted)
73 #define clear_pseudo_atomic_interrupted(thread)                         \
74     (dynamic_space_free_pointer                                         \
75      = (lispobj*) ((unsigned long) dynamic_space_free_pointer & ~flag_PseudoAtomicInterrupted))
76 #define set_pseudo_atomic_interrupted(thread)                           \
77     (dynamic_space_free_pointer                                         \
78      = (lispobj*) ((unsigned long) dynamic_space_free_pointer | flag_PseudoAtomicInterrupted))
79
80 #endif
81
82 #endif /* PSEUDO_ATOMIC_H */
83