diff options
Diffstat (limited to 'rts/PrimOps.cmm')
-rw-r--r-- | rts/PrimOps.cmm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 60d0dc2ccc..9e86a8e0a2 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -689,6 +689,17 @@ stg_newMutVarzh ( gcptr init ) return (mv); } +stg_atomicSwapMutVarzh ( gcptr mv, gcptr new ) + /* MutVar# s a -> a -> State# s -> (# State#, a #) */ +{ + W_ old; + (old) = prim %xchgW(mv + SIZEOF_StgHeader + OFFSET_StgMutVar_var, new); + if (GET_INFO(mv) == stg_MUT_VAR_CLEAN_info) { + ccall dirty_MUT_VAR(BaseReg "ptr", mv "ptr", old "ptr"); + } + return (old); +} + // RRN: To support the "ticketed" approach, we return the NEW rather // than old value if the CAS is successful. This is received in an // opaque form in the Haskell code, preventing the compiler from |