1  #include <stdio.h>
       2  #include <stdlib.h>
       3  #include "cpuid.h"
       4  
       5  static void bmi2_test (void);
       6  
       7  static void
       8  __attribute__ ((noinline))
       9  do_test (void)
      10  {
      11    bmi2_test ();
      12  }
      13  
      14  int
      15  main ()
      16  {
      17    unsigned int eax, ebx, ecx, edx;
      18  
      19    if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
      20      return 0;
      21  
      22    /* Run BMI2 test only if host has BMI2 support.  */
      23    if (ebx & bit_BMI2)
      24      {
      25        do_test ();
      26  #ifdef DEBUG
      27        printf ("PASSED\n");
      28  #endif
      29        return 0;
      30      }
      31  
      32  #ifdef DEBUG
      33    printf ("SKIPPED\n");
      34  #endif
      35    return 0;
      36  }