2 * macros for manipulating pseudo-atomic flags (per thread)
6 * This software is part of the SBCL system. See the README file for
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.
16 #ifndef PSEUDO_ATOMIC_H
17 #define PSEUDO_ATOMIC_H
19 #if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
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)
28 #if defined(LISP_FEATURE_X86)
29 #define LISPOBJ_ASM_SUFFIX "l"
30 #elif defined(LISP_FEATURE_X86_64)
31 #define LISPOBJ_ASM_SUFFIX "q"
35 get_pseudo_atomic_atomic(struct thread *thread)
37 return fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) &
42 set_pseudo_atomic_atomic(struct thread *thread)
44 lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread);
46 ("or" LISPOBJ_ASM_SUFFIX " %0,%1"
48 : "g" (make_fixnum(1)), "m" (*p)
53 clear_pseudo_atomic_atomic(struct thread *thread)
55 lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread);
57 ("and" LISPOBJ_ASM_SUFFIX " %0,%1"
59 : "g" (~make_fixnum(1)), "m" (*p)
64 get_pseudo_atomic_interrupted(struct thread *thread)
66 return fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) &
71 set_pseudo_atomic_interrupted(struct thread *thread)
73 lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread);
75 ("or" LISPOBJ_ASM_SUFFIX " %0,%1"
77 : "g" (make_fixnum(2)), "m" (*p)
82 clear_pseudo_atomic_interrupted(struct thread *thread)
84 lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread);
86 ("and" LISPOBJ_ASM_SUFFIX " %0,%1"
88 : "g" (~make_fixnum(2)), "m" (*p)
94 #elif defined(LISP_FEATURE_PPC) && defined(LISP_FEATURE_GENCGC)
96 /* FIXME: Are these async signal safe? Compiler reordering? */
98 #define set_alloc_pointer(value) \
99 (dynamic_space_free_pointer = \
101 ((value) | (((unsigned long)dynamic_space_free_pointer) & LOWTAG_MASK))))
103 #define get_alloc_pointer() \
104 ((unsigned long) dynamic_space_free_pointer & ~LOWTAG_MASK)
105 #define get_binding_stack_pointer(thread) \
106 (current_binding_stack_pointer)
107 #define get_pseudo_atomic_atomic(thread) \
108 ((unsigned long)dynamic_space_free_pointer & flag_PseudoAtomic)
109 #define set_pseudo_atomic_atomic(thread) \
110 (dynamic_space_free_pointer \
111 = (lispobj*) ((unsigned long)dynamic_space_free_pointer | flag_PseudoAtomic))
112 #define clear_pseudo_atomic_atomic(thread) \
113 (dynamic_space_free_pointer \
114 = (lispobj*) ((unsigned long) dynamic_space_free_pointer & ~flag_PseudoAtomic))
115 #define get_pseudo_atomic_interrupted(thread) \
116 ((unsigned long) dynamic_space_free_pointer & flag_PseudoAtomicInterrupted)
117 #define clear_pseudo_atomic_interrupted(thread) \
118 (dynamic_space_free_pointer \
119 = (lispobj*) ((unsigned long) dynamic_space_free_pointer & ~flag_PseudoAtomicInterrupted))
120 #define set_pseudo_atomic_interrupted(thread) \
121 (dynamic_space_free_pointer \
122 = (lispobj*) ((unsigned long) dynamic_space_free_pointer | flag_PseudoAtomicInterrupted))
126 #endif /* PSEUDO_ATOMIC_H */