Skip to content

Commit 807f6e6

Browse files
authored
Use prtconf to determine CPU type on AIX
for #1803
1 parent 76a66ea commit 807f6e6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cpuid_power.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,33 @@ int detect(void){
127127
#endif
128128

129129
#ifdef _AIX
130+
FILE *infile;
131+
char buffer[512], *p;
132+
133+
p = (char *)NULL;
134+
infile = popen("prtconf|grep 'Processor Type'");
135+
while (fgets(buffer, sizeof(buffer), infile)){
136+
if (!strncmp("Pro", buffer, 3)){
137+
p = strchr(buffer, ':') + 2;
138+
#if 0
139+
fprintf(stderr, "%s\n", p);
140+
#endif
141+
break;
142+
}
143+
}
144+
145+
pclose(infile);
146+
147+
if (!strncasecmp(p, "POWER3", 6)) return CPUTYPE_POWER3;
148+
if (!strncasecmp(p, "POWER4", 6)) return CPUTYPE_POWER4;
149+
if (!strncasecmp(p, "PPC970", 6)) return CPUTYPE_PPC970;
150+
if (!strncasecmp(p, "POWER5", 6)) return CPUTYPE_POWER5;
151+
if (!strncasecmp(p, "POWER6", 6)) return CPUTYPE_POWER6;
152+
if (!strncasecmp(p, "POWER7", 6)) return CPUTYPE_POWER6;
153+
if (!strncasecmp(p, "POWER8", 6)) return CPUTYPE_POWER8;
154+
if (!strncasecmp(p, "Cell", 4)) return CPUTYPE_CELL;
155+
if (!strncasecmp(p, "7447", 4)) return CPUTYPE_PPCG4;
156+
130157
return CPUTYPE_POWER5;
131158
#endif
132159

0 commit comments

Comments
 (0)