X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fpseudo-atomic.h;h=230e3e85e22b17a1c91728823e0cac27138d0cef;hb=ab5427d31da2bd95805cccc8e47b8f43d3dd606d;hp=9636e5b3a4e2bedb765285479776138963aa3318;hpb=de0a47a2f2b165f34177669bd9499135847b4897;p=sbcl.git diff --git a/src/runtime/pseudo-atomic.h b/src/runtime/pseudo-atomic.h index 9636e5b..230e3e8 100644 --- a/src/runtime/pseudo-atomic.h +++ b/src/runtime/pseudo-atomic.h @@ -22,8 +22,6 @@ SetSymbolValue(ALLOCATION_POINTER, value, 0) #define get_alloc_pointer() \ SymbolValue(ALLOCATION_POINTER, 0) -#define get_binding_stack_pointer(thread) \ - SymbolValue(BINDING_STACK_POINTER, thread) #if defined(LISP_FEATURE_X86) #define LISPOBJ_ASM_SUFFIX "l" @@ -34,18 +32,19 @@ static inline int get_pseudo_atomic_atomic(struct thread *thread) { - return fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) & - make_fixnum(1)); + return SymbolValue(PSEUDO_ATOMIC_BITS, thread) & (~1); } static inline void set_pseudo_atomic_atomic(struct thread *thread) { lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread); + if (*p) + lose("set_pseudo_atomic_atomic: pseudo atomic bits is %d.", *p); __asm__ __volatile__ ("or" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (make_fixnum(1)), "m" (*p) + : "g" (~1), "m" (*p) : "memory"); } @@ -56,42 +55,45 @@ clear_pseudo_atomic_atomic(struct thread *thread) __asm__ __volatile__ ("and" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (~make_fixnum(1)), "m" (*p) + : "g" (1), "m" (*p) : "memory"); } static inline int get_pseudo_atomic_interrupted(struct thread *thread) { - return fixnum_value(SymbolValue(PSEUDO_ATOMIC_BITS, thread) & - make_fixnum(2)); + return SymbolValue(PSEUDO_ATOMIC_BITS, thread) & 1; } static inline void set_pseudo_atomic_interrupted(struct thread *thread) { + if (!get_pseudo_atomic_atomic(thread)) + lose("set_pseudo_atomic_interrupted not in pseudo atomic"); lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread); __asm__ __volatile__ ("or" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (make_fixnum(2)), "m" (*p) + : "g" (1), "m" (*p) : "memory"); } static inline void clear_pseudo_atomic_interrupted(struct thread *thread) { + if (get_pseudo_atomic_atomic(thread)) + lose("clear_pseudo_atomic_interrupted in pseudo atomic"); lispobj *p = SymbolValueAddress(PSEUDO_ATOMIC_BITS, thread); __asm__ __volatile__ ("and" LISPOBJ_ASM_SUFFIX " %0,%1" : - : "g" (~make_fixnum(2)), "m" (*p) + : "g" (~1), "m" (*p) : "memory"); } #undef LISPOBJ_SUFFIX -#elif defined(LISP_FEATURE_PPC) && defined(LISP_FEATURE_GENCGC) +#elif defined(LISP_FEATURE_GENCGC) /* FIXME: Are these async signal safe? Compiler reordering? */ @@ -102,8 +104,21 @@ clear_pseudo_atomic_interrupted(struct thread *thread) #define get_alloc_pointer() \ ((unsigned long) dynamic_space_free_pointer & ~LOWTAG_MASK) -#define get_binding_stack_pointer(thread) \ - (current_binding_stack_pointer) + +#ifdef LISP_FEATURE_SB_THREAD +#define get_pseudo_atomic_atomic(thread) \ + ((thread)->pseudo_atomic_bits & flag_PseudoAtomic) +#define set_pseudo_atomic_atomic(thread) \ + ((thread)->pseudo_atomic_bits |= flag_PseudoAtomic) +#define clear_pseudo_atomic_atomic(thread) \ + ((thread)->pseudo_atomic_bits &= ~flag_PseudoAtomic) +#define get_pseudo_atomic_interrupted(thread) \ + ((thread)->pseudo_atomic_bits & flag_PseudoAtomicInterrupted) +#define set_pseudo_atomic_interrupted(thread) \ + ((thread)->pseudo_atomic_bits |= flag_PseudoAtomicInterrupted) +#define clear_pseudo_atomic_interrupted(thread) \ + ((thread)->pseudo_atomic_bits &= ~flag_PseudoAtomicInterrupted) +#else #define get_pseudo_atomic_atomic(thread) \ ((unsigned long)dynamic_space_free_pointer & flag_PseudoAtomic) #define set_pseudo_atomic_atomic(thread) \ @@ -120,6 +135,7 @@ clear_pseudo_atomic_interrupted(struct thread *thread) #define set_pseudo_atomic_interrupted(thread) \ (dynamic_space_free_pointer \ = (lispobj*) ((unsigned long) dynamic_space_free_pointer | flag_PseudoAtomicInterrupted)) +#endif #endif