Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're on Linux (or on Windows running under Cygwin), you can figure that out by reading the special file <code>/proc/cpuinfo</code> and looking for the line beginning with <code>vendor_id</code>. If the string is <code>GenuineIntel</code>, you're running on an Intel chip. If you get <code>AuthenticAMD</code>, you're running on an AMD chip.</p> <pre><code>void get_vendor_id(char *vendor_id) // must be at least 13 bytes { FILE *cpuinfo = fopen("/proc/cpuinfo", "r"); if(cpuinfo == NULL) ; // handle error char line[256]; while(fgets(line, 256, cpuinfo)) { if(strncmp(line, "vendor_id", 9) == 0) { char *colon = strchr(line, ':'); if(colon == NULL || colon[1] == 0) ; // handle error strncpy(vendor_id, 12, colon + 2); fclose(cpuinfo); return; } } // if we got here, handle error fclose(cpuinfo); } </code></pre> <p>If you know you're running on an x86 architecture, a less portable method would be to use the CPUID instruction:</p> <pre><code>void get_vendor_id(char *vendor_id) // must be at least 13 bytes { // GCC inline assembler __asm__ __volatile__ ("movl $0, %%eax\n\t" "cpuid\n\t" "movl %%ebx, %0\n\t" "movl %%edx, %1\n\t" "movl %%ecx, %2\n\t" : "=m"(vendor_id), "=m"(vendor_id + 4), "=m"(vendor_id + 8) // outputs : // no inputs : "%eax", "%ebx", "%edx", "%ecx", "memory"); // clobbered registers vendor_id[12] = 0; } int main(void) { char vendor_id[13]; get_vendor_id(vendor_id); if(strcmp(vendor_id, "GenuineIntel") == 0) ; // it's Intel else if(strcmp(vendor_id, "AuthenticAMD") == 0) ; // it's AMD else ; // other return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload