Solved Endianness on aarch64, powerpc64 and riscv64?

Hello everyone,

Do you know the endianness used by FreeBSD on these platforms?
  • 64-bit ARMv8 (aarch64)
  • 64-bit PowerPC (powerpc64)
  • 64-bit RISC-V (riscv64)

If you have a computer with one of those architectures, you can find out the endianness of FreeBSD on that architecture by compiling and executing this C program:

C:
#include <stdio.h>

union word {
    unsigned long long int i;
    unsigned char c[8];
};

int main(void) {
    union word w;
    w.i = 0x0102030405060708ull;
    if (w.c[0] == 8)
        printf("Little-endian.\n");
    if (w.c[0] == 1)
        printf("Big-endian.\n");
    return 0;
}

To compile this program, you can save the above source code in a file named file.c and run the command clang file.c . You can then execute the program by running the command ./a.out .

If you do this, it would be nice to also include the result of the commands clang --version and uname -m , to check which architecture you have.

Thank you.
 
Back
Top