Safe/Unsafe calls with the GHC Foreign Function Interface

More questions from Rob regarding his mysterious bindings... So I've been reading the docs for the FFI, and it's my understanding that foreign functions imported as "unsafe" are faster, but they've got a problem with callbacks. From what I read, I believe that I should just make a foreign function safe if it sets up a callback; is this correct? Normally I wouldn't bother people with questions like this, but I'd rather be absolutely certain and avoid tracking down a strange bug later. Many thanks as always, Rob

On Thu, May 17, 2007 at 10:32:11PM -0500, Rob Hoelz wrote:
More questions from Rob regarding his mysterious bindings...
So I've been reading the docs for the FFI, and it's my understanding that foreign functions imported as "unsafe" are faster, but they've got a problem with callbacks. From what I read, I believe that I should just make a foreign function safe if it sets up a callback; is this correct? Normally I wouldn't bother people with questions like this, but I'd rather be absolutely certain and avoid tracking down a strange bug later.
Many thanks as always, Rob
If it *calls* a callback into haskell. Also, for unfathomable reasons, safety has been overloaded to include forking OS threads. If it could block (like getchar), you must make it safe. Stefan

Stefan O'Rear
On Thu, May 17, 2007 at 10:32:11PM -0500, Rob Hoelz wrote:
More questions from Rob regarding his mysterious bindings...
So I've been reading the docs for the FFI, and it's my understanding that foreign functions imported as "unsafe" are faster, but they've got a problem with callbacks. From what I read, I believe that I should just make a foreign function safe if it sets up a callback; is this correct? Normally I wouldn't bother people with questions like this, but I'd rather be absolutely certain and avoid tracking down a strange bug later.
Many thanks as always, Rob
If it *calls* a callback into haskell.
Also, for unfathomable reasons, safety has been overloaded to include forking OS threads. If it could block (like getchar), you must make it safe.
Stefan
Ouch...how bad is the overhead for a safe function?
participants (2)
-
Rob Hoelz
-
Stefan O'Rear