More core cleanups

db4
Slava Pestov 2008-07-28 22:57:43 -05:00
parent 4be5b70695
commit 8a2f1d0451
9 changed files with 13 additions and 22 deletions

View File

@ -2,7 +2,7 @@
! Copyright (C) 2007, 2008 Slava Pestov
! Copyright (C) 2007, 2008 Doug Coleman
! See http://factorcode.org/license.txt for BSD license.
USING: alien assocs continuations destructors init kernel
USING: alien assocs continuations destructors kernel
namespaces accessors sets ;
IN: libc
@ -20,7 +20,14 @@ IN: libc
: (realloc) ( alien size -- newalien )
"void*" "libc" "realloc" { "void*" "ulong" } alien-invoke ;
SYMBOL: mallocs
SYMBOL: malloc-expiry
: mallocs ( -- assoc )
malloc-expiry get-global dup expired? [
drop
-1 <alien> malloc-expiry set-global
H{ } clone dup \ mallocs set-global
] when ;
PRIVATE>
@ -35,19 +42,17 @@ ERROR: realloc-error ptr size ;
<PRIVATE
[ H{ } clone mallocs set-global ] "libc" add-init-hook
: add-malloc ( alien -- )
mallocs get-global conjoin ;
mallocs conjoin ;
: delete-malloc ( alien -- )
[
mallocs get-global delete-at*
mallocs delete-at*
[ double-free ] unless drop
] when* ;
: malloc-exists? ( alien -- ? )
mallocs get-global key? ;
mallocs key? ;
PRIVATE>

View File

@ -1,11 +1,11 @@
! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: bootstrap.stage1
USING: arrays debugger generic hashtables io assocs
kernel.private kernel math memory namespaces parser
prettyprint sequences vectors words system splitting
init io.files bootstrap.image bootstrap.image.private vocabs
vocabs.loader system debugger continuations ;
IN: bootstrap.stage1
{ "resource:core" } vocab-roots set
@ -33,10 +33,6 @@ load-help? off
"math.floats" require
"memory" require
! this must add its init hook before io.backend does
"libc" require
! "io.thread" require
"io.streams.c" require
"vocabs.loader" require

View File

@ -1,7 +0,0 @@
IN: init.tests
USING: init namespaces sequences math tools.test kernel ;
[ t ] [
init-hooks get [ first "libc" = ] find drop
init-hooks get [ first "io.backend" = ] find drop <
] unit-test

View File

@ -1,3 +0,0 @@
USING: io io.streams.string io.streams.nested kernel math
namespaces io.styles tools.test ;
IN: io.streams.nested.tests