Skip to content

Commit 0fbef6e

Browse files
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.
1 parent 67d6a79 commit 0fbef6e

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

src/uutils.c

+18-28
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#ifndef DOS
2929
#include <pwd.h>
30+
#include <sys/utsname.h>
3031
#endif
3132

3233
#include "lispemul.h"
@@ -209,45 +210,34 @@ LispPTR unix_username(LispPTR *args) {
209210
/* */
210211
/************************************************************************/
211212
/*
212-
* The code for "MACH" and "ARCH" are really not correct and it's not
213-
* clear what use they are. RS/6000 systems use a PowerPC processor,
214-
* and so did PowerBook Macintosh systems.
215-
* "MACH" and "ARCH" both seem to be a mix of instruction set architecture and
216-
* system types (rs/6000 used PowerPC).
217-
* The only usage seems to be checking "ARCH" == "dos" and for the existence
218-
* of *any* result from the call, which indicates it's an emulated system.
213+
* The only usage for "ARCH" seems to be checking "ARCH" == "dos"
214+
* and for the existence of *any* result from the call, which
215+
* indicates it's an emulated system.
219216
*/
220217
LispPTR unix_getparm(LispPTR *args) {
221218
char envname[20], result[128], *envvalue;
219+
#ifndef DOS
220+
struct utsname u;
221+
#endif
222+
222223
if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL;
223224

225+
#ifdef DOS
224226
if (strcmp(envname, "MACH") == 0) {
225-
#if defined(sparc)
226-
envvalue = "sparc";
227-
#elif defined(I386)
228-
envvalue = "i386";
229-
#elif defined(DOS)
230227
envvalue = "386";
231-
#elif defined(MACOSX)
232-
envvalue = "i386";
233-
#else
234-
envvalue = "mc68020";
235-
#endif
236-
237228
} else if (strcmp(envname, "ARCH") == 0) {
238-
#if defined(sparc)
239-
envvalue = "sun4";
240-
#elif defined(I386)
241-
envvalue = "sun386";
242-
#elif defined(DOS)
243229
envvalue = "dos";
244-
#elif defined(MACOSX)
245-
envvalue = "i386";
230+
}
246231
#else
247-
envvalue = "sun3";
248-
#endif
232+
if (uname(&u) == -1) return NIL;
249233

250-
} else if (strcmp(envname, "DISPLAY") == 0) {
234+
if (strcmp(envname, "MACH") == 0) {
235+
envvalue = u.machine;
236+
} else if (strcmp(envname, "ARCH") == 0) {
237+
envvalue = u.sysname;
238+
}
239+
#endif
240+
else if (strcmp(envname, "DISPLAY") == 0) {
251241
#if defined(XWINDOW)
252242
envvalue = "X";
253243
#elif defined(DISPLAYBUFFER)

0 commit comments

Comments
 (0)