|
38 | 38 |
|
39 | 39 | #include <sys/utsname.h>
|
40 | 40 | #ifdef _AIX
|
| 41 | +#include <sys/systemcfg.h> |
41 | 42 | #include <sys/vminfo.h>
|
42 | 43 | #endif
|
43 | 44 | #ifdef __APPLE__
|
@@ -137,35 +138,19 @@ int detect(void){
|
137 | 138 | #endif
|
138 | 139 |
|
139 | 140 | #ifdef _AIX
|
140 |
| - FILE *infile; |
141 |
| - char buffer[512], *p; |
142 |
| - |
143 |
| - p = (char *)NULL; |
144 |
| - infile = popen("prtconf|grep 'Processor Type'", "r"); |
145 |
| - while (fgets(buffer, sizeof(buffer), infile)){ |
146 |
| - if (!strncmp("Pro", buffer, 3)){ |
147 |
| - p = strchr(buffer, ':') + 2; |
148 |
| -#if 0 |
149 |
| - fprintf(stderr, "%s\n", p); |
150 |
| -#endif |
151 |
| - break; |
152 |
| - } |
153 |
| - } |
154 |
| - |
155 |
| - pclose(infile); |
| 141 | + // Cast from int to unsigned to ensure comparisons work for all bits in |
| 142 | + // the bit mask, even the top bit |
| 143 | + unsigned implementation = (unsigned) _system_configuration.implementation; |
156 | 144 |
|
157 |
| - if (strstr(p, "POWER3")) return CPUTYPE_POWER3; |
158 |
| - if (strstr(p, "POWER4")) return CPUTYPE_POWER4; |
159 |
| - if (strstr(p, "PPC970")) return CPUTYPE_PPC970; |
160 |
| - if (strstr(p, "POWER5")) return CPUTYPE_POWER5; |
161 |
| - if (strstr(p, "POWER6")) return CPUTYPE_POWER6; |
162 |
| - if (strstr(p, "POWER7")) return CPUTYPE_POWER6; |
163 |
| - if (strstr(p, "POWER8")) return CPUTYPE_POWER8; |
164 |
| - if (strstr(p, "POWER9")) return CPUTYPE_POWER9; |
165 |
| - if (strstr(p, "POWER10")) return CPUTYPE_POWER10; |
166 |
| - if (strstr(p, "Cell")) return CPUTYPE_CELL; |
167 |
| - if (strstr(p, "7447")) return CPUTYPE_PPCG4; |
168 |
| - return CPUTYPE_POWER5; |
| 145 | + if (implementation >= 0x40000u) return CPUTYPE_POWER10; |
| 146 | + else if (implementation & 0x20000) return CPUTYPE_POWER9; |
| 147 | + else if (implementation & 0x10000) return CPUTYPE_POWER8; |
| 148 | + else if (implementation & 0x08000) return CPUTYPE_POWER7; // POWER 7 |
| 149 | + else if (implementation & 0x04000) return CPUTYPE_POWER6; |
| 150 | + else if (implementation & 0x02000) return CPUTYPE_POWER5; |
| 151 | + else if (implementation & 0x01000) return CPUTYPE_POWER4; // MPC7450 |
| 152 | + else if (implementation & 0x00800) return CPUTYPE_POWER4; |
| 153 | + else return CPUTYPE_POWER3; |
169 | 154 | #endif
|
170 | 155 |
|
171 | 156 | #ifdef __APPLE__
|
|
0 commit comments