summaryrefslogtreecommitdiff
path: root/includes/RtsAPI.h
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2009-06-12 11:41:56 +0000
committerDuncan Coutts <duncan@well-typed.com>2009-06-12 11:41:56 +0000
commit85df606a23117641682e19f3851099134e5f77a4 (patch)
tree6eee4ab0b86a7ba96aece61bb16e1abc409a4e56 /includes/RtsAPI.h
parentf5c113de54455bc1320da4674c70e17598832533 (diff)
downloadhaskell-85df606a23117641682e19f3851099134e5f77a4.tar.gz
Add and export rts_unsafeGetMyCapability from rts
We need this, or something equivalent, to be able to implement stgAllocForGMP outside of the rts. That's because we want to use allocateLocal which allocates from the given capability without having to take any locks. In the gmp primops we're basically in an unsafe foreign call, that is a context where we hold a current capability. So it's safe for us to use allocateLocal. We just need a way to get the current capability. The method to get the current capability varies depends on whether we're using the threaded rts or not. When stgAllocForGMP is built inside the rts that's ok because we can do it conditionally on THREADED_RTS. Outside the rts we need a single api we can call without knowing if we're talking to a threaded rts or not, hence this addition.
Diffstat (limited to 'includes/RtsAPI.h')
-rw-r--r--includes/RtsAPI.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h
index 41f0fc026c..5160046da8 100644
--- a/includes/RtsAPI.h
+++ b/includes/RtsAPI.h
@@ -66,6 +66,15 @@ Capability *rts_lock (void);
// releases the token acquired with rts_lock().
void rts_unlock (Capability *token);
+// If you are in a context where you know you have a current capability but
+// do not know what it is, then use this to get it. Basically this only
+// applies to "unsafe" foreign calls (as unsafe foreign calls are made with
+// the capability held).
+//
+// WARNING: There is *no* guarantee this returns anything sensible (eg NULL)
+// when there is no current capability.
+Capability *rts_unsafeGetMyCapability (void);
+
/* ----------------------------------------------------------------------------
Building Haskell objects from C datatypes.
------------------------------------------------------------------------- */