On Wed, Nov 30, 2016 at 03:15:01PM +0000, Suzuki K Poulose wrote:
Here is a sample program which demonstrates how to use mrs
emulation to fetch the ID registers.
Are we planning to add this in Documentation/? If so, we might want
some tweaks (noted below).
----8>----
/*
* Sample program to demonstrate the MRS emulation
* ABI.
overwrapped?
int main()
(void)
{
We don't wan't people using the MRS emulation without checking for its
availability first.
Something like this may work (untested), with the caveat that getauxval()
is a GNU libc extension, and other environments may require a different
mechanism to obtain the hwcaps.
--8<--
#include <sys/auxv.h>
#include <asm/hwcap.h>
/* ... */
if (!getauxval(AT_HWCAP) & HWCAP_CPUID) {
fputs("CPUID registers unavailable\n", stderr);
return 1;
}
-->8--