summaryrefslogtreecommitdiff
path: root/lang/tcl83/patches/patch-ac
blob: 762f5d227d720fb484c06f2c9561d08818973e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$NetBSD: patch-ac,v 1.1.1.1 2004/03/08 19:22:27 minskim Exp $

--- tclUnixInit.c.orig	Fri Aug 24 19:13:22 2001
+++ tclUnixInit.c
@@ -22,6 +22,11 @@
 #	include <dlfcn.h>
 #   endif
 #endif
+#if defined(__NetBSD__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/utsname.h>
+#endif
 
 /*
  * The Init script (common to Windows and Unix platforms) is
@@ -550,6 +555,11 @@
     int unameOK;
     char *user;
     Tcl_DString ds;
+#if defined(__NetBSD__)
+    char machine_arch[SYS_NMLN];
+    int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
+    size_t len = sizeof(machine_arch);
+#endif
 
     Tcl_SetVar(interp, "tclDefaultLibrary", defaultLibraryDir, TCL_GLOBAL_ONLY);
     Tcl_SetVar(interp, "tcl_pkgPath", pkgPath, TCL_GLOBAL_ONLY);
@@ -585,8 +595,16 @@
 	    Tcl_SetVar2(interp, "tcl_platform", "osVersion", name.release,
 		    TCL_GLOBAL_ONLY|TCL_APPEND_VALUE);
 	}
+#if defined(__NetBSD__)
+	if (sysctl(mib, sizeof(mib) / sizeof(int), machine_arch, &len, NULL, 0) < 0)
+	    unameOK = 0;
+	else
+	    Tcl_SetVar2(interp, "tcl_platform", "machine", machine_arch,
+		    TCL_GLOBAL_ONLY);
+#else
 	Tcl_SetVar2(interp, "tcl_platform", "machine", name.machine,
 		TCL_GLOBAL_ONLY);
+#endif
     }
 #endif
     if (!unameOK) {