You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I originally thought this wasn't possible. That is, I originally thought that wrappers for writev, recvmmsg, etc. were doomed to only work on pinned byte arrays. But, it should actually be possible to pass an UnliftedArray of ByteArrays to to a C function with the unsafe FFI. Of course, now we have an array of pointers to GHC heap objects (meaning that the Header and the byte count are present, taking up two machine words). We would want to include Closures.h for portability rather than hard-coding the two-word-prefix assumption. The only tricky part is that, from C, we need to allocate something to hold the pointers to the buffers. After all, we cannot feed a value of type StgArrBytes into any of the posix functions. Here, we can use a variable length array, since we can easily figure out the total size of what we need. And then it should all work.
The difficulty is that more of the code will need to be written in C. This includes some of the error checking code. Oh well.
The text was updated successfully, but these errors were encountered:
I originally thought this wasn't possible. That is, I originally thought that wrappers for
writev
,recvmmsg
, etc. were doomed to only work on pinned byte arrays. But, it should actually be possible to pass anUnliftedArray
ofByteArray
s to to a C function with the unsafe FFI. Of course, now we have an array of pointers to GHC heap objects (meaning that the Header and the byte count are present, taking up two machine words). We would want to includeClosures.h
for portability rather than hard-coding the two-word-prefix assumption. The only tricky part is that, from C, we need to allocate something to hold the pointers to the buffers. After all, we cannot feed a value of typeStgArrBytes
into any of the posix functions. Here, we can use a variable length array, since we can easily figure out the total size of what we need. And then it should all work.The difficulty is that more of the code will need to be written in C. This includes some of the error checking code. Oh well.
The text was updated successfully, but these errors were encountered: