summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2013-07-10 13:32:15 -0700
committerEdward Z. Yang <ezyang@mit.edu>2013-07-10 13:32:15 -0700
commitdb8d4a345ef77bc6832e9496e0ba38c8e36cadff (patch)
tree7c392036f854725ee3dbc1dfc5056fe28f35027b /rts
parent190d34a68945120f5e283fc1c64ed6fe49710213 (diff)
downloadhaskell-db8d4a345ef77bc6832e9496e0ba38c8e36cadff.tar.gz
Implement tryAtomicReadMVar#.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c1
-rw-r--r--rts/PrimOps.cmm16
2 files changed, 17 insertions, 0 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 9129b46be6..1389b4ff87 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1319,6 +1319,7 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(stg_threadStatuszh) \
SymI_HasProto(stg_tryPutMVarzh) \
SymI_HasProto(stg_tryTakeMVarzh) \
+ SymI_HasProto(stg_tryAtomicReadMVarzh) \
SymI_HasProto(stg_unmaskAsyncExceptionszh) \
SymI_HasProto(unloadObj) \
SymI_HasProto(stg_unsafeThawArrayzh) \
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index abe54c82c6..6bb938eae4 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -1567,6 +1567,22 @@ stg_atomicReadMVarzh ( P_ mvar, /* :: MVar a */ )
return (val);
}
+stg_tryAtomicReadMVarzh ( P_ mvar, /* :: MVar a */ )
+{
+ W_ val, info, tso, q;
+
+ LOCK_CLOSURE(mvar, info);
+
+ if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
+ return (0, stg_NO_FINALIZER_closure);
+ }
+
+ val = StgMVar_value(mvar);
+
+ unlockClosure(mvar, stg_MVAR_DIRTY_info);
+ return (1, val);
+}
+
/* -----------------------------------------------------------------------------
Stable pointer primitives
------------------------------------------------------------------------- */