From 0fbef6e65ce658be91fa93fa9effcfc19595c1f9 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 23 Dec 2020 20:59:32 +0700 Subject: [PATCH] Use uname() for getparm for ARCH/MACH queries. Previously, this was implemented in very inconsistent ways and not yet implemented for most of the platforms that we're supporting today. The values for DOS are maintained as they were. --- src/uutils.c | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/uutils.c b/src/uutils.c index 371ff0a0..49d5494c 100644 --- a/src/uutils.c +++ b/src/uutils.c @@ -27,6 +27,7 @@ #ifndef DOS #include +#include #endif #include "lispemul.h" @@ -209,45 +210,34 @@ LispPTR unix_username(LispPTR *args) { /* */ /************************************************************************/ /* - * The code for "MACH" and "ARCH" are really not correct and it's not - * clear what use they are. RS/6000 systems use a PowerPC processor, - * and so did PowerBook Macintosh systems. - * "MACH" and "ARCH" both seem to be a mix of instruction set architecture and - * system types (rs/6000 used PowerPC). - * The only usage seems to be checking "ARCH" == "dos" and for the existence - * of *any* result from the call, which indicates it's an emulated system. + * The only usage for "ARCH" seems to be checking "ARCH" == "dos" + * and for the existence of *any* result from the call, which + * indicates it's an emulated system. */ LispPTR unix_getparm(LispPTR *args) { char envname[20], result[128], *envvalue; +#ifndef DOS + struct utsname u; +#endif + if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL; +#ifdef DOS if (strcmp(envname, "MACH") == 0) { -#if defined(sparc) - envvalue = "sparc"; -#elif defined(I386) - envvalue = "i386"; -#elif defined(DOS) envvalue = "386"; -#elif defined(MACOSX) - envvalue = "i386"; -#else - envvalue = "mc68020"; -#endif - } else if (strcmp(envname, "ARCH") == 0) { -#if defined(sparc) - envvalue = "sun4"; -#elif defined(I386) - envvalue = "sun386"; -#elif defined(DOS) envvalue = "dos"; -#elif defined(MACOSX) - envvalue = "i386"; + } #else - envvalue = "sun3"; -#endif + if (uname(&u) == -1) return NIL; - } else if (strcmp(envname, "DISPLAY") == 0) { + if (strcmp(envname, "MACH") == 0) { + envvalue = u.machine; + } else if (strcmp(envname, "ARCH") == 0) { + envvalue = u.sysname; + } +#endif + else if (strcmp(envname, "DISPLAY") == 0) { #if defined(XWINDOW) envvalue = "X"; #elif defined(DISPLAYBUFFER)