From 5f7079b97e322fd84e99adb686c86afe6d7c8231 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 6 Feb 2009 13:01:30 +0000 Subject: [PATCH] add a single-threaded version of cas() --- includes/SMP.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/SMP.h b/includes/SMP.h index 5d74667..49bc336 100644 --- a/includes/SMP.h +++ b/includes/SMP.h @@ -218,6 +218,17 @@ xchg(StgPtr p, StgWord w) return old; } +STATIC_INLINE StgWord +cas(StgVolatilePtr p, StgWord o, StgWord n) +{ + StgWord result; + result = *p; + if (result == o) { + *p = n; + } + return result; +} + #endif /* !THREADED_RTS */ #endif /* SMP_H */ -- 1.7.10.4