|
27 | 27 |
|
28 | 28 | #ifndef DOS
|
29 | 29 | #include <pwd.h>
|
| 30 | +#include <sys/utsname.h> |
30 | 31 | #endif
|
31 | 32 |
|
32 | 33 | #include "lispemul.h"
|
@@ -209,45 +210,34 @@ LispPTR unix_username(LispPTR *args) {
|
209 | 210 | /* */
|
210 | 211 | /************************************************************************/
|
211 | 212 | /*
|
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. |
219 | 216 | */
|
220 | 217 | LispPTR unix_getparm(LispPTR *args) {
|
221 | 218 | char envname[20], result[128], *envvalue;
|
| 219 | +#ifndef DOS |
| 220 | + struct utsname u; |
| 221 | +#endif |
| 222 | + |
222 | 223 | if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL;
|
223 | 224 |
|
| 225 | +#ifdef DOS |
224 | 226 | if (strcmp(envname, "MACH") == 0) {
|
225 |
| -#if defined(sparc) |
226 |
| - envvalue = "sparc"; |
227 |
| -#elif defined(I386) |
228 |
| - envvalue = "i386"; |
229 |
| -#elif defined(DOS) |
230 | 227 | envvalue = "386";
|
231 |
| -#elif defined(MACOSX) |
232 |
| - envvalue = "i386"; |
233 |
| -#else |
234 |
| - envvalue = "mc68020"; |
235 |
| -#endif |
236 |
| - |
237 | 228 | } else if (strcmp(envname, "ARCH") == 0) {
|
238 |
| -#if defined(sparc) |
239 |
| - envvalue = "sun4"; |
240 |
| -#elif defined(I386) |
241 |
| - envvalue = "sun386"; |
242 |
| -#elif defined(DOS) |
243 | 229 | envvalue = "dos";
|
244 |
| -#elif defined(MACOSX) |
245 |
| - envvalue = "i386"; |
| 230 | + } |
246 | 231 | #else
|
247 |
| - envvalue = "sun3"; |
248 |
| -#endif |
| 232 | + if (uname(&u) == -1) return NIL; |
249 | 233 |
|
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) { |
251 | 241 | #if defined(XWINDOW)
|
252 | 242 | envvalue = "X";
|
253 | 243 | #elif defined(DISPLAYBUFFER)
|
|
0 commit comments