Skip to content

Vector IO and unpinned arrays #8

@andrewthad

Description

@andrewthad

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions