Hacker News new | ask | show | jobs
by tmgross 816 days ago
Elaborating on the problems - _BitInt(128) has an alignment of 8, meaning that C's _BitInt(128) and __int128 are incompatible, similar to the Rust-C incompatibility that was just fixed :(.

https://groups.google.com/g/x86-64-abi/c/-JeR9HgUU20

1 comments

It's actually worse than that; from what I can piece together of the history:

  1. the people at Intel who originally implemented `_BitInt()` made `_BitInt(128)` eight-byte aligned
  2. the x86_64 psABI document was updated to agree with that
  3. it was implemented in clang in such a way that it also made `_BitInt(128)` eight-byte aligned on arm64 ...
  4. ... but the AAPCS says that it's sixteen-byte aligned
  5. ... and maybe the x86_64 psABI is going to change to say that it's sixteen byte aligned after-all.
So--as of a month ago when I was studying this because we're in the middle of enabling `[U]Int128` in Swift--_BitInt(128) didn't agree with __int128[_t] on either platform, and that's definitely a bug on arm64, and, although it behaves as documented on x86_64, that also might change.