(Thanks for the replies, and sorry if I'm a bother... I am asking all of
this in detail because it's not for a single project that I want to
support -- it's to have these details sorted out before I start to send
patches to upstream projects.
The easier to understand and the more similar to what other arches do
the better, in order to get upstream to accept them with as little
friction as possible.
And if this changes later and I/we have to repeat the process, is a
mess.)
2017-02-07 23:06 Andrew Waterman:
>Hi Manuel,
>
>I think Stefan's point is that XLEN and the size of a pointer are not
>necessarily equal. __riscv and __riscv_xlen will be defined on RISC-V
>systems, but even if __riscv_xlen == 64, it may not be the case that
>__SIZEOF_POINTER__ == 8. Similarly, __aarch64__ may be defined when
>pointers are 4 bytes, because of their ILP32 ABI.
Yeah, I got that.
The vast majority of arch-specific support that I have seen in upstream
projects starts with checks of self-explanatory strings like "#ifdef
__aarch64__", for all architectures/ABIs, including recent ones like
this aarch64 or aarch64_ilp32, or __x86_64__ and x32.
So even if that solution is more correct, I think that it will cause
some friction to integrate in the projects.
But if it's the only solution, well, it'll have to be that way :)
>So use __SIZEOF_POINTER__ to condition on pointer size, and
>__riscv_xlen to condition on ISA, and their conjunction to condition
>on the overall ABI.
Unfortunately, I think that __SIZEOF_POINTER__ is out of question as a
general pattern if it's a GCC-only extension.
Cheers and thanks for the advice.