$NetBSD: patch-ac,v 1.10 2006/11/02 17:41:23 adam Exp $ --- unix/tclUnixInit.c.orig 2006-09-10 19:04:42.000000000 +0200 +++ unix/tclUnixInit.c @@ -26,7 +26,7 @@ # endif # endif #endif -#if defined(__FreeBSD__) && defined(__GNUC__) +#if (defined(__FreeBSD__) || defined(__DragonFly__)) && defined(__GNUC__) # include #endif #if defined(__bsdi__) @@ -35,6 +35,11 @@ # include # endif #endif +#if defined(__NetBSD__) +#include +#include +#include +#endif /* * The Init script (common to Windows and Unix platforms) is @@ -221,7 +226,7 @@ TclpInitPlatform() (void) signal(SIGPIPE, SIG_IGN); #endif /* SIGPIPE */ -#if defined(__FreeBSD__) && defined(__GNUC__) +#if (defined(__FreeBSD__) || defined(__DragonFly__)) && defined(__GNUC__) /* * Adjust the rounding mode to be more conventional. Note that FreeBSD * only provides the __fpsetreg() used by the following two for the GNU @@ -779,6 +784,11 @@ TclpSetVariables(interp) int unameOK; CONST 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 #ifdef HAVE_COREFOUNDATION char tclLibPath[MAXPATHLEN + 1]; @@ -905,8 +915,16 @@ TclpSetVariables(interp) 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) {