vapier 15/08/05 07:14:35 Modified: uname-test.c Log: add support for common arch aliases so we can scan files from the cpuinfo package (and remove redundant prefixes from the look up list)
Revision Changes Path 1.9 src/patchsets/coreutils/uname-test/uname-test.c file : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?rev=1.9&view=markup plain: http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?rev=1.9&content-type=text/plain diff : http://sources.gentoo.org/viewvc.cgi/gentoo/src/patchsets/coreutils/uname-test/uname-test.c?r1=1.8&r2=1.9 Index: uname-test.c =================================================================== RCS file: /var/cvsroot/gentoo/src/patchsets/coreutils/uname-test/uname-test.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- uname-test.c 5 Aug 2015 07:11:22 -0000 1.8 +++ uname-test.c 5 Aug 2015 07:14:35 -0000 1.9 @@ -112,6 +112,26 @@ return strncmp(s, prefix, strlen(prefix)) == 0 ? true : false; } +static const char *procinfo_guess_arch(const char *file) +{ + if (startswith(file, "blackfin")) + return "bfin"; + + if (startswith(file, "x86")) + return "i386"; + + if (startswith(file, "parisc")) + return "hppa"; + + if (startswith(file, "ppc64")) + return "powerpc64"; + + if (startswith(file, "ppc")) + return "powerpc"; + + return file; +} + static bool procinfo_init(void) { static const struct { @@ -133,17 +153,16 @@ { "m68k", "CPU", "MMU" }, { "mips", "cpu model", "system type" }, { "powerpc", "cpu", "machine" }, - { "powerpc64", "cpu", "machine" }, { "s390", "Type", "Manufacturer" }, - { "s390x", "Type", "Manufacturer" }, { "sh", "cpu type", "machine" }, { "sparc", "type", "cpu" }, { "vax", "cpu type", "cpu" }, }; size_t i; + const char *arch = procinfo_guess_arch(filename); for (i = 0; i < ARRAY_SIZE(procinfo_keys_all); ++i) - if (startswith(filename, procinfo_keys_all[i].arch)) { + if (startswith(arch, procinfo_keys_all[i].arch)) { procinfo_processor = procinfo_keys_all[i].processor; procinfo_platform = procinfo_keys_all[i].platform; return true;
