@@ -73,17 +73,17 @@ public struct AsyncRandomAccessFile: ~Copyable, Sendable {
7373 }
7474 return stats. st_size
7575 }
76-
76+
7777 deinit {
7878 // Ensure we've closed the file if we're going out of scope
7979 if !isClosed {
80- unistd . close ( fileDescriptor)
80+ Darwin . close ( fileDescriptor)
8181 }
8282 }
8383
8484 public consuming func close( ) {
8585 isClosed = true
86- unistd . close ( fileDescriptor)
86+ Darwin . close ( fileDescriptor)
8787 }
8888}
8989
@@ -213,7 +213,7 @@ private final class WriteOperation: AsyncIOOperation {
213213 private struct OperationResult {
214214 var dataToWrite : Data
215215 var controlBlockPointer : UnsafeMutablePointer < aiocb > ?
216- var externalDataToWrite : UnsafeMutablePointer < CChar > ?
216+ var externalDataToWrite : UnsafeMutableRawBufferPointer ?
217217 }
218218
219219 private let fileDescriptor : Int32
@@ -243,21 +243,21 @@ private final class WriteOperation: AsyncIOOperation {
243243 let error = mutableBits. withLock { [ fileDescriptor, offset] mutableBits in
244244 let byteCount = mutableBits. dataToWrite. count
245245 let controlBlockPointer = UnsafeMutablePointer< aiocb> . allocate( capacity: 1 )
246- controlBlockPointer. pointee = mutableBits. dataToWrite. withUnsafeMutableBytes { rawPointer in
247- let unsafeMutablePointer : UnsafeMutablePointer < CChar >
246+ controlBlockPointer. pointee = mutableBits. dataToWrite. withUnsafeMutableBytes { ( rawBufferPointer : UnsafeMutableRawBufferPointer ) in
247+ let unsafeMutablePointer : UnsafeMutableRawBufferPointer
248248 if byteCount > 16 {
249249 // This is probably not inline data, so use it as is. YOLO
250- unsafeMutablePointer = rawPointer
250+ unsafeMutablePointer = rawBufferPointer
251251 } else {
252252 // This is probably inline data, so make a copy
253- unsafeMutablePointer = UnsafeMutablePointer < CChar > . allocate( capacity : byteCount)
254- unsafeMutablePointer. initialize ( from: rawPointer , count : byteCount )
253+ unsafeMutablePointer = UnsafeMutableRawBufferPointer . allocate ( byteCount : byteCount, alignment : 16 )
254+ unsafeMutablePointer. copyBytes ( from: rawBufferPointer )
255255 mutableBits. externalDataToWrite = unsafeMutablePointer
256256 }
257- return aiocb (
257+ return aiocb (
258258 aio_fildes: fileDescriptor,
259259 aio_offset: offset,
260- aio_buf: unsafeMutablePointer,
260+ aio_buf: unsafeMutablePointer. baseAddress ,
261261 aio_nbytes: byteCount,
262262 aio_reqprio: 0 ,
263263 aio_sigevent: sigevent (
0 commit comments