Merge branch 'master' of git://factorcode.org/git/factor
commit
b71d7bc422
|
@ -6,7 +6,7 @@ strings io.styles vectors words system splitting math.parser
|
||||||
tuples continuations continuations.private combinators
|
tuples continuations continuations.private combinators
|
||||||
generic.math io.streams.duplex classes compiler.units
|
generic.math io.streams.duplex classes compiler.units
|
||||||
generic.standard vocabs threads threads.private init
|
generic.standard vocabs threads threads.private init
|
||||||
kernel.private ;
|
kernel.private libc ;
|
||||||
IN: debugger
|
IN: debugger
|
||||||
|
|
||||||
GENERIC: error. ( error -- )
|
GENERIC: error. ( error -- )
|
||||||
|
@ -63,20 +63,9 @@ M: string error. print ;
|
||||||
[ global [ "Error in print-error!" print drop ] bind ]
|
[ global [ "Error in print-error!" print drop ] bind ]
|
||||||
recover ;
|
recover ;
|
||||||
|
|
||||||
: error-in-thread. ( -- )
|
|
||||||
error-thread get-global
|
|
||||||
"Error in thread " write
|
|
||||||
[
|
|
||||||
dup thread-id #
|
|
||||||
" (" % dup thread-name %
|
|
||||||
", " % dup thread-quot unparse-short % ")" %
|
|
||||||
] "" make
|
|
||||||
swap write-object ":" print nl ;
|
|
||||||
|
|
||||||
SYMBOL: error-hook
|
SYMBOL: error-hook
|
||||||
|
|
||||||
[
|
[
|
||||||
error-in-thread.
|
|
||||||
print-error
|
print-error
|
||||||
restarts.
|
restarts.
|
||||||
nl
|
nl
|
||||||
|
@ -265,6 +254,24 @@ M: no-compilation-unit error.
|
||||||
M: no-vocab summary
|
M: no-vocab summary
|
||||||
drop "Vocabulary does not exist" ;
|
drop "Vocabulary does not exist" ;
|
||||||
|
|
||||||
|
M: check-ptr summary
|
||||||
|
drop "Memory allocation failed" ;
|
||||||
|
|
||||||
|
M: double-free summary
|
||||||
|
drop "Free failed since memory is not allocated" ;
|
||||||
|
|
||||||
|
M: realloc-error summary
|
||||||
|
drop "Memory reallocation failed" ;
|
||||||
|
|
||||||
|
: error-in-thread. ( -- )
|
||||||
|
error-thread get-global
|
||||||
|
"Error in thread " write
|
||||||
|
[
|
||||||
|
dup thread-id #
|
||||||
|
" (" % dup thread-name %
|
||||||
|
", " % dup thread-quot unparse-short % ")" %
|
||||||
|
] "" make swap write-object ":" print nl ;
|
||||||
|
|
||||||
! Hooks
|
! Hooks
|
||||||
M: thread error-in-thread ( error thread -- )
|
M: thread error-in-thread ( error thread -- )
|
||||||
initial-thread get-global eq? [
|
initial-thread get-global eq? [
|
||||||
|
|
|
@ -142,7 +142,6 @@ DEFER: copy-tree-to
|
||||||
|
|
||||||
: copy-tree ( from to -- )
|
: copy-tree ( from to -- )
|
||||||
over directory? [
|
over directory? [
|
||||||
dup make-directories
|
|
||||||
>r dup directory swap r> [
|
>r dup directory swap r> [
|
||||||
>r swap first path+ r> copy-tree-to
|
>r swap first path+ r> copy-tree-to
|
||||||
] 2curry each
|
] 2curry each
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! Copyright (C) 2007 Slava Pestov
|
! Copyright (C) 2007 Slava Pestov
|
||||||
! Copyright (C) 2007 Doug Coleman
|
! Copyright (C) 2007 Doug Coleman
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien assocs continuations init inspector kernel namespaces ;
|
USING: alien assocs continuations init kernel namespaces ;
|
||||||
IN: libc
|
IN: libc
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -25,22 +25,16 @@ PRIVATE>
|
||||||
|
|
||||||
TUPLE: check-ptr ;
|
TUPLE: check-ptr ;
|
||||||
|
|
||||||
M: check-ptr summary drop "Memory allocation failed" ;
|
|
||||||
|
|
||||||
: check-ptr ( c-ptr -- c-ptr )
|
: check-ptr ( c-ptr -- c-ptr )
|
||||||
[ \ check-ptr construct-boa throw ] unless* ;
|
[ \ check-ptr construct-boa throw ] unless* ;
|
||||||
|
|
||||||
TUPLE: double-free ;
|
TUPLE: double-free ;
|
||||||
|
|
||||||
M: double-free summary drop "Free failed since memory is not allocated" ;
|
|
||||||
|
|
||||||
: double-free ( -- * )
|
: double-free ( -- * )
|
||||||
\ double-free construct-empty throw ;
|
\ double-free construct-empty throw ;
|
||||||
|
|
||||||
TUPLE: realloc-error ptr size ;
|
TUPLE: realloc-error ptr size ;
|
||||||
|
|
||||||
M: realloc-error summary drop "Memory reallocation failed" ;
|
|
||||||
|
|
||||||
: realloc-error ( alien size -- * )
|
: realloc-error ( alien size -- * )
|
||||||
\ realloc-error construct-boa throw ;
|
\ realloc-error construct-boa throw ;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
USING: tools.deploy.config ;
|
USING: tools.deploy.config ;
|
||||||
H{
|
H{
|
||||||
{ deploy-c-types? f }
|
{ deploy-io 2 }
|
||||||
{ deploy-ui? f }
|
|
||||||
{ deploy-reflection 1 }
|
|
||||||
{ deploy-math? f }
|
{ deploy-math? f }
|
||||||
|
{ deploy-threads? f }
|
||||||
|
{ deploy-compiler? f }
|
||||||
{ deploy-word-props? f }
|
{ deploy-word-props? f }
|
||||||
{ deploy-word-defs? f }
|
{ deploy-word-defs? f }
|
||||||
{ deploy-name "Hello world (console)" }
|
{ deploy-name "Hello world (console)" }
|
||||||
|
{ deploy-reflection 2 }
|
||||||
|
{ deploy-c-types? f }
|
||||||
|
{ deploy-ui? f }
|
||||||
{ "stop-after-last-window?" t }
|
{ "stop-after-last-window?" t }
|
||||||
{ deploy-compiler? f }
|
|
||||||
{ deploy-io 2 }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: io.backend kernel continuations namespaces sequences
|
USING: io.backend kernel continuations namespaces sequences
|
||||||
assocs hashtables sorting arrays threads boxes ;
|
assocs hashtables sorting arrays threads boxes io.timeouts ;
|
||||||
IN: io.monitors
|
IN: io.monitors
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -32,7 +32,11 @@ M: monitor dispose
|
||||||
|
|
||||||
! Simple monitor; used on Linux and Mac OS X. On Windows,
|
! Simple monitor; used on Linux and Mac OS X. On Windows,
|
||||||
! monitors are full-fledged ports.
|
! monitors are full-fledged ports.
|
||||||
TUPLE: simple-monitor handle callback ;
|
TUPLE: simple-monitor handle callback timeout ;
|
||||||
|
|
||||||
|
M: simple-monitor timeout simple-monitor-timeout ;
|
||||||
|
|
||||||
|
M: simple-monitor set-timeout set-simple-monitor-timeout ;
|
||||||
|
|
||||||
: <simple-monitor> ( handle -- simple-monitor )
|
: <simple-monitor> ( handle -- simple-monitor )
|
||||||
f (monitor) <box> {
|
f (monitor) <box> {
|
||||||
|
@ -47,9 +51,14 @@ TUPLE: simple-monitor handle callback ;
|
||||||
: notify-callback ( simple-monitor -- )
|
: notify-callback ( simple-monitor -- )
|
||||||
simple-monitor-callback ?box [ resume ] [ drop ] if ;
|
simple-monitor-callback ?box [ resume ] [ drop ] if ;
|
||||||
|
|
||||||
|
M: simple-monitor timed-out
|
||||||
|
notify-callback ;
|
||||||
|
|
||||||
M: simple-monitor fill-queue ( monitor -- )
|
M: simple-monitor fill-queue ( monitor -- )
|
||||||
|
[
|
||||||
[ swap simple-monitor-callback >box ]
|
[ swap simple-monitor-callback >box ]
|
||||||
"monitor" suspend drop
|
"monitor" suspend drop
|
||||||
|
] with-timeout
|
||||||
check-monitor ;
|
check-monitor ;
|
||||||
|
|
||||||
M: simple-monitor dispose ( monitor -- )
|
M: simple-monitor dispose ( monitor -- )
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
! Copyright (C) 2005, 2008 Slava Pestov.
|
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: io.backend io.nonblocking io.unix.backend io.files io
|
USING: io.backend io.nonblocking io.unix.backend io.files io
|
||||||
unix kernel math continuations math.bitfields byte-arrays
|
unix unix.stat kernel math continuations math.bitfields byte-arrays
|
||||||
alien ;
|
alien ;
|
||||||
|
|
||||||
IN: io.unix.files
|
IN: io.unix.files
|
||||||
|
|
||||||
M: unix-io cwd
|
M: unix-io cwd
|
||||||
|
|
|
@ -66,6 +66,11 @@ HELP: deploy-math?
|
||||||
$nl
|
$nl
|
||||||
"On by default. Often the programmer will use rationals without realizing it. A small amount of space can be saved by stripping these features out, but some code may require changes to work properly." } ;
|
"On by default. Often the programmer will use rationals without realizing it. A small amount of space can be saved by stripping these features out, but some code may require changes to work properly." } ;
|
||||||
|
|
||||||
|
HELP: deploy-threads?
|
||||||
|
{ $description "Deploy flag. If set, the deployed image will contain support for threads."
|
||||||
|
$nl
|
||||||
|
"On by default. Often the programmer will use threads without realizing it. A small amount of space can be saved by stripping this feature out, but some code may require changes to work properly." } ;
|
||||||
|
|
||||||
HELP: deploy-compiler?
|
HELP: deploy-compiler?
|
||||||
{ $description "Deploy flag. If set, words in the deployed image will be compiled with the optimizing compiler when possible."
|
{ $description "Deploy flag. If set, words in the deployed image will be compiled with the optimizing compiler when possible."
|
||||||
$nl
|
$nl
|
||||||
|
|
|
@ -10,6 +10,7 @@ SYMBOL: deploy-name
|
||||||
SYMBOL: deploy-ui?
|
SYMBOL: deploy-ui?
|
||||||
SYMBOL: deploy-compiler?
|
SYMBOL: deploy-compiler?
|
||||||
SYMBOL: deploy-math?
|
SYMBOL: deploy-math?
|
||||||
|
SYMBOL: deploy-threads?
|
||||||
|
|
||||||
SYMBOL: deploy-io
|
SYMBOL: deploy-io
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ SYMBOL: deploy-image
|
||||||
{ deploy-io 2 }
|
{ deploy-io 2 }
|
||||||
{ deploy-reflection 1 }
|
{ deploy-reflection 1 }
|
||||||
{ deploy-compiler? t }
|
{ deploy-compiler? t }
|
||||||
|
{ deploy-threads? t }
|
||||||
{ deploy-math? t }
|
{ deploy-math? t }
|
||||||
{ deploy-word-props? f }
|
{ deploy-word-props? f }
|
||||||
{ deploy-word-defs? f }
|
{ deploy-word-defs? f }
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
IN: temporary
|
||||||
|
USING: tools.test system io.files kernel tools.deploy.config
|
||||||
|
tools.deploy.backend math ;
|
||||||
|
|
||||||
|
: shake-and-bake
|
||||||
|
"." resource-path [
|
||||||
|
vm
|
||||||
|
"hello.image" temp-file
|
||||||
|
rot dup deploy-config make-deploy-image
|
||||||
|
] with-directory ;
|
||||||
|
|
||||||
|
[ ] [ "hello-world" shake-and-bake ] unit-test
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
"hello.image" temp-file file-length 500000 <=
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ ] [ "hello-ui" shake-and-bake ] unit-test
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
"hello.image" temp-file file-length 2000000 <=
|
||||||
|
] unit-test
|
|
@ -11,8 +11,16 @@ IN: tools.deploy.shaker
|
||||||
: strip-init-hooks ( -- )
|
: strip-init-hooks ( -- )
|
||||||
"Stripping startup hooks" show
|
"Stripping startup hooks" show
|
||||||
"command-line" init-hooks get delete-at
|
"command-line" init-hooks get delete-at
|
||||||
"mallocs" init-hooks get delete-at
|
"libc" init-hooks get delete-at
|
||||||
strip-io? [ "io.backend" init-hooks get delete-at ] when ;
|
deploy-threads? get [
|
||||||
|
"threads" init-hooks get delete-at
|
||||||
|
] unless
|
||||||
|
native-io? [
|
||||||
|
"io.thread" init-hooks get delete-at
|
||||||
|
] unless
|
||||||
|
strip-io? [
|
||||||
|
"io.backend" init-hooks get delete-at
|
||||||
|
] when ;
|
||||||
|
|
||||||
: strip-debugger ( -- )
|
: strip-debugger ( -- )
|
||||||
strip-debugger? [
|
strip-debugger? [
|
||||||
|
@ -85,6 +93,7 @@ IN: tools.deploy.shaker
|
||||||
{ } set-retainstack
|
{ } set-retainstack
|
||||||
V{ } set-namestack
|
V{ } set-namestack
|
||||||
V{ } set-catchstack
|
V{ } set-catchstack
|
||||||
|
|
||||||
"Saving final image" show
|
"Saving final image" show
|
||||||
[ save-image-and-exit ] call-clear ;
|
[ save-image-and-exit ] call-clear ;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
USING: kernel ;
|
USING: kernel threads threads.private ;
|
||||||
IN: debugger
|
IN: debugger
|
||||||
|
|
||||||
: print-error die ;
|
: print-error die ;
|
||||||
|
|
||||||
: error. die ;
|
: error. die ;
|
||||||
|
|
||||||
|
M: thread error-in-thread ( error thread -- ) die 2drop ;
|
||||||
|
|
|
@ -10,10 +10,10 @@ IN: tools.deploy.windows
|
||||||
vm over copy-file ;
|
vm over copy-file ;
|
||||||
|
|
||||||
: copy-fonts ( bundle-name -- )
|
: copy-fonts ( bundle-name -- )
|
||||||
"fonts/" resource-path swap copy-tree ;
|
"fonts/" resource-path swap copy-tree-to ;
|
||||||
|
|
||||||
: copy-dlls ( bundle-name -- )
|
: copy-dlls ( bundle-name -- )
|
||||||
{ "freetype6.dll" "zlib1.dll" "factor-nt.dll" }
|
{ "freetype6.dll" "zlib1.dll" "factor.dll" }
|
||||||
[ resource-path ] map
|
[ resource-path ] map
|
||||||
swap copy-files-to ;
|
swap copy-files-to ;
|
||||||
|
|
||||||
|
@ -30,10 +30,11 @@ TUPLE: windows-deploy-implementation ;
|
||||||
T{ windows-deploy-implementation } deploy-implementation set-global
|
T{ windows-deploy-implementation } deploy-implementation set-global
|
||||||
|
|
||||||
M: windows-deploy-implementation deploy*
|
M: windows-deploy-implementation deploy*
|
||||||
"." resource-path cd
|
"." resource-path [
|
||||||
dup deploy-config [
|
dup deploy-config [
|
||||||
[ deploy-name get create-exe-dir ] keep
|
[ deploy-name get create-exe-dir ] keep
|
||||||
[ deploy-name get image-name ] keep
|
[ deploy-name get image-name ] keep
|
||||||
[ namespace make-deploy-image ] keep
|
[ namespace make-deploy-image ] keep
|
||||||
open-in-explorer
|
open-in-explorer
|
||||||
] bind ;
|
] bind
|
||||||
|
] with-directory ;
|
||||||
|
|
|
@ -27,7 +27,7 @@ M: pair make-disassemble-cmd
|
||||||
+closed+ +stdin+ set
|
+closed+ +stdin+ set
|
||||||
out-file +stdout+ set
|
out-file +stdout+ set
|
||||||
[ "gdb" , "-x" , in-file , "-batch" , ] { } make +arguments+ set
|
[ "gdb" , "-x" , in-file , "-batch" , ] { } make +arguments+ set
|
||||||
] { } make-assoc run-process drop
|
] { } make-assoc try-process
|
||||||
out-file file-lines ;
|
out-file file-lines ;
|
||||||
|
|
||||||
: tabs>spaces ( str -- str' )
|
: tabs>spaces ( str -- str' )
|
||||||
|
|
|
@ -34,9 +34,10 @@ TUPLE: deploy-gadget vocab settings ;
|
||||||
"Advanced:" <label> gadget,
|
"Advanced:" <label> gadget,
|
||||||
deploy-compiler? get "Use optimizing compiler" <checkbox> gadget,
|
deploy-compiler? get "Use optimizing compiler" <checkbox> gadget,
|
||||||
deploy-math? get "Rational and complex number support" <checkbox> gadget,
|
deploy-math? get "Rational and complex number support" <checkbox> gadget,
|
||||||
deploy-word-props? get "Include word properties" <checkbox> gadget,
|
deploy-threads? get "Threading support" <checkbox> gadget,
|
||||||
deploy-word-defs? get "Include word definitions" <checkbox> gadget,
|
deploy-word-props? get "Retain all word properties" <checkbox> gadget,
|
||||||
deploy-c-types? get "Include C types" <checkbox> gadget, ;
|
deploy-word-defs? get "Retain all word definitions" <checkbox> gadget,
|
||||||
|
deploy-c-types? get "Retain all C types" <checkbox> gadget, ;
|
||||||
|
|
||||||
: deploy-settings-theme
|
: deploy-settings-theme
|
||||||
{ 10 10 } over set-pack-gap
|
{ 10 10 } over set-pack-gap
|
||||||
|
|
|
@ -24,31 +24,10 @@ C-STRUCT: stat
|
||||||
{ "ulong" "unused4" }
|
{ "ulong" "unused4" }
|
||||||
{ "ulong" "unused5" } ;
|
{ "ulong" "unused5" } ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
FUNCTION: int __xstat ( int ver, char* pathname, stat* buf ) ;
|
FUNCTION: int __xstat ( int ver, char* pathname, stat* buf ) ;
|
||||||
FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ;
|
FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ;
|
||||||
|
|
||||||
: stat ( pathname buf -- int ) 3 -rot __xstat ;
|
: stat ( pathname buf -- int ) 3 -rot __xstat ;
|
||||||
: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
|
: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
: S_IFMT OCT: 170000 ; ! These bits determine file type.
|
|
||||||
|
|
||||||
: S_IFDIR OCT: 40000 ; ! Directory.
|
|
||||||
: S_IFCHR OCT: 20000 ; ! Character device.
|
|
||||||
: S_IFBLK OCT: 60000 ; ! Block device.
|
|
||||||
: S_IFREG OCT: 100000 ; ! Regular file.
|
|
||||||
: S_IFIFO OCT: 010000 ; ! FIFO.
|
|
||||||
: S_IFLNK OCT: 120000 ; ! Symbolic link.
|
|
||||||
: S_IFSOCK OCT: 140000 ; ! Socket.
|
|
||||||
|
|
||||||
: S_ISTYPE ( mode mask -- val ) >r S_IFMT bitand r> = ;
|
|
||||||
|
|
||||||
: S_ISREG ( mode -- value ) S_IFREG S_ISTYPE ;
|
|
||||||
: S_ISDIR ( mode -- value ) S_IFDIR S_ISTYPE ;
|
|
||||||
: S_ISCHR ( mode -- value ) S_IFCHR S_ISTYPE ;
|
|
||||||
: S_ISBLK ( mode -- value ) S_IFBLK S_ISTYPE ;
|
|
||||||
: S_ISFIFO ( mode -- value ) S_IFIFO S_ISTYPE ;
|
|
||||||
: S_ISLNK ( mode -- value ) S_IFLNK S_ISTYPE ;
|
|
||||||
: S_ISSOCK ( mode -- value ) S_IFSOCK S_ISTYPE ;
|
|
||||||
|
|
||||||
|
|
|
@ -29,26 +29,3 @@ FUNCTION: int __lxstat ( int ver, char* pathname, stat* buf ) ;
|
||||||
|
|
||||||
: stat ( pathname buf -- int ) 3 -rot __xstat ;
|
: stat ( pathname buf -- int ) 3 -rot __xstat ;
|
||||||
: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
|
: lstat ( pathname buf -- int ) 3 -rot __lxstat ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
: S_IFMT OCT: 170000 ; ! These bits determine file type.
|
|
||||||
|
|
||||||
: S_IFDIR OCT: 40000 ; ! Directory.
|
|
||||||
: S_IFCHR OCT: 20000 ; ! Character device.
|
|
||||||
: S_IFBLK OCT: 60000 ; ! Block device.
|
|
||||||
: S_IFREG OCT: 100000 ; ! Regular file.
|
|
||||||
: S_IFIFO OCT: 010000 ; ! FIFO.
|
|
||||||
: S_IFLNK OCT: 120000 ; ! Symbolic link.
|
|
||||||
: S_IFSOCK OCT: 140000 ; ! Socket.
|
|
||||||
|
|
||||||
: S_ISTYPE ( mode mask -- val ) >r S_IFMT bitand r> = ;
|
|
||||||
|
|
||||||
: S_ISREG ( mode -- value ) S_IFREG S_ISTYPE ;
|
|
||||||
: S_ISDIR ( mode -- value ) S_IFDIR S_ISTYPE ;
|
|
||||||
: S_ISCHR ( mode -- value ) S_IFCHR S_ISTYPE ;
|
|
||||||
: S_ISBLK ( mode -- value ) S_IFBLK S_ISTYPE ;
|
|
||||||
: S_ISFIFO ( mode -- value ) S_IFIFO S_ISTYPE ;
|
|
||||||
: S_ISLNK ( mode -- value ) S_IFLNK S_ISTYPE ;
|
|
||||||
: S_ISSOCK ( mode -- value ) S_IFSOCK S_ISTYPE ;
|
|
||||||
|
|
||||||
|
|
|
@ -27,26 +27,3 @@ C-STRUCT: stat
|
||||||
|
|
||||||
FUNCTION: int stat ( char* pathname, stat* buf ) ;
|
FUNCTION: int stat ( char* pathname, stat* buf ) ;
|
||||||
FUNCTION: int lstat ( char* pathname, stat* buf ) ;
|
FUNCTION: int lstat ( char* pathname, stat* buf ) ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
: S_IFMT OCT: 170000 ; ! These bits determine file type.
|
|
||||||
|
|
||||||
: S_IFDIR OCT: 40000 ; ! Directory.
|
|
||||||
: S_IFCHR OCT: 20000 ; ! Character device.
|
|
||||||
: S_IFBLK OCT: 60000 ; ! Block device.
|
|
||||||
: S_IFREG OCT: 100000 ; ! Regular file.
|
|
||||||
: S_IFIFO OCT: 010000 ; ! FIFO.
|
|
||||||
: S_IFLNK OCT: 120000 ; ! Symbolic link.
|
|
||||||
: S_IFSOCK OCT: 140000 ; ! Socket.
|
|
||||||
|
|
||||||
: S_ISTYPE ( mode mask -- val ) >r S_IFMT bitand r> = ;
|
|
||||||
|
|
||||||
: S_ISREG ( mode -- value ) S_IFREG S_ISTYPE ;
|
|
||||||
: S_ISDIR ( mode -- value ) S_IFDIR S_ISTYPE ;
|
|
||||||
: S_ISCHR ( mode -- value ) S_IFCHR S_ISTYPE ;
|
|
||||||
: S_ISBLK ( mode -- value ) S_IFBLK S_ISTYPE ;
|
|
||||||
: S_ISFIFO ( mode -- value ) S_IFIFO S_ISTYPE ;
|
|
||||||
: S_ISLNK ( mode -- value ) S_IFLNK S_ISTYPE ;
|
|
||||||
: S_ISSOCK ( mode -- value ) S_IFSOCK S_ISTYPE ;
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,62 @@
|
||||||
|
|
||||||
USING: system combinators vocabs.loader ;
|
USING: kernel system combinators alien.syntax math vocabs.loader ;
|
||||||
|
|
||||||
IN: unix.stat
|
IN: unix.stat
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
! File Types
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
: S_IFMT OCT: 170000 ; ! These bits determine file type.
|
||||||
|
|
||||||
|
: S_IFDIR OCT: 40000 ; ! Directory.
|
||||||
|
: S_IFCHR OCT: 20000 ; ! Character device.
|
||||||
|
: S_IFBLK OCT: 60000 ; ! Block device.
|
||||||
|
: S_IFREG OCT: 100000 ; ! Regular file.
|
||||||
|
: S_IFIFO OCT: 010000 ; ! FIFO.
|
||||||
|
: S_IFLNK OCT: 120000 ; ! Symbolic link.
|
||||||
|
: S_IFSOCK OCT: 140000 ; ! Socket.
|
||||||
|
|
||||||
|
: S_ISTYPE ( mode mask -- val ) >r S_IFMT bitand r> = ;
|
||||||
|
|
||||||
|
: S_ISREG ( mode -- value ) S_IFREG S_ISTYPE ;
|
||||||
|
: S_ISDIR ( mode -- value ) S_IFDIR S_ISTYPE ;
|
||||||
|
: S_ISCHR ( mode -- value ) S_IFCHR S_ISTYPE ;
|
||||||
|
: S_ISBLK ( mode -- value ) S_IFBLK S_ISTYPE ;
|
||||||
|
: S_ISFIFO ( mode -- value ) S_IFIFO S_ISTYPE ;
|
||||||
|
: S_ISLNK ( mode -- value ) S_IFLNK S_ISTYPE ;
|
||||||
|
: S_ISSOCK ( mode -- value ) S_IFSOCK S_ISTYPE ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
! File Access Permissions
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
! Read, write, execute/search by owner
|
||||||
|
: S_IRWXU OCT: 0000700 ; inline ! rwx mask owner
|
||||||
|
: S_IRUSR OCT: 0000400 ; inline ! r owner
|
||||||
|
: S_IWUSR OCT: 0000200 ; inline ! w owner
|
||||||
|
: S_IXUSR OCT: 0000100 ; inline ! x owner
|
||||||
|
! Read, write, execute/search by group
|
||||||
|
: S_IRWXG OCT: 0000070 ; inline ! rwx mask group
|
||||||
|
: S_IRGRP OCT: 0000040 ; inline ! r group
|
||||||
|
: S_IWGRP OCT: 0000020 ; inline ! w group
|
||||||
|
: S_IXGRP OCT: 0000010 ; inline ! x group
|
||||||
|
! Read, write, execute/search by others
|
||||||
|
: S_IRWXO OCT: 0000007 ; inline ! rwx mask other
|
||||||
|
: S_IROTH OCT: 0000004 ; inline ! r other
|
||||||
|
: S_IWOTH OCT: 0000002 ; inline ! w other
|
||||||
|
: S_IXOTH OCT: 0000001 ; inline ! x other
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
FUNCTION: int chmod ( char* path, mode_t mode ) ;
|
||||||
|
|
||||||
|
FUNCTION: int fchmod ( int fd, mode_t mode ) ;
|
||||||
|
|
||||||
|
FUNCTION: int mkdir ( char* path, mode_t mode ) ;
|
||||||
|
|
||||||
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
{
|
{
|
||||||
{ [ linux? ] [ "unix.stat.linux" require ] }
|
{ [ linux? ] [ "unix.stat.linux" require ] }
|
||||||
{ [ t ] [ ] }
|
{ [ t ] [ ] }
|
||||||
|
|
|
@ -7,9 +7,9 @@ IN: unix.types
|
||||||
|
|
||||||
TYPEDEF: ulonglong __uquad_type
|
TYPEDEF: ulonglong __uquad_type
|
||||||
TYPEDEF: ulong __ulongword_type
|
TYPEDEF: ulong __ulongword_type
|
||||||
TYPEDEF: uint __uword_type
|
TYPEDEF: long __sword_type
|
||||||
|
TYPEDEF: ulong __uword_type
|
||||||
TYPEDEF: long __slongword_type
|
TYPEDEF: long __slongword_type
|
||||||
TYPEDEF: int __sword_type
|
|
||||||
TYPEDEF: uint __u32_type
|
TYPEDEF: uint __u32_type
|
||||||
TYPEDEF: int __s32_type
|
TYPEDEF: int __s32_type
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
USING: alien.syntax ;
|
||||||
|
|
||||||
IN: unix.types
|
IN: unix.types
|
||||||
|
|
||||||
! Darwin 9.1.0 ppc
|
! Darwin 9.1.0 ppc
|
||||||
|
|
|
@ -1,37 +1,15 @@
|
||||||
! Copyright (C) 2005, 2007 Slava Pestov.
|
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: unix
|
|
||||||
USING: alien alien.c-types alien.syntax kernel libc structs
|
USING: alien alien.c-types alien.syntax kernel libc structs
|
||||||
math namespaces system combinators vocabs.loader ;
|
math namespaces system combinators vocabs.loader unix.types ;
|
||||||
|
|
||||||
! ! ! Unix types
|
IN: unix
|
||||||
|
|
||||||
TYPEDEF: long word
|
|
||||||
TYPEDEF: ulong uword
|
|
||||||
|
|
||||||
TYPEDEF: long longword
|
|
||||||
TYPEDEF: ulong ulongword
|
|
||||||
|
|
||||||
TYPEDEF: long ssize_t
|
|
||||||
TYPEDEF: longword blksize_t
|
|
||||||
TYPEDEF: longword blkcnt_t
|
|
||||||
TYPEDEF: longlong quad_t
|
|
||||||
TYPEDEF: ulonglong dev_t
|
|
||||||
TYPEDEF: uint gid_t
|
|
||||||
TYPEDEF: uint in_addr_t
|
TYPEDEF: uint in_addr_t
|
||||||
TYPEDEF: ulong ino_t
|
|
||||||
TYPEDEF: int pid_t
|
|
||||||
TYPEDEF: uint socklen_t
|
TYPEDEF: uint socklen_t
|
||||||
TYPEDEF: uint time_t
|
TYPEDEF: uint time_t
|
||||||
TYPEDEF: uint uid_t
|
|
||||||
TYPEDEF: ulong size_t
|
TYPEDEF: ulong size_t
|
||||||
TYPEDEF: ulong u_long
|
|
||||||
TYPEDEF: uint mode_t
|
|
||||||
TYPEDEF: uword nlink_t
|
|
||||||
TYPEDEF: void* caddr_t
|
|
||||||
|
|
||||||
TYPEDEF: ulong off_t
|
|
||||||
TYPEDEF-IF: bsd? ulonglong off_t
|
|
||||||
|
|
||||||
C-STRUCT: tm
|
C-STRUCT: tm
|
||||||
{ "int" "sec" } ! Seconds: 0-59 (K&R says 0-61?)
|
{ "int" "sec" } ! Seconds: 0-59 (K&R says 0-61?)
|
||||||
|
@ -56,41 +34,6 @@ C-STRUCT: timespec
|
||||||
[ set-timespec-nsec ] keep
|
[ set-timespec-nsec ] keep
|
||||||
[ set-timespec-sec ] keep ;
|
[ set-timespec-sec ] keep ;
|
||||||
|
|
||||||
! ! ! Unix constants
|
|
||||||
|
|
||||||
! File type
|
|
||||||
: S_IFMT OCT: 0170000 ; inline ! type of file
|
|
||||||
: S_IFIFO OCT: 0010000 ; inline ! named pipe (fifo)
|
|
||||||
: S_IFCHR OCT: 0020000 ; inline ! character special
|
|
||||||
: S_IFDIR OCT: 0040000 ; inline ! directory
|
|
||||||
: S_IFBLK OCT: 0060000 ; inline ! block special
|
|
||||||
: S_IFREG OCT: 0100000 ; inline ! regular
|
|
||||||
: S_IFLNK OCT: 0120000 ; inline ! symbolic link
|
|
||||||
: S_IFSOCK OCT: 0140000 ; inline ! socket
|
|
||||||
: S_IFWHT OCT: 0160000 ; inline ! whiteout
|
|
||||||
: S_IFXATTR OCT: 0200000 ; inline ! extended attribute
|
|
||||||
|
|
||||||
! File mode
|
|
||||||
! Read, write, execute/search by owner
|
|
||||||
: S_IRWXU OCT: 0000700 ; inline ! rwx mask owner
|
|
||||||
: S_IRUSR OCT: 0000400 ; inline ! r owner
|
|
||||||
: S_IWUSR OCT: 0000200 ; inline ! w owner
|
|
||||||
: S_IXUSR OCT: 0000100 ; inline ! x owner
|
|
||||||
! Read, write, execute/search by group
|
|
||||||
: S_IRWXG OCT: 0000070 ; inline ! rwx mask group
|
|
||||||
: S_IRGRP OCT: 0000040 ; inline ! r group
|
|
||||||
: S_IWGRP OCT: 0000020 ; inline ! w group
|
|
||||||
: S_IXGRP OCT: 0000010 ; inline ! x group
|
|
||||||
! Read, write, execute/search by others
|
|
||||||
: S_IRWXO OCT: 0000007 ; inline ! rwx mask other
|
|
||||||
: S_IROTH OCT: 0000004 ; inline ! r other
|
|
||||||
: S_IWOTH OCT: 0000002 ; inline ! w other
|
|
||||||
: S_IXOTH OCT: 0000001 ; inline ! x other
|
|
||||||
|
|
||||||
: S_ISUID OCT: 0004000 ; inline ! set user id on execution
|
|
||||||
: S_ISGID OCT: 0002000 ; inline ! set group id on execution
|
|
||||||
: S_ISVTX OCT: 0001000 ; inline ! sticky bit
|
|
||||||
|
|
||||||
: PROT_NONE 0 ; inline
|
: PROT_NONE 0 ; inline
|
||||||
: PROT_READ 1 ; inline
|
: PROT_READ 1 ; inline
|
||||||
: PROT_WRITE 2 ; inline
|
: PROT_WRITE 2 ; inline
|
||||||
|
@ -113,7 +56,6 @@ LIBRARY: libc
|
||||||
FUNCTION: int accept ( int s, void* sockaddr, socklen_t* socklen ) ;
|
FUNCTION: int accept ( int s, void* sockaddr, socklen_t* socklen ) ;
|
||||||
FUNCTION: int bind ( int s, void* name, socklen_t namelen ) ;
|
FUNCTION: int bind ( int s, void* name, socklen_t namelen ) ;
|
||||||
FUNCTION: int chdir ( char* path ) ;
|
FUNCTION: int chdir ( char* path ) ;
|
||||||
FUNCTION: int chmod ( char* path, mode_t mode ) ;
|
|
||||||
FUNCTION: int chown ( char* path, uid_t owner, gid_t group ) ;
|
FUNCTION: int chown ( char* path, uid_t owner, gid_t group ) ;
|
||||||
FUNCTION: int chroot ( char* path ) ;
|
FUNCTION: int chroot ( char* path ) ;
|
||||||
FUNCTION: void close ( int fd ) ;
|
FUNCTION: void close ( int fd ) ;
|
||||||
|
@ -124,7 +66,6 @@ FUNCTION: int execv ( char* path, char** argv ) ;
|
||||||
FUNCTION: int execvp ( char* path, char** argv ) ;
|
FUNCTION: int execvp ( char* path, char** argv ) ;
|
||||||
FUNCTION: int execve ( char* path, char** argv, char** envp ) ;
|
FUNCTION: int execve ( char* path, char** argv, char** envp ) ;
|
||||||
FUNCTION: int fchdir ( int fd ) ;
|
FUNCTION: int fchdir ( int fd ) ;
|
||||||
FUNCTION: int fchmod ( int fd, mode_t mode ) ;
|
|
||||||
FUNCTION: int fchown ( int fd, uid_t owner, gid_t group ) ;
|
FUNCTION: int fchown ( int fd, uid_t owner, gid_t group ) ;
|
||||||
FUNCTION: int fcntl ( int fd, int cmd, int arg ) ;
|
FUNCTION: int fcntl ( int fd, int cmd, int arg ) ;
|
||||||
FUNCTION: int flock ( int fd, int operation ) ;
|
FUNCTION: int flock ( int fd, int operation ) ;
|
||||||
|
@ -150,7 +91,6 @@ FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ;
|
||||||
FUNCTION: int listen ( int s, int backlog ) ;
|
FUNCTION: int listen ( int s, int backlog ) ;
|
||||||
FUNCTION: tm* localtime ( time_t* clock ) ;
|
FUNCTION: tm* localtime ( time_t* clock ) ;
|
||||||
FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ;
|
FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ;
|
||||||
FUNCTION: int mkdir ( char* path, mode_t mode ) ;
|
|
||||||
FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ;
|
FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ;
|
||||||
FUNCTION: int munmap ( void* addr, size_t len ) ;
|
FUNCTION: int munmap ( void* addr, size_t len ) ;
|
||||||
FUNCTION: uint ntohl ( uint n ) ;
|
FUNCTION: uint ntohl ( uint n ) ;
|
||||||
|
|
|
@ -161,6 +161,9 @@ DEFINE_PRIMITIVE(save_image_and_exit)
|
||||||
for(i = 0; i < FIRST_SAVE_ENV; i++)
|
for(i = 0; i < FIRST_SAVE_ENV; i++)
|
||||||
userenv[i] = F;
|
userenv[i] = F;
|
||||||
|
|
||||||
|
for(i = LAST_SAVE_ENV + 1; i < USER_ENV; i++)
|
||||||
|
userenv[i] = F;
|
||||||
|
|
||||||
/* do a full GC + code heap compaction */
|
/* do a full GC + code heap compaction */
|
||||||
compact_code_heap();
|
compact_code_heap();
|
||||||
|
|
||||||
|
|
1
vm/run.h
1
vm/run.h
|
@ -64,6 +64,7 @@ typedef enum {
|
||||||
} F_ENVTYPE;
|
} F_ENVTYPE;
|
||||||
|
|
||||||
#define FIRST_SAVE_ENV BOOT_ENV
|
#define FIRST_SAVE_ENV BOOT_ENV
|
||||||
|
#define LAST_SAVE_ENV STAGE2_ENV
|
||||||
|
|
||||||
/* TAGGED user environment data; see getenv/setenv prims */
|
/* TAGGED user environment data; see getenv/setenv prims */
|
||||||
DLLEXPORT CELL userenv[USER_ENV];
|
DLLEXPORT CELL userenv[USER_ENV];
|
||||||
|
|
Loading…
Reference in New Issue