OpenCOBOL 1.1pre-rel
|
00001 #include <stdio.h> 00002 #include <string.h> 00003 00004 int 00005 main () 00006 { 00007 #ifdef __i386__ 00008 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3 00009 #if __GNUC__ > 3 || __GNUC_MINOR__ > 3 00010 char *ctune = "-mtune="; 00011 #else 00012 char *ctune = "-mcpu="; 00013 #endif 00014 char vendor_string[16]; 00015 int eax, ebx, edx, ecx; 00016 int i, hv; 00017 int family, model, stepping; 00018 00019 __asm__ (".byte 0x0f,0xa2" 00020 : "=a" (hv), "=b" (ebx), "=d" (edx), "=c" (ecx) : "0" (0)); 00021 00022 *(int *) (vendor_string + 0) = ebx; 00023 *(int *) (vendor_string + 4) = edx; 00024 *(int *) (vendor_string + 8) = ecx; 00025 vendor_string[12] = 0; 00026 i = 1; 00027 00028 __asm__ (".byte 0x0f,0xa2" 00029 : "=a" (eax), "=b" (ebx), "=d" (edx), "=c" (ecx) : "0" (i)); 00030 00031 family = (eax >> 8) & 0xf; 00032 model = (eax >> 4) & 0xf; 00033 stepping = eax & 0xf; 00034 if (family == 0xf) { 00035 /* "extended" mode. */ 00036 family += (eax >> 20) & 0xff; 00037 model += (eax >> 12) & 0xf0; 00038 } 00039 00040 if (strcmp (vendor_string, "GenuineIntel") == 0) { 00041 if (family == 5) { 00042 printf ("-march=i686 %spentium", ctune); 00043 } else if (family == 6) { 00044 if (model <= 2) { 00045 printf ("-march=i686 %spentiumpro",ctune); 00046 } else if (model >= 3 && model <= 6) { 00047 printf ("-march=i686 %spentium2",ctune); 00048 } else if (model <= 11) { 00049 printf ("-march=i686 %spentium3", ctune); 00050 } else { 00051 printf ("-march=i686 %spentium4", ctune); 00052 } 00053 } 00054 else if (family == 15) { 00055 printf ("-march=i686 %spentium4", ctune); 00056 } 00057 } else if (strcmp (vendor_string, "AuthenticAMD") == 0) { 00058 if (family == 6) { 00059 printf ("-march=i686 %sathlon", ctune); 00060 } 00061 } 00062 #endif 00063 #endif 00064 return 0; 00065 }