summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-03-01 10:10:25 +0000
committerSimon Marlow <marlowsd@gmail.com>2011-03-01 10:10:25 +0000
commit59977b6c7cc81777dc6f8266c68945d1ab691aec (patch)
tree8a72ed52c2bb57abdb910520627c77a46581b02c
parent3da491217855adfe4eeace6493c9a625e23965ea (diff)
downloadhaskell-59977b6c7cc81777dc6f8266c68945d1ab691aec.tar.gz
GHC.Prim.threadStatus# now returns the cap number, and the value of TSO_LOCKED
-rw-r--r--compiler/prelude/primops.txt.pp2
-rw-r--r--includes/mkDerivedConstants.c1
-rw-r--r--rts/PrimOps.cmm13
3 files changed, 13 insertions, 3 deletions
diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
index 525a837940..777e83fe74 100644
--- a/compiler/prelude/primops.txt.pp
+++ b/compiler/prelude/primops.txt.pp
@@ -1449,7 +1449,7 @@ primop NoDuplicateOp "noDuplicate#" GenPrimOp
has_side_effects = True
primop ThreadStatusOp "threadStatus#" GenPrimOp
- ThreadId# -> State# RealWorld -> (# State# RealWorld, Int# #)
+ ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
with
out_of_line = True
has_side_effects = True
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
index 41cf1d742f..b02b6c86f0 100644
--- a/includes/mkDerivedConstants.c
+++ b/includes/mkDerivedConstants.c
@@ -234,6 +234,7 @@ main(int argc, char *argv[])
field_offset(Capability, r);
field_offset(Capability, lock);
+ struct_field(Capability, no);
struct_field(Capability, mut_lists);
struct_field(Capability, context_switch);
struct_field(Capability, sparks);
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 7a7942abcc..701654af49 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -631,7 +631,7 @@ stg_threadStatuszh
W_ tso;
W_ why_blocked;
W_ what_next;
- W_ ret;
+ W_ ret, cap, locked;
tso = R1;
@@ -651,7 +651,16 @@ stg_threadStatuszh
ret = why_blocked;
}
}
- RET_N(ret);
+
+ cap = TO_W_(Capability_no(StgTSO_cap(tso)));
+
+ if ((TO_W_(StgTSO_flags(tso)) & TSO_LOCKED) != 0) {
+ locked = 1;
+ } else {
+ locked = 0;
+ }
+
+ RET_NNN(ret,cap,locked);
}
/* -----------------------------------------------------------------------------