Skip to content

Commit a2ca722

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 16019c2 commit a2ca722

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
@@ -26,6 +26,7 @@
2626

2727
#ifndef DOS
2828
#include <pwd.h>
29+
#include <sys/utsname.h>
2930
#endif
3031

3132
#include "lispemul.h"
@@ -212,47 +213,36 @@ LispPTR unix_username(LispPTR *args) {
212213
/* */
213214
/************************************************************************/
214215
/*
215-
* The code for "MACH" and "ARCH" are really not correct and it's not
216-
* clear what use they are. RS/6000 systems use a PowerPC processor,
217-
* and so did PowerBook Macintosh systems.
218-
* "MACH" and "ARCH" both seem to be a mix of instruction set architecture and
219-
* system types (rs/6000 used PowerPC).
220-
* The only usage seems to be checking "ARCH" == "dos" and for the existance
221-
* of *any* result from the call, which indicates it's an emulated system.
216+
* The only usage for "ARCH" seems to be checking "ARCH" == "dos"
217+
* and for the existence of *any* result from the call, which
218+
* indicates it's an emulated system.
222219
*/
223220
char *getenv(const char *);
224221

225222
LispPTR unix_getparm(LispPTR *args) {
226223
char envname[20], result[128], *envvalue;
224+
#ifndef DOS
225+
struct utsname u;
226+
#endif
227+
227228
if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL;
228229

230+
#ifdef DOS
229231
if (strcmp(envname, "MACH") == 0) {
230-
#if defined(sparc)
231-
envvalue = "sparc";
232-
#elif defined(I386)
233-
envvalue = "i386";
234-
#elif defined(DOS)
235232
envvalue = "386";
236-
#elif defined(MACOSX)
237-
envvalue = "i386";
238-
#else
239-
envvalue = "mc68020";
240-
#endif
241-
242233
} else if (strcmp(envname, "ARCH") == 0) {
243-
#if defined(sparc)
244-
envvalue = "sun4";
245-
#elif defined(I386)
246-
envvalue = "sun386";
247-
#elif defined(DOS)
248234
envvalue = "dos";
249-
#elif defined(MACOSX)
250-
envvalue = "i386";
235+
}
251236
#else
252-
envvalue = "sun3";
253-
#endif
237+
if (uname(&u) == -1) return NIL;
254238

255-
} else if (strcmp(envname, "DISPLAY") == 0) {
239+
if (strcmp(envname, "MACH") == 0) {
240+
envvalue = u.machine;
241+
} else if (strcmp(envname, "ARCH") == 0) {
242+
envvalue = u.sysname;
243+
}
244+
#endif
245+
else if (strcmp(envname, "DISPLAY") == 0) {
256246
#if defined(XWINDOW)
257247
envvalue = "X";
258248
#elif defined(DISPLAYBUFFER)

0 commit comments

Comments
 (0)