Get OS name from uname()
This implies that OS names have changed. Unix-like OS names are now capitalized. "macos" is now "Darwin". Windows is now all-lowecase "windows". "win32" is gone. "win64" was not used in the original code despite a reference to it.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static const struct utsname *get_global_uname(void)
|
||||
{
|
||||
static struct utsname buf;
|
||||
|
||||
if (!buf.sysname[0]) {
|
||||
if (uname(&buf) == -1) {
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
}
|
||||
}
|
||||
return &buf;
|
||||
}
|
||||
|
||||
const char *env_get_os_name(void) { return get_global_uname()->sysname; }
|
||||
@@ -0,0 +1 @@
|
||||
const char *env_get_os_name(void) { return "windows"; }
|
||||
@@ -63,8 +63,9 @@
|
||||
|
||||
#include "flisp.h"
|
||||
|
||||
#include "opcodes.h"
|
||||
#include "argcount.h"
|
||||
#include "env.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
static char *builtin_names[] = {
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
@@ -2622,19 +2623,7 @@ static void lisp_init(size_t initial_heapsize)
|
||||
setc(symbol("procedure?"), builtin(OP_FUNCTIONP));
|
||||
setc(symbol("top-level-bound?"), builtin(OP_BOUNDP));
|
||||
|
||||
#ifdef LINUX
|
||||
set(symbol("*os-name*"), symbol("linux"));
|
||||
#elif defined(_WIN32)
|
||||
set(symbol("*os-name*"), symbol("win32"));
|
||||
#elif defined(MACOSX)
|
||||
set(symbol("*os-name*"), symbol("macos"));
|
||||
#elif defined(OPENBSD)
|
||||
set(symbol("*os-name*"), symbol("openbsd"));
|
||||
#elif defined(FREEBSD)
|
||||
set(symbol("*os-name*"), symbol("freebsd"));
|
||||
#else
|
||||
set(symbol("*os-name*"), symbol("unknown"));
|
||||
#endif
|
||||
set(symbol("*os-name*"), symbol(env_get_os_name()));
|
||||
|
||||
the_empty_vector = tagptr(alloc_words(1), TAG_VECTOR);
|
||||
vector_setsize(the_empty_vector, 0);
|
||||
|
||||
Reference in New Issue
Block a user