Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector IO and unpinned arrays #8

Open
andrewthad opened this issue Feb 27, 2019 · 0 comments
Open

Vector IO and unpinned arrays #8

andrewthad opened this issue Feb 27, 2019 · 0 comments

Comments

@andrewthad
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant