freebsd? linux? unix? words

cvs
Slava Pestov 2005-04-27 05:47:57 +00:00
parent 4e8da1f829
commit d9150c3613
4 changed files with 23 additions and 19 deletions

View File

@ -96,6 +96,8 @@
+ i/o: + 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 - reader syntax for arrays, byte arrays, displaced aliens
- separate words for writing characters and strings - separate words for writing characters and strings
- perhaps: - perhaps:

View File

@ -5,14 +5,14 @@ lists namespaces parser sequences stdio unparser words ;
"Bootstrap stage 3..." print "Bootstrap stage 3..." print
os "unix" = [ unix? [
"libc" "libc.so" "cdecl" add-library "libc" "libc.so" "cdecl" add-library
"sdl" "libSDL.so" "cdecl" add-library "sdl" "libSDL.so" "cdecl" add-library
"sdl-gfx" "libSDL_gfx.so" "cdecl" add-library "sdl-gfx" "libSDL_gfx.so" "cdecl" add-library
"sdl-ttf" "libSDL_ttf.so" "cdecl" add-library "sdl-ttf" "libSDL_ttf.so" "cdecl" add-library
] when ] when
os "win32" = [ win32? [
"kernel32" "kernel32.dll" "stdcall" add-library "kernel32" "kernel32.dll" "stdcall" add-library
"user32" "user32.dll" "stdcall" add-library "user32" "user32.dll" "stdcall" add-library
"gdi32" "gdi32.dll" "stdcall" add-library "gdi32" "gdi32.dll" "stdcall" add-library
@ -131,7 +131,14 @@ t [
] pull-in ] pull-in
compile? [ 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-io.factor"
"/library/win32/win32-errors.factor" "/library/win32/win32-errors.factor"
"/library/win32/winsock.factor" "/library/win32/winsock.factor"
@ -140,13 +147,6 @@ compile? [
"/library/win32/win32-server.factor" "/library/win32/win32-server.factor"
"/library/bootstrap/win32-io.factor" "/library/bootstrap/win32-io.factor"
] pull-in ] pull-in
os "unix" = [
"/library/unix/syscalls.factor"
"/library/unix/io.factor"
"/library/unix/sockets.factor"
"/library/unix/files.factor"
] pull-in
] when ] when
compile? [ compile? [

View File

@ -14,15 +14,6 @@ M: object = eq? ;
GENERIC: clone ( obj -- obj ) GENERIC: clone ( obj -- obj )
M: object clone ; 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-boot ( quot -- )
#! Set the boot quotation. #! Set the boot quotation.
8 setenv ; 8 setenv ;
@ -42,3 +33,10 @@ M: object clone ;
: or ( a b -- a|b ) t swap ? ; inline : or ( a b -- a|b ) t swap ? ; inline
: xor ( a b -- a^b ) dup not swap ? ; inline : xor ( a b -- a^b ) dup not swap ? ; inline
: implies ( a b -- a->b ) t ? ; 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 ;

View File

@ -22,6 +22,10 @@ void init_factor(char* image, CELL ds_size, CELL cs_size,
#ifdef WIN32 #ifdef WIN32
userenv[OS_ENV] = tag_object(from_c_string("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 #else
userenv[OS_ENV] = tag_object(from_c_string("unix")); userenv[OS_ENV] = tag_object(from_c_string("unix"));
#endif #endif