lkml.org 
[lkml]   [2017]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [sample] A sample program for MRS emulation
From
Date
On 30/11/16 16:27, Dave Martin wrote:
> 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).

Dave,

Thanks for taking a look. Apologies for the late response. We could
either add it to the Documentation or stick it into samples/. I prefer
the Documentation, as it would help the text.

>
>>
>> ----8>----
>> /*
>> * Sample program to demonstrate the MRS emulation
>> * ABI.
>
> overwrapped?

will fix it.

>

>> 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.
>

Makes sense.

> --8<--
>
> #include <sys/auxv.h>
> #include <asm/hwcap.h>
>
> /* ... */
>
> if (!getauxval(AT_HWCAP) & HWCAP_CPUID) {
> fputs("CPUID registers unavailable\n", stderr);
> return 1;
> }
>
> -->8--

Cheers
Suzuki

\
 
 \ /
  Last update: 2017-01-03 16:39    [W:0.042 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site