diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 69cb61a14e..cfe3256dc9 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -96,6 +96,8 @@ + i/o: +- merge unix and win32 io where appropriate +- unix io: handle \n\r and \n\0 - reader syntax for arrays, byte arrays, displaced aliens - separate words for writing characters and strings - perhaps: diff --git a/library/bootstrap/boot-stage3.factor b/library/bootstrap/boot-stage3.factor index fc4a6e090d..75d6189307 100644 --- a/library/bootstrap/boot-stage3.factor +++ b/library/bootstrap/boot-stage3.factor @@ -5,14 +5,14 @@ lists namespaces parser sequences stdio unparser words ; "Bootstrap stage 3..." print -os "unix" = [ +unix? [ "libc" "libc.so" "cdecl" add-library "sdl" "libSDL.so" "cdecl" add-library "sdl-gfx" "libSDL_gfx.so" "cdecl" add-library "sdl-ttf" "libSDL_ttf.so" "cdecl" add-library ] when -os "win32" = [ +win32? [ "kernel32" "kernel32.dll" "stdcall" add-library "user32" "user32.dll" "stdcall" add-library "gdi32" "gdi32.dll" "stdcall" add-library @@ -131,7 +131,14 @@ t [ ] pull-in compile? [ - os "win32" = [ + unix? [ + "/library/unix/syscalls.factor" + "/library/unix/io.factor" + "/library/unix/sockets.factor" + "/library/unix/files.factor" + ] pull-in + + win32? [ "/library/win32/win32-io.factor" "/library/win32/win32-errors.factor" "/library/win32/winsock.factor" @@ -140,13 +147,6 @@ compile? [ "/library/win32/win32-server.factor" "/library/bootstrap/win32-io.factor" ] pull-in - - os "unix" = [ - "/library/unix/syscalls.factor" - "/library/unix/io.factor" - "/library/unix/sockets.factor" - "/library/unix/files.factor" - ] pull-in ] when compile? [ diff --git a/library/kernel.factor b/library/kernel.factor index 28841868f9..93d24f86a4 100644 --- a/library/kernel.factor +++ b/library/kernel.factor @@ -14,15 +14,6 @@ M: object = eq? ; GENERIC: clone ( obj -- obj ) M: object clone ; - -: cpu ( -- arch ) - #! Returns one of "x86", "ppc", or "unknown". - 7 getenv ; - -: os ( -- arch ) - #! Returns one of "unix" or "win32". - 11 getenv ; - : set-boot ( quot -- ) #! Set the boot quotation. 8 setenv ; @@ -42,3 +33,10 @@ M: object clone ; : or ( a b -- a|b ) t swap ? ; inline : xor ( a b -- a^b ) dup not swap ? ; inline : implies ( a b -- a->b ) t ? ; inline + +: cpu ( -- arch ) 7 getenv ; +: os ( -- os ) 11 getenv ; +: win32? ( -- ? ) os "win32" = ; +: freebsd? ( -- ? ) os "freebsd" = ; +: linux? ( -- ? ) os "linux" = ; +: unix? ( -- ? ) freebsd? linux? or ; diff --git a/native/factor.c b/native/factor.c index 163a76ca20..c14cebbda8 100644 --- a/native/factor.c +++ b/native/factor.c @@ -22,6 +22,10 @@ void init_factor(char* image, CELL ds_size, CELL cs_size, #ifdef WIN32 userenv[OS_ENV] = tag_object(from_c_string("win32")); +#elif defined(__FreeBSD__) + userenv[OS_ENV] = tag_object(from_c_string("freebsd")); +#elif defined(linux) + userenv[OS_ENV] = tag_object(from_c_string("linux")); #else userenv[OS_ENV] = tag_object(from_c_string("unix")); #endif