-
Notifications
You must be signed in to change notification settings - Fork 58
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
Support unaligned GC array accesses in Prim
#409
Comments
I have some WIP code at https://github.com/raehik/primitive/tree/raehik/unaligned-array-accesses . |
Prim
Prim
A different approach is taken at https://hackage.haskell.org/package/primitive-unaligned-0.1.1.2/docs/Data-Primitive-ByteArray-Unaligned.html In |
Regarding unaligned ByteArray primops, I can find Thanks for the On a related note, would you take a |
What's interesting about your type that makes endianness explicit in bytezap is that it's the same exact way I approached the problem in the byte-order library in We might be able to drop support for GHC < 8.6 soon. Currently we support all the way back to GHC 8.0. I'll open a separate thread discussing when older GHCs can be dropped. I'll take any PRs to primitive-unaligned even before GHC 9.10 is properly released. If you're playing around with a release candidate of it and you're able to incorporate the unaligned |
Fab! Thanks for letting me know about I might have a think about safely emulating unaligned |
|
Using the FFI for the shim isn't necessary. For reading/indexing, see Data.Bytes.Parser.BigEndian:word64 for an example of how to do this:
And for the other direction, writing, see Data.Bytes.Builder.Bounded:word64BE:
Admittedly, that's for |
Thanks and understood, shame because it's got poor performance but it is a compat layer. I'll start a PR on prim-unaligned later :) |
GHC exposes a set of
(read|write|index)Word8ArrayAs[ty]#
primops for safe unaligned accesses to GC pointers. I think thePrim
class could sensibly expose these.Also note that similar primops for
Addr#
non-GC pointers will be coming in GHC 9.10 .The text was updated successfully, but these errors were encountered: