Handle buffers should be allocated with newPinnedByteArray# always
authorSimon Marlow <simonmar@microsoft.com>
Wed, 25 Jul 2007 09:55:50 +0000 (09:55 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Wed, 25 Jul 2007 09:55:50 +0000 (09:55 +0000)
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.

GHC/Handle.hs

index fc4d613..37d78e6 100644 (file)
@@ -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