Skip to content

Use FFI for unaligned reads#235

Merged
konsumlamm merged 2 commits intohaskell:masterfrom
konsumlamm:unaligned-read
Apr 20, 2026
Merged

Use FFI for unaligned reads#235
konsumlamm merged 2 commits intohaskell:masterfrom
konsumlamm:unaligned-read

Conversation

@konsumlamm
Copy link
Copy Markdown
Contributor

Closes #226.

The C code uses memcpy, which operates at the byte level, so unaligned accesses are handled correctly.

In my benchmark, the FFI variant is just slightly slower than using the unaligned primops. The sizeOf calls are simplified to constants.

@konsumlamm konsumlamm merged commit d7a2ce2 into haskell:master Apr 20, 2026
15 checks passed
@konsumlamm konsumlamm deleted the unaligned-read branch April 20, 2026 13:03
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

Successfully merging this pull request may close these issues.

Undefined behavior because of unaligned reads?

1 participant