riscv-non-isa / riscv-c-api-doc

Documentation of the RISC-V C API
https://lf-riscv.atlassian.net/browse/RVG-4
Creative Commons Attribution 4.0 International
75 stars 41 forks source link

Add macro to test endianness #87

Closed ismaeldamiao closed 1 week ago

ismaeldamiao commented 2 months ago

The RISC-V ELF Specification allow both big-endian and little-endian but there is no macro on RISC-V C API to check the host endianness.

ismaeldamiao commented 2 months ago

Simple, because this is a compiler dependent feature, but is reasonable to suppose that any compiler targeting RISC-V have support to RISC-V C API language extensions.

aswaterman commented 2 months ago

This is probably a solution in search of a problem, but couldn't we just mandate that, as part of the RISC-V C API, the __BYTE_ORDER__ etc. macros be defined?

It reflects reality, after all.

ismaeldamiao commented 2 months ago

In fact, looks better.