Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uname() for getparm for ARCH/MACH queries. #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 18 additions & 28 deletions src/uutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#ifndef DOS
#include <pwd.h>
#include <sys/utsname.h>
#endif

#include "lispemul.h"
Expand Down Expand Up @@ -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)
Expand Down