Search code examples
linuxpowerpc

How to do a runtime check for power7 or greater on LinuxPPC?


I can check for power7+ on AIX with something like:

inline bool ossPower7orLater( )
{
   #if defined _AIX
      if ( !__power_set( POWER_6 | POWER_5 | POWER_4 ) )
      {
         return true ;
      }
      else
   #endif
         return false ;
}

using macros from systemcfg.h. Here the __power_set() macro is used instead of __power_7() to avoid coding a check for power7 that will break when power8 comes out.

How would this be extended to include support for LinuxPPC too? I could imagine there's probably some instruction that could be used, so pointing me at that if there's nothing better would be acceptable (ie: I could code up an asm block if I knew what to use).


Solution

  • Was able to do this by checking the ELF AUX header as discussed here:

    programatic way to find ELF aux header (or envp) in shared library code?