From: Simon Marlow Date: Wed, 25 Jul 2007 09:55:50 +0000 (+0000) Subject: Handle buffers should be allocated with newPinnedByteArray# always X-Git-Url: http://git.megacz.com/?p=ghc-base.git;a=commitdiff_plain;h=cc4dd66d902a438d614f3031c89c7a5d5a555528 Handle buffers should be allocated with newPinnedByteArray# always Not just on Windows. This change is required because we now use safe foreign calls for I/O on blocking file descriptors with the threaded RTS. Exposed by concio001.thr on MacOS X: MacOS apparently uses smaller buffers by default, so they weren't being allocated as large objects. --- diff --git a/GHC/Handle.hs b/GHC/Handle.hs index fc4d613..37d78e6 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -376,15 +376,9 @@ newEmptyBuffer b state size allocateBuffer :: Int -> BufferState -> IO Buffer allocateBuffer sz@(I# size) state = IO $ \s -> -#ifdef mingw32_HOST_OS - -- To implement asynchronous I/O under Win32, we have to pass - -- buffer references to external threads that handles the - -- filling/emptying of their contents. Hence, the buffer cannot - -- be moved around by the GC. + -- We sometimes need to pass the address of this buffer to + -- a "safe" foreign call, hence it must be immovable. case newPinnedByteArray# size s of { (# s, b #) -> -#else - case newByteArray# size s of { (# s, b #) -> -#endif (# s, newEmptyBuffer b state sz #) } writeCharIntoBuffer :: RawBuffer -> Int -> Char -> IO Int