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.
allocateBuffer :: Int -> BufferState -> IO Buffer
allocateBuffer sz@(I# size) state = IO $ \s ->
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 #) ->
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
(# s, newEmptyBuffer b state sz #) }
writeCharIntoBuffer :: RawBuffer -> Int -> Char -> IO Int