From: Jim Meyering Date: Tue, 9 Nov 2004 20:31:39 +0000 (+0000) Subject: [__APPLE__]: Include and . X-Git-Tag: v5.3.0~446 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=594d5064c950fa1d99a9eafbd357c5f46320d002;p=thirdparty%2Fcoreutils.git [__APPLE__]: Include and . (main) [__APPLE__]: Get the processor type via syscall rather than hard-coding "powerpc". From toby@opendarwin.org. --- diff --git a/src/uname.c b/src/uname.c index 8380a63050..ffdc44a3e8 100644 --- a/src/uname.c +++ b/src/uname.c @@ -46,6 +46,11 @@ # endif #endif +#ifdef __APPLE__ +#include +#include +#endif + #include "system.h" #include "error.h" #include "quote.h" @@ -259,10 +264,25 @@ main (int argc, char **argv) static int mib[] = { CTL_HW, UNAME_PROCESSOR }; if (sysctl (mib, 2, processor, &s, 0, 0) >= 0) element = processor; -# ifdef __POWERPC__ + +# ifdef __APPLE__ /* This kludge works around a bug in Mac OS X. */ if (element == unknown) - element = "powerpc"; + { + cpu_type_t cputype; + size_t s = sizeof cputype; + NXArchInfo const *ai; + if (sysctlbyname ("hw.cputype", &cputype, &s, NULL, 0) == 0 + && (ai = NXGetArchInfoFromCpuType (cputype, + CPU_SUBTYPE_MULTIPLE)) + != NULL) + element = ai->name; + + /* Hack "safely" around the ppc vs. powerpc return value. */ + if (cputype == CPU_TYPE_POWERPC + && strncmp (element, "ppc", 3) == 0) + element = "powerpc"; + } # endif } #endif