-
Notifications
You must be signed in to change notification settings - Fork 60
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
What about: "odd" pointer sizes #255
Comments
size is probably 4 for alignment reasons |
On 65816 at least, according to the definition I have used and written, As for (*On lccc, I would prefer that, even for accesses of size 0, it needs to point to an object. However because lccc has rules that allow it to invent objects, this can be trivially worked around) |
What about e.g. eZ80, which AFAIK has 24-bit addresses and no alignment requirements? |
I guess we could imagine the last byte of pointers and
They don't on normal platforms, but for weird things like 3-byte integers the best option might me to make an exception... |
A possible good idea would be to specify that the normal integer types
On 65816 the alignment requirement is imposed by the ABI (that is, there is no hardware level alignment on it either). It was done because pointers are a "scalar unit" which can be accessed as one value by the CPU, and sometimes, those accesses can wrap at the bank bounderies (every 64kiB), so I have to ensure no scalar unit can be allocated accross a bank. If the same problem arises there, the eZ80 target could act similarily to how I've defined it for the 65816. |
One problem with |
I mean, for |
The disadvantage of this idea is that now all code has to carry the cost of supporting exotic platforms. All unsafe code working with This could be implementation-defined though, i.e. rustc could guarantee absence of padding for those targets where the pointer size is a power of two. That makes life easier for unsafe code authors on the majority of platforms, at the cost of people working on exotic platforms (they need to have special audits for unsafe code). Frankly, this is likely what would happen anyway, even of we officially left things unspecified -- I doubt most unsafe code authors are even aware that such platforms exist. |
I wouldn't be opposed to the increased difficulty, provided its not disproportionate to the cost of shifting the burden to unsafe developers, and rust can be written on these platforms. In particular I would really benefit from being able to use rust as a frontend language for SNES-Dev, a toolchain I am writing for compiling SNES homebrew, which is a 65816 target (and the origin of the ABI in question, though it can be generalized to any 65816 platform). |
@chorman0773 brings up the issue of platforms where pointers have "strange" sizes, such as 3 bytes.
if Rust wants to support such platforms, interesting questions arise:
size_of::<*const ()> == 3
? That seems like the most obvious choice, but @chorman0773's comment indicates C makes the size 4 and the highest byte is somehow "dead". Not sure why a size of 4 would be reasonable though, if there are only 3 bytes of data.usize
a magicu24
, or is itu32
and usize-to-ptr casts truncate, or something else?I am probably also missing some aspects of this due to a lack of familiarity with such platforms. :)
This seems somewhat related to #29 in that it is about "strange platforms".
The text was updated successfully, but these errors were encountered: