This source file includes following definitions.
- hwloc_have_x86_cpuid
- hwloc_have_x86_cpuid
- hwloc_x86_cpuid
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 #ifndef HWLOC_PRIVATE_CPUID_X86_H
  12 #define HWLOC_PRIVATE_CPUID_X86_H
  13 
  14 #if (defined HWLOC_X86_32_ARCH) && (!defined HWLOC_HAVE_MSVC_CPUIDEX)
  15 static __hwloc_inline int hwloc_have_x86_cpuid(void)
  16 {
  17   int ret;
  18   unsigned tmp, tmp2;
  19   __asm__(
  20       "mov $0,%0\n\t"   
  21 
  22       "pushfl   \n\t"   
  23 
  24       "pushfl   \n\t"                                           \
  25       "pop %1   \n\t"                            \
  26 
  27 #define TRY_TOGGLE                                              \
  28       "xor $0x00200000,%1\n\t"            \
  29       "mov %1,%2\n\t"                  \
  30       "push %1  \n\t"                                           \
  31       "popfl    \n\t"                        \
  32       "pushfl   \n\t"                                           \
  33       "pop %1   \n\t"                                           \
  34       "cmp %1,%2\n\t"          \
  35       "jnz 0f\n\t"                  \
  36 
  37       TRY_TOGGLE        
  38       TRY_TOGGLE        
  39 
  40       "mov $1,%0\n\t"   
  41 
  42       "0: \n\t"
  43       "popfl    \n\t"   
  44 
  45       : "=r" (ret), "=&r" (tmp), "=&r" (tmp2));
  46   return ret;
  47 }
  48 #endif 
  49 #if (defined HWLOC_X86_64_ARCH) || (defined HWLOC_HAVE_MSVC_CPUIDEX)
  50 static __hwloc_inline int hwloc_have_x86_cpuid(void) { return 1; }
  51 #endif 
  52 
  53 static __hwloc_inline void hwloc_x86_cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
  54 {
  55 #ifdef HWLOC_HAVE_MSVC_CPUIDEX
  56   int regs[4];
  57   __cpuidex(regs, *eax, *ecx);
  58   *eax = regs[0];
  59   *ebx = regs[1];
  60   *ecx = regs[2];
  61   *edx = regs[3];
  62 #else 
  63   
  64 
  65 #ifdef HWLOC_X86_64_ARCH
  66   hwloc_uint64_t sav_rbx;
  67   __asm__(
  68   "mov %%rbx,%2\n\t"
  69   "cpuid\n\t"
  70   "xchg %2,%%rbx\n\t"
  71   "movl %k2,%1\n\t"
  72   : "+a" (*eax), "=m" (*ebx), "=&r"(sav_rbx),
  73     "+c" (*ecx), "=&d" (*edx));
  74 #elif defined(HWLOC_X86_32_ARCH)
  75   __asm__(
  76   "mov %%ebx,%1\n\t"
  77   "cpuid\n\t"
  78   "xchg %%ebx,%1\n\t"
  79   : "+a" (*eax), "=&SD" (*ebx), "+c" (*ecx), "=&d" (*edx));
  80 #else
  81 #error unknown architecture
  82 #endif
  83 #endif 
  84 }
  85 
  86 #endif