bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Patch for coreutils 4.5.7 on Mac OS X


From: Paul Eggert
Subject: Re: Patch for coreutils 4.5.7 on Mac OS X
Date: 20 Feb 2003 09:55:18 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.3

The <sys/types.h> part of that change seems reasonable, but the other
change (enclosed below) looks like a maintenance nightmare.  We don't
want to have that kind of #ifdef in the code, since we'd then have to
add another #ifdef for every kind of processor on such operating systems.

How does MacOS solve this problem?  Does it have a different system
call that returns the processor name?

If not, perhaps a better workaround would be something like this:

 char const *default_processor = 0;
#ifdef PROCESSOR
 default_processor = PROCESSOR;
#endif

and then use "else element = default_processor;" in the mainline code.
You can then compile with -DPROCESSOR="\"`uname -p`\"'.  This sort of
thing could be Autoconf'ed, though it is a bit circular....

--- src-4.5.7/src/uname.c       2002-12-06 16:40:55.000000000 +0100
+++ src-4.5.7-local/src/uname.c 2003-02-20 16:17:16.000000000 +0100
@@ -29,7 +29,12 @@
 # include <sys/systeminfo.h>
 #endif
 
-#if HAVE_SYSCTL && HAVE_SYS_SYSCTL_H
+/*
+ * Mac OS X got <sys/param.h> but is missing <sysctl.h>, but behaves
+ * almost like FreeBSD, except that HW_MACHINE_ARCH returns error from
+ * sysctl.
+ */
+#if HAVE_SYS_PARAM_H && HAVE_SYS_SYSCTL_H
 # include <sys/param.h> /* needed for OpenBSD 3.0 */
 # include <sys/sysctl.h>
 # ifdef HW_MODEL
@@ -255,6 +260,11 @@
          static int mib[] = { CTL_HW, UNAME_PROCESSOR };
          if (sysctl (mib, 2, processor, &s, 0, 0) >= 0)
            element = processor;
+#ifdef __POWERPC__
+         /* Mac OS X is broken, so we hardcode this here */
+         else
+           element = "powerpc";
+#endif
        }
 #endif
       print_element (element);




reply via email to

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