Skip to content
Permalink
Browse files

Introducing Kernel.Endian

Returns the appropriate Endian enum for the current kernel architecture,
either LittleEndian or BigEndian.
  • Loading branch information...
lizmat committed Dec 12, 2018
1 parent dd2af90 commit 2a761ca7af3e66f6a5cad90ea9f483cd19066ba7
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/core/Kernel.pm6
@@ -184,6 +184,18 @@ class Kernel does Systemic {
+ nqp::atpos_i(@rusage, nqp::const::RUSAGE_STIME_SEC) * 1000000
+ nqp::atpos_i(@rusage, nqp::const::RUSAGE_STIME_MSEC)
}

my $endian := nqp::null;
method Endian(--> Endian:D) {
nqp::ifnull(
$endian,
nqp::bind($endian,nqp::if(
blob8.new(0,1).read-int16(0) == 1, # hacky way to find out
BigEndian,
LittleEndian
))
)
}
}

Rakudo::Internals.REGISTER-DYNAMIC: '$*KERNEL', {

0 comments on commit 2a761ca

Please sign in to comment.
You can’t perform that action at this time.