Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make If MAKE_NATIVE, use sysctl to get MACHINE_ARCH ...



details:   https://anonhg.NetBSD.org/src/rev/fda1e6294132
branches:  trunk
changeset: 789988:fda1e6294132
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Sep 14 15:09:34 2013 +0000

description:
If MAKE_NATIVE, use sysctl to get MACHINE_ARCH from hw.machine_arch.

diffstat:

 usr.bin/make/main.c |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (66 lines):

diff -r e2e2aff4eaf0 -r fda1e6294132 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Sep 14 14:07:56 2013 +0000
+++ b/usr.bin/make/main.c       Sat Sep 14 15:09:34 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -118,6 +118,9 @@
 #include <sys/param.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
+#ifdef MAKE_NATIVE
+#include <sys/sysctl.h>
+#endif
 #include <sys/utsname.h>
 #include <sys/wait.h>
 
@@ -879,6 +882,20 @@
        }
 
        if (!machine_arch) {
+#ifdef MAKE_NATIVE
+           static char machine_arch_buf[sizeof(utsname.machine)];
+           const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
+           size_t len = sizeof(machine_arch_buf);
+                
+           if (sysctl(mib, __arraycount(mib), machine_arch_buf,
+                   &len, NULL, 0) < 0) {
+               (void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname,
+                   strerror(errno));
+               exit(2);
+           }
+
+           machine_arch = machine_arch_buf;
+#else
 #ifndef MACHINE_ARCH
 #ifdef MAKE_MACHINE_ARCH
             machine_arch = MAKE_MACHINE_ARCH;
@@ -888,6 +905,7 @@
 #else
            machine_arch = MACHINE_ARCH;
 #endif
+#endif
        }
 
        myPid = getpid();               /* remember this for vFork() */



Home | Main Index | Thread Index | Old Index