Note: Rakudo 2018.12 is introducing the endian-sensitiveread-int16 method, which makes endian detection a little easier:
In Rakudo 2019.01 the dynamic KERNEL variable was fleshed out with a bunch of accessors, among them:
Output:
use NativeCall;
say $*VM.config<ptr_size>;
my $bytes = nativecast(CArray[uint8], CArray[uint16].new(1));
say $bytes[0] ?? "little-endian" !! "big-endian";
8
little-endian
say blob8.new(1,0).read-int16(0) == 1 ?? "little-endian" !! "big-endian"
say join ', ', $*KERNEL, $*KERNEL.bits, $*KERNEL.arch, $*KERNEL.endian