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:
parent
be6a18175f
commit
2ec07684d2
|
@ -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"; }
|
17
c/flisp.c
17
c/flisp.c
|
@ -63,8 +63,9 @@
|
||||||
|
|
||||||
#include "flisp.h"
|
#include "flisp.h"
|
||||||
|
|
||||||
#include "opcodes.h"
|
|
||||||
#include "argcount.h"
|
#include "argcount.h"
|
||||||
|
#include "env.h"
|
||||||
|
#include "opcodes.h"
|
||||||
|
|
||||||
static char *builtin_names[] = {
|
static char *builtin_names[] = {
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
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("procedure?"), builtin(OP_FUNCTIONP));
|
||||||
setc(symbol("top-level-bound?"), builtin(OP_BOUNDP));
|
setc(symbol("top-level-bound?"), builtin(OP_BOUNDP));
|
||||||
|
|
||||||
#ifdef LINUX
|
set(symbol("*os-name*"), symbol(env_get_os_name()));
|
||||||
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
|
|
||||||
|
|
||||||
the_empty_vector = tagptr(alloc_words(1), TAG_VECTOR);
|
the_empty_vector = tagptr(alloc_words(1), TAG_VECTOR);
|
||||||
vector_setsize(the_empty_vector, 0);
|
vector_setsize(the_empty_vector, 0);
|
||||||
|
|
|
@ -1056,9 +1056,7 @@
|
||||||
|
|
||||||
; initialize globals that need to be set at load time
|
; initialize globals that need to be set at load time
|
||||||
(define (__init_globals)
|
(define (__init_globals)
|
||||||
(if (or (eq? *os-name* 'win32)
|
(if (eq? *os-name* 'windows)
|
||||||
(eq? *os-name* 'win64)
|
|
||||||
(eq? *os-name* 'windows))
|
|
||||||
(begin (set! *directory-separator* "\\")
|
(begin (set! *directory-separator* "\\")
|
||||||
(set! *linefeed* "\r\n"))
|
(set! *linefeed* "\r\n"))
|
||||||
(begin (set! *directory-separator* "/")
|
(begin (set! *directory-separator* "/")
|
||||||
|
|
|
@ -21,6 +21,7 @@ $CC $CFLAGS -c ../c/bitvector-ops.c
|
||||||
$CC $CFLAGS -c ../c/bitvector.c
|
$CC $CFLAGS -c ../c/bitvector.c
|
||||||
$CC $CFLAGS -c ../c/builtins.c
|
$CC $CFLAGS -c ../c/builtins.c
|
||||||
$CC $CFLAGS -c ../c/dump.c
|
$CC $CFLAGS -c ../c/dump.c
|
||||||
|
$CC $CFLAGS -c ../c/env_unix.c
|
||||||
$CC $CFLAGS -c ../c/equalhash.c
|
$CC $CFLAGS -c ../c/equalhash.c
|
||||||
$CC $CFLAGS -c ../c/flisp.c
|
$CC $CFLAGS -c ../c/flisp.c
|
||||||
$CC $CFLAGS -c ../c/flmain.c
|
$CC $CFLAGS -c ../c/flmain.c
|
||||||
|
@ -40,7 +41,7 @@ $CC $CFLAGS -c ../c/table.c
|
||||||
$CC $CFLAGS -c ../c/time_unix.c
|
$CC $CFLAGS -c ../c/time_unix.c
|
||||||
$CC $CFLAGS -c ../c/utf8.c
|
$CC $CFLAGS -c ../c/utf8.c
|
||||||
$CC $LFLAGS -o flisp -lm \
|
$CC $LFLAGS -o flisp -lm \
|
||||||
bitvector-ops.o bitvector.o builtins.o dump.o \
|
bitvector-ops.o bitvector.o builtins.o dump.o env_unix.o \
|
||||||
equalhash.o flisp.o flmain.o fs_"$os".o fs_unix.o \
|
equalhash.o flisp.o flmain.o fs_"$os".o fs_unix.o \
|
||||||
hashing.o htable.o int2str.o \
|
hashing.o htable.o int2str.o \
|
||||||
ios.o iostream.o lltinit.o ptrhash.o random.o socket.o \
|
ios.o iostream.o lltinit.o ptrhash.o random.o socket.o \
|
||||||
|
|
Loading…
Reference in New Issue