bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bugs #10778] uname: "correct" Darwin/Mac OS X patch


From: Jim Meyering
Subject: Re: [bugs #10778] uname: "correct" Darwin/Mac OS X patch
Date: Sat, 23 Oct 2004 23:02:21 +0200

> This mail is an automated notification from the bugs tracker
>  of the project: GNU Core Utilities.
>
> URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=10778>
> Project: GNU Core Utilities
> Submitted by: 0
> On: Sat 10/23/2004 at 05:02
>
> Category:  None
> Severity:  5 - Average
> Item Group:  None
> Resolution:  None
> Privacy:  Public
> Assigned to:  None
> Status:  Open
>
>
> Summary:  uname: "correct" Darwin/Mac OS X patch
>
> Original Submission:  I realize that this is fixed in CVS,
> but I've attached a "correct" patch for uname -p on
> Darwin/Mac OS X. Diff is against coreutils 5.2.1.
>
> It attempts to use the correct sysctl to determine the CPU type.
> Unfortunately, I found it necessary to convert "ppc" to "powerpc".
...
> I don't have a Savannah account, sorry.
> Please feel free to email me at address@hidden

Thanks a lot!
I'm forwarding a copy of your patch to the bug-coreutils mailing list:

--- src/uname.c.orig    Wed Jan 21 17:27:02 2004
+++ src/uname.c Sat Oct 23 04:37:29 2004
@@ -44,6 +44,11 @@
 # endif
 #endif
 
+#if defined(__APPLE__)
+#include <mach/machine.h>
+#include <mach-o/arch.h>
+#endif
+
 #include "system.h"
 #include "error.h"
 
@@ -258,6 +263,21 @@
          static int mib[] = { CTL_HW, UNAME_PROCESSOR };
          if (sysctl (mib, 2, processor, &s, 0, 0) >= 0)
            element = processor;
+       }
+#endif
+#if defined(__APPLE__)
+       if (element == unknown)
+       {
+               cpu_type_t cputype;
+               size_t s = sizeof cputype;
+               NXArchInfo *ai;
+               if (sysctlbyname("hw.cputype", &cputype, &s, NULL, 0) == 0)
+                       if ((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))
+                       element = "powerpc";
        }
 #endif
       print_element (element);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]