miscellaneous fixes for I/O and PowerPC FFI

cvs
Slava Pestov 2005-04-24 04:27:07 +00:00
parent 1efa0fa2cc
commit 09123b279a
13 changed files with 69 additions and 82 deletions

View File

@ -53,6 +53,9 @@
+ sequences
- nappend: instead of using push, enlarge the sequence with set-length
then add set the elements with set-nth
- ensure-capacity: don't be generic
- vector's ensure-capacity will crash if not given fixnums!
- dipping seq-2nmap, seq-2each
- remove seq- prefixes
@ -98,7 +101,7 @@
- stream server can hang because of exception handler limitations
- better i/o scheduler
- add a socket timeout
- unix ffi i/o
- get sockets working
- renumber types appopriately
- linux? freebsd? words, linux i/o stuff
- clean up errors

View File

@ -69,7 +69,7 @@ SYMBOL: d
0.8 c set
-2.1 d set
1024 768 0 SDL_HWSURFACE [
800 600 0 SDL_HWSURFACE [
[ 0 0 200000 [ draw-dejong ] time ] with-surface
<event> event-loop

View File

@ -133,7 +133,7 @@ DEFER: alien-global
parameters
dup stack-space
dup #parameters swons , >r
dup 0 swap [ dupd unbox-parameter 1 + ] each drop
dup dup length swap [ >r 1 - dup r> unbox-parameter ] each drop
length [ #parameter swons ] project % r> ;
: linearize-returns ( returns -- )

View File

@ -55,12 +55,14 @@ cpu "x86" = [
"/library/compiler/x86/stack.factor"
"/library/compiler/x86/generator.factor"
"/library/compiler/x86/fixnum.factor"
"/library/compiler/x86/alien.factor"
] pull-in
cpu "ppc" = [
"/library/compiler/ppc/assembler.factor"
"/library/compiler/ppc/stack.factor"
"/library/compiler/ppc/generator.factor"
"/library/compiler/ppc/alien.factor"
] pull-in
"/library/bootstrap/boot-stage3.factor" run-resource

View File

@ -6,7 +6,10 @@ lists namespaces parser sequences stdio unparser words ;
"Bootstrap stage 3..." print
os "unix" = [
"libc" "libc.so" "cdecl" add-library
"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" = [
@ -19,41 +22,22 @@ os "win32" = [
"sdl" "SDL.dll" "cdecl" add-library
"sdl-gfx" "SDL_gfx.dll" "cdecl" add-library
"sdl-ttf" "SDL_ttf.dll" "cdecl" add-library
! FIXME: KLUDGE to get FFI-based IO going in Windows.
"/library/bootstrap/win32-io.factor" run-resource
] when
default-cli-args
parse-command-line
init-assembler
"/library/io/buffer.factor" run-resource
"compile" get supported-cpu? and [
init-assembler
: compile? "compile" get supported-cpu? and ;
compile? [
\ car compile
\ = compile
\ length compile
\ unparse compile
\ scan compile
[
"imalloc" "ifree" "irealloc" "imemcpy"
] [
[ "io-internals" ] search compile
] each
os "unix" = [
"/library/unix/syscalls.factor"
"/library/unix/io.factor"
"/library/unix/sockets.factor"
"/library/unix/files.factor"
] pull-in
os "unix" = [
"unix-internals" words [ compile ] each
] when
init-io
] when
t [
@ -81,9 +65,7 @@ t [
"/library/tools/annotations.factor"
"/library/tools/dump.factor"
"/library/bootstrap/image.factor"
] pull-in
"compile" get supported-cpu? and "mini" get not and [
"/library/io/logging.factor"
"/library/tools/telnetd.factor"
@ -148,15 +130,33 @@ t [
"/library/ui/tool-menus.factor"
] pull-in
os "win32" = [
"/library/win32/win32-io.factor"
"/library/win32/win32-errors.factor"
"/library/win32/winsock.factor"
"/library/win32/win32-io-internals.factor"
"/library/win32/win32-stream.factor"
"/library/win32/win32-server.factor"
] pull-in
compile? [
os "win32" = [
"/library/win32/win32-io.factor"
"/library/win32/win32-errors.factor"
"/library/win32/winsock.factor"
"/library/win32/win32-io-internals.factor"
"/library/win32/win32-stream.factor"
"/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? [
"Compiling system..." print
compile-all
"Initializing native I/O..." print
init-io
] when
FORGET: pull-in
FORGET: compile?
"/library/bootstrap/boot-stage4.factor" dup print run-resource

View File

@ -33,9 +33,6 @@ words ;
warm-boot
"Compiling system..." print
"compile" get [ compile-all ] when
terpri
"Unless you're working on the compiler, ignore the errors above." print
"Not every word compiles, by design." print

View File

@ -25,24 +25,6 @@
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IN: threads
USE: compiler
USE: io-internals
USE: kernel
USE: win32-io-internals
USE: win32-api
: stop ( -- )
next-thread [
call
] [
next-io-task [
call
] [
win32-next-io-task
] ifte*
] ifte* ;
IN: streams
USE: compiler
USE: namespaces
@ -56,6 +38,11 @@ USE: win32-api
: <file-writer> <win32-file-writer> ;
: <server> <win32-server> ;
: init-stdio ( -- )
IN: io-internals
: io-multiplex ( -- task )
win32-next-io-task ;
: init-io ( -- )
win32-init-stdio ;

View File

@ -48,13 +48,7 @@ M: compound (compile) ( word -- )
: try-compile ( word -- )
[ compile ] [ [ cannot-compile ] when* ] catch ;
: compile-all ( -- )
#! Compile all words.
supported-cpu? [
[ try-compile ] each-word
] [
"Unsupported CPU" print
] ifte ;
: compile-all ( -- ) [ try-compile ] each-word ;
: decompile ( word -- )
dup compiled? [

View File

@ -1,5 +1,13 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: assembler
DEFER: compile-call-label ( label -- )
DEFER: compile-jump-label ( label -- )
DEFER: compile-jump-t ( label -- )
DEFER: compile-jump-f ( label -- )
IN: compiler
USING: assembler errors inference kernel lists math namespaces
sequences strings vectors words ;
@ -56,9 +64,6 @@ SYMBOL: previous-offset
#! Given a type number, return the tag number.
dup 6 > [ drop 3 ] when ;
DEFER: compile-call-label ( label -- )
DEFER: compile-jump-label ( label -- )
: compile-call ( word -- ) dup postpone-word compile-call-label ;
#call [
@ -69,9 +74,6 @@ DEFER: compile-jump-label ( label -- )
compile-jump-label
] "generator" set-word-prop
DEFER: compile-jump-t ( label -- )
DEFER: compile-jump-f ( label -- )
#jump-t-label [ compile-jump-t ] "generator" set-word-prop
#jump-t [ compile-jump-t ] "generator" set-word-prop

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: compiler
USING: alien assembler inference kernel kernel-internals lists
IN: assembler
USING: alien compiler inference kernel kernel-internals lists
math memory namespaces words ;
\ alien-invoke [
@ -12,13 +12,15 @@ math memory namespaces words ;
dup 0 = [ drop ] [ 1 1 rot SUBI ] ifte
] "generator" set-word-prop
: stack@ cell * neg cell - ;
#unbox [
uncons f dlsym compile-call-far
3 1 rot neg 4 - STW
3 1 rot stack@ STW
] "generator" set-word-prop
#parameter [
dup 3 + 1 rot cell * neg 4 - LWZ
dup 3 + 1 rot stack@ LWZ
] "generator" set-word-prop
#box [

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: compiler
USING: assembler inference kernel kernel-internals lists math
IN: assembler
USING: compiler inference kernel kernel-internals lists math
words ;
! At the start of each word that calls a subroutine, we store

View File

@ -17,7 +17,7 @@ math memory namespaces words ;
] "generator" set-word-prop
#unbox [
dup f dlsym CALL f t rel-dlsym
cdr dup f dlsym CALL f t rel-dlsym
EAX PUSH
] "generator" set-word-prop

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: compiler
USING: alien assembler inference kernel kernel-internals lists
IN: assembler
USING: alien compiler inference kernel kernel-internals lists
math memory namespaces words ;
! Not used on x86