1.0.7.33: better handling of ASSOC and MEMBER on empty lists
[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      ((lispobj *) \
58       ((value) | (((unsigned long)dynamic_space_free_pointer) & LOWTAG_MASK))))
59
60 #define get_alloc_pointer()                                     \
61     ((unsigned long) dynamic_space_free_pointer & ~LOWTAG_MASK)
62 #define get_binding_stack_pointer(thread)       \
63     (current_binding_stack_pointer)
64 #define get_pseudo_atomic_atomic(thread)                                \
65     ((unsigned long)dynamic_space_free_pointer & flag_PseudoAtomic)
66 #define set_pseudo_atomic_atomic(thread)                                \
67     (dynamic_space_free_pointer                                         \
68      = (lispobj*) ((unsigned long)dynamic_space_free_pointer | flag_PseudoAtomic))
69 #define clear_pseudo_atomic_atomic(thread)                              \
70     (dynamic_space_free_pointer                                         \
71      = (lispobj*) ((unsigned long) dynamic_space_free_pointer & ~flag_PseudoAtomic))
72 #define get_pseudo_atomic_interrupted(thread)                           \
73     ((unsigned long) dynamic_space_free_pointer & flag_PseudoAtomicInterrupted)
74 #define clear_pseudo_atomic_interrupted(thread)                         \
75     (dynamic_space_free_pointer                                         \
76      = (lispobj*) ((unsigned long) dynamic_space_free_pointer & ~flag_PseudoAtomicInterrupted))
77 #define set_pseudo_atomic_interrupted(thread)                           \
78     (dynamic_space_free_pointer                                         \
79      = (lispobj*) ((unsigned long) dynamic_space_free_pointer | flag_PseudoAtomicInterrupted))
80
81 #endif
82
83 #endif /* PSEUDO_ATOMIC_H */
84