[commit: ghc] wip/ghc-8.8-merges: base: Document errno behaviour in haddocks. (beb7f9b)

git at git.haskell.org git at git.haskell.org
Thu Feb 21 15:11:41 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/ghc-8.8-merges
Link       : http://ghc.haskell.org/trac/ghc/changeset/beb7f9ba73b8cac469f15fa8ab31f1e21b4c1cb9/ghc

>---------------------------------------------------------------

commit beb7f9ba73b8cac469f15fa8ab31f1e21b4c1cb9
Author: Niklas Hambüchen <mail at nh2.me>
Date:   Thu Feb 14 16:52:17 2019 -0500

    base: Document errno behaviour in haddocks.
    
    Also add an implementation comment for details.
    
    (cherry picked from commit 76ac103f5021cba5cd000293c7cb8c2bd3148e7a)


>---------------------------------------------------------------

beb7f9ba73b8cac469f15fa8ab31f1e21b4c1cb9
 libraries/base/Foreign/C/Error.hs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libraries/base/Foreign/C/Error.hs b/libraries/base/Foreign/C/Error.hs
index 90b949b..6d6c0cc 100644
--- a/libraries/base/Foreign/C/Error.hs
+++ b/libraries/base/Foreign/C/Error.hs
@@ -255,11 +255,15 @@ isValidErrno (Errno errno)  = errno /= -1
 
 -- | Get the current value of @errno@ in the current thread.
 --
+-- On GHC, the runtime will ensure that any Haskell thread will only see "its own"
+-- @errno@, by saving and restoring the value when Haskell threads are scheduled
+-- across OS threads.
 getErrno :: IO Errno
 
 -- We must call a C function to get the value of errno in general.  On
 -- threaded systems, errno is hidden behind a C macro so that each OS
--- thread gets its own copy.
+-- thread gets its own copy (`saved_errno`, which `rts/Schedule.c` restores
+-- back into the thread-local `errno` when a Haskell thread is rescheduled).
 getErrno = do e <- get_errno; return (Errno e)
 foreign import ccall unsafe "HsBase.h __hscore_get_errno" get_errno :: IO CInt
 



More information about the ghc-commits mailing list