Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 26 lines (21 sloc) 0.395 kb
119cb0d9 »
2012-09-09 detect-virt: simple yes/no virtualization detection
1 #include <stdint.h>
2
3 #if defined (__i386__)
4 #define REG_a "eax"
5 #define REG_b "ebx"
6 #elif defined (__amd64__)
7 #define REG_a "rax"
8 #define REG_b "rbx"
9 #endif
10
11 int main(void)
12 {
13 uint32_t eax, ecx;
14
15 eax = 1;
16 __asm__ __volatile__ (
17 " push %%" REG_b " \n\t"
18 " cpuid \n\t"
19 " pop %%" REG_b " \n\t"
20
21 : "=a" (eax), "=c" (ecx)
22 : "0" (eax)
23 );
24
25 return !!!(ecx & 0x80000000U);
26 }
Something went wrong with that request. Please try again.