From 8819f233129a07ea30e3dd8907fe6681982f5459 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 19 Nov 2008 01:50:05 -0600 Subject: [PATCH] Replace millis primitive with micros primitive Add millis as a library word sleep now takes either a duration or a microsecond count; code using durations doens't need to be updated, code using millisecond counts updated to use durations for the most part --- basis/bootstrap/stage2.factor | 10 +++++----- basis/calendar/calendar-docs.factor | 6 +++--- basis/calendar/calendar-tests.factor | 8 ++++---- basis/calendar/calendar.factor | 10 ++++++++-- basis/calendar/model/model.factor | 2 +- basis/compiler/tests/alien.factor | 2 +- .../combinators/combinators-tests.factor | 2 +- basis/concurrency/flags/flags-tests.factor | 8 ++++---- basis/concurrency/futures/futures-docs.factor | 6 +++--- basis/concurrency/locks/locks-tests.factor | 4 ++-- basis/concurrency/promises/promises-docs.factor | 2 +- basis/core-foundation/run-loop/run-loop.factor | 4 ++-- basis/io/launcher/launcher.factor | 5 +++-- basis/io/unix/files/files.factor | 2 +- basis/io/unix/kqueue/kqueue.factor | 2 +- basis/io/unix/select/select.factor | 4 ++-- basis/io/windows/nt/pipes/pipes.factor | 2 +- basis/smtp/smtp.factor | 2 +- basis/stack-checker/known-words/known-words.factor | 4 ++-- basis/stack-checker/stack-checker.factor | 5 ++++- basis/threads/threads-docs.factor | 2 +- basis/threads/threads.factor | 6 +++--- basis/tools/deploy/test/1/1.factor | 2 +- basis/tools/profiler/profiler-tests.factor | 2 +- basis/tools/threads/threads.factor | 4 ++-- basis/tools/time/time-docs.factor | 6 +++--- basis/tools/time/time.factor | 12 ++++++------ basis/ui/gestures/gestures-docs.factor | 2 +- basis/ui/gestures/gestures.factor | 6 +++--- basis/ui/tools/interactor/interactor-tests.factor | 8 ++++---- basis/ui/tools/listener/listener-tests.factor | 5 +++-- basis/ui/tools/search/search-tests.factor | 6 +++--- basis/ui/ui.factor | 6 +++--- basis/unix/time/time.factor | 8 ++++---- core/alien/alien-docs.factor | 4 ++-- core/bootstrap/primitives.factor | 2 +- core/io/backend/backend-docs.factor | 4 ++-- core/io/streams/c/c.factor | 2 +- core/system/system-docs.factor | 11 ++++++++--- core/system/system.factor | 2 ++ extra/crypto/timing/timing.factor | 4 ++-- extra/jamshred/jamshred.factor | 2 +- extra/mason/test/test.factor | 13 ++++++++----- extra/nehe/4/4.factor | 5 +++-- extra/nehe/5/5.factor | 5 +++-- extra/openal/example/example.factor | 6 +++--- vm/data_gc.c | 12 ++++++------ vm/data_gc.h | 4 ++-- vm/factor.c | 6 +++--- vm/os-unix.c | 8 ++++---- vm/os-unix.h | 4 ++-- vm/os-windows-ce.c | 4 ++-- vm/os-windows-ce.h | 2 +- vm/os-windows-nt.c | 4 ++-- vm/os-windows.c | 4 ++-- vm/os-windows.h | 4 ++-- vm/primitives.c | 2 +- vm/run.c | 6 +++--- vm/run.h | 2 +- 59 files changed, 155 insertions(+), 132 deletions(-) diff --git a/basis/bootstrap/stage2.factor b/basis/bootstrap/stage2.factor index d25394e978..78d555fe92 100644 --- a/basis/bootstrap/stage2.factor +++ b/basis/bootstrap/stage2.factor @@ -32,8 +32,8 @@ SYMBOL: bootstrap-time : count-words ( pred -- ) all-words swap count number>string write ; -: print-time ( time -- ) - 1000 /i +: print-time ( us -- ) + 1000000 /i 60 /mod swap number>string write " minutes and " write number>string write " seconds." print ; @@ -52,7 +52,7 @@ SYMBOL: bootstrap-time [ ! We time bootstrap - millis + micros default-image-name "output-image" set-global @@ -77,7 +77,7 @@ SYMBOL: bootstrap-time [ load-components - millis over - core-bootstrap-time set-global + micros over - core-bootstrap-time set-global run-bootstrap-init ] with-compiler-errors @@ -100,7 +100,7 @@ SYMBOL: bootstrap-time ] [ print-error 1 exit ] recover ] set-boot-quot - millis swap - bootstrap-time set-global + micros swap - bootstrap-time set-global print-report "output-image" get save-image-and-exit diff --git a/basis/calendar/calendar-docs.factor b/basis/calendar/calendar-docs.factor index 64c74a494a..433459cb24 100644 --- a/basis/calendar/calendar-docs.factor +++ b/basis/calendar/calendar-docs.factor @@ -365,12 +365,12 @@ HELP: unix-1970 { $values { "timestamp" timestamp } } { $description "Outputs the beginning of UNIX time, or midnight, January 1, 1970." } ; -HELP: millis>timestamp +HELP: micros>timestamp { $values { "x" number } { "timestamp" timestamp } } -{ $description "Converts a number of milliseconds into a timestamp value in GMT time." } +{ $description "Converts a number of microseconds into a timestamp value in GMT time." } { $examples { $example "USING: accessors calendar prettyprint ;" - "1000 millis>timestamp year>> ." + "1000 micros>timestamp year>> ." "1970" } } ; diff --git a/basis/calendar/calendar-tests.factor b/basis/calendar/calendar-tests.factor index 995bd23c09..00d5730745 100644 --- a/basis/calendar/calendar-tests.factor +++ b/basis/calendar/calendar-tests.factor @@ -143,10 +143,10 @@ IN: calendar.tests [ +gt+ ] [ 2005 1 1 12 30 0 instant 2004 1 1 13 30 0 instant <=> ] unit-test -[ t ] [ now timestamp>millis millis - 1000 < ] unit-test -[ t ] [ 0 millis>timestamp unix-1970 = ] unit-test -[ t ] [ 123456789000 [ millis>timestamp timestamp>millis ] keep = ] unit-test -[ t ] [ 123456789123456 [ millis>timestamp timestamp>millis ] keep = ] unit-test +[ t ] [ now timestamp>micros micros - 1000000 < ] unit-test +[ t ] [ 0 micros>timestamp unix-1970 = ] unit-test +[ t ] [ 123456789000000 [ micros>timestamp timestamp>micros ] keep = ] unit-test +[ t ] [ 123456789123456000 [ micros>timestamp timestamp>micros ] keep = ] unit-test : checktime+ now dup clone [ rot time+ drop ] keep = ; diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index c002760748..a78cf60eb0 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -325,9 +325,15 @@ M: duration time- : timestamp>millis ( timestamp -- n ) unix-1970 (time-) 1000 * >integer ; +: micros>timestamp ( x -- timestamp ) + >r unix-1970 r> microseconds time+ ; + +: timestamp>micros ( timestamp -- n ) + unix-1970 (time-) 1000000 * >integer ; + : gmt ( -- timestamp ) #! GMT time, right now - unix-1970 millis milliseconds time+ ; + unix-1970 micros microseconds time+ ; : now ( -- timestamp ) gmt >local-time ; : hence ( duration -- timestamp ) now swap time+ ; @@ -404,7 +410,7 @@ PRIVATE> : since-1970 ( duration -- timestamp ) unix-1970 time+ >local-time ; -M: timestamp sleep-until timestamp>millis sleep-until ; +M: timestamp sleep-until timestamp>micros sleep-until ; M: duration sleep hence sleep-until ; diff --git a/basis/calendar/model/model.factor b/basis/calendar/model/model.factor index 60a61c2026..8665cc22ce 100644 --- a/basis/calendar/model/model.factor +++ b/basis/calendar/model/model.factor @@ -7,7 +7,7 @@ SYMBOL: time : (time-thread) ( -- ) now time get set-model - 1000 sleep (time-thread) ; + 1 seconds sleep (time-thread) ; : time-thread ( -- ) [ diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 3ca6fc87f3..abcdb46ea2 100644 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -361,7 +361,7 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ; [ 1 2 3 ] [ callback-6 callback_test_1 1 2 3 ] unit-test : callback-7 ( -- callback ) - "void" { } "cdecl" [ 1000 sleep ] alien-callback ; + "void" { } "cdecl" [ 1000000 sleep ] alien-callback ; [ 1 2 3 ] [ callback-7 callback_test_1 1 2 3 ] unit-test diff --git a/basis/concurrency/combinators/combinators-tests.factor b/basis/concurrency/combinators/combinators-tests.factor index 562111242d..440a6766c5 100644 --- a/basis/concurrency/combinators/combinators-tests.factor +++ b/basis/concurrency/combinators/combinators-tests.factor @@ -10,7 +10,7 @@ concurrency.mailboxes threads sequences accessors arrays ; [ { 1 4 9 } ] [ { 1 2 3 } [ sq ] parallel-map ] unit-test -[ { 1 4 9 } ] [ { 1 2 3 } [ 1000 random sleep sq ] parallel-map ] unit-test +[ { 1 4 9 } ] [ { 1 2 3 } [ 1000000 random sleep sq ] parallel-map ] unit-test [ { 1 2 3 } [ dup 2 mod 0 = [ "Even" throw ] when ] parallel-map ] [ error>> "Even" = ] must-fail-with diff --git a/basis/concurrency/flags/flags-tests.factor b/basis/concurrency/flags/flags-tests.factor index 9d3f6de98c..0f78183aba 100644 --- a/basis/concurrency/flags/flags-tests.factor +++ b/basis/concurrency/flags/flags-tests.factor @@ -1,6 +1,6 @@ IN: concurrency.flags.tests USING: tools.test concurrency.flags concurrency.combinators -kernel threads locals accessors ; +kernel threads locals accessors calendar ; :: flag-test-1 ( -- ) [let | f [ ] | @@ -13,7 +13,7 @@ kernel threads locals accessors ; :: flag-test-2 ( -- ) [let | f [ ] | - [ 1000 sleep f raise-flag ] "Flag test" spawn drop + [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop f lower-flag f value>> ] ; @@ -39,7 +39,7 @@ kernel threads locals accessors ; :: flag-test-5 ( -- ) [let | f [ ] | - [ 1000 sleep f raise-flag ] "Flag test" spawn drop + [ 1 seconds sleep f raise-flag ] "Flag test" spawn drop f wait-for-flag f value>> ] ; @@ -48,6 +48,6 @@ kernel threads locals accessors ; [ ] [ { 1 2 } - [ [ 1000 sleep raise-flag ] curry "Flag test" spawn drop ] + [ [ 1 seconds sleep raise-flag ] curry "Flag test" spawn drop ] [ [ wait-for-flag drop ] curry parallel-each ] bi ] unit-test diff --git a/basis/concurrency/futures/futures-docs.factor b/basis/concurrency/futures/futures-docs.factor index 22549c1720..3d2ac552de 100644 --- a/basis/concurrency/futures/futures-docs.factor +++ b/basis/concurrency/futures/futures-docs.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2008 Chris Double, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: concurrency.promises concurrency.messaging kernel arrays -continuations help.markup help.syntax quotations ; +continuations help.markup help.syntax quotations calendar ; IN: concurrency.futures HELP: future @@ -11,8 +11,8 @@ $nl "The quotation begins with an empty data stack, an empty catch stack, and a name stack containing the global namespace only. This means that the only way to pass data to the quotation is to partially apply the data, for example using " { $link curry } " or " { $link compose } "." } ; HELP: ?future-timeout -{ $values { "future" future } { "timeout" "a timeout in milliseconds or " { $link f } } { "value" object } } -{ $description "Waits for a deferred computation to complete, blocking indefinitely if " { $snippet "timeout" } " is " { $link f } ", otherwise waiting up to " { $snippet "timeout" } " milliseconds." } +{ $values { "future" future } { "timeout" { $maybe duration } } { "value" object } } +{ $description "Waits for a deferred computation to complete, blocking indefinitely if " { $snippet "timeout" } " is " { $link f } ", otherwise waiting up to the " { $snippet "timeout" } " before throwing an error." } { $errors "Throws an error if the timeout expires before the computation completes. Also throws an error if the future quotation threw an error." } ; HELP: ?future diff --git a/basis/concurrency/locks/locks-tests.factor b/basis/concurrency/locks/locks-tests.factor index 67f9bbb15a..7696e6c1eb 100644 --- a/basis/concurrency/locks/locks-tests.factor +++ b/basis/concurrency/locks/locks-tests.factor @@ -100,7 +100,7 @@ threads sequences calendar accessors ; c await l [ 4 v push - 1000 sleep + 1 seconds sleep 5 v push ] with-write-lock c'' count-down @@ -139,7 +139,7 @@ threads sequences calendar accessors ; l [ 1 v push c count-down - 1000 sleep + 1 seconds sleep 2 v push ] with-write-lock c' count-down diff --git a/basis/concurrency/promises/promises-docs.factor b/basis/concurrency/promises/promises-docs.factor index be7a8cf65b..8e160842a9 100644 --- a/basis/concurrency/promises/promises-docs.factor +++ b/basis/concurrency/promises/promises-docs.factor @@ -13,7 +13,7 @@ HELP: promise-fulfilled? HELP: ?promise-timeout { $values { "promise" promise } { "timeout" { $maybe duration } } { "result" object } } -{ $description "Waits for another thread to fulfill a promise, returning immediately if the promise has already been fulfilled. A timeout of " { $link f } " indicates that the thread may block indefinitely, otherwise it will wait up to " { $snippet "timeout" } " milliseconds." } +{ $description "Waits for another thread to fulfill a promise, returning immediately if the promise has already been fulfilled. A timeout of " { $link f } " indicates that the thread may block indefinitely, otherwise it will wait up to the " { $snippet "timeout" } " before throwing an error." } { $errors "Throws an error if the timeout expires before the promise has been fulfilled." } ; HELP: ?promise diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index e30cc2eb60..9a5666b5d3 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: alien.syntax kernel threads init namespaces alien -core-foundation ; +core-foundation calendar ; IN: core-foundation.run-loop : kCFRunLoopRunFinished 1 ; inline @@ -30,7 +30,7 @@ FUNCTION: SInt32 CFRunLoopRunInMode ( : run-loop-thread ( -- ) CFRunLoopDefaultMode 0 f CFRunLoopRunInMode - kCFRunLoopRunHandledSource = [ 1000 sleep ] unless + kCFRunLoopRunHandledSource = [ 1 seconds sleep ] unless run-loop-thread ; : start-run-loop-thread ( -- ) diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor index 3e1ef6ce05..bdccfc3f57 100644 --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -4,7 +4,8 @@ USING: system kernel namespaces strings hashtables sequences assocs combinators vocabs.loader init threads continuations math accessors concurrency.flags destructors environment io io.backend io.timeouts io.pipes io.pipes.private io.encodings -io.streams.duplex io.ports debugger prettyprint summary ; +io.streams.duplex io.ports debugger prettyprint summary +calendar ; IN: io.launcher TUPLE: process < identity-tuple @@ -65,7 +66,7 @@ SYMBOL: wait-flag : wait-loop ( -- ) processes get assoc-empty? [ wait-flag get-global lower-flag ] - [ wait-for-processes [ 100 sleep ] when ] if ; + [ wait-for-processes [ 100 milliseconds sleep ] when ] if ; : start-wait-thread ( -- ) wait-flag set-global diff --git a/basis/io/unix/files/files.factor b/basis/io/unix/files/files.factor index 3f254e7713..fb8615c47b 100644 --- a/basis/io/unix/files/files.factor +++ b/basis/io/unix/files/files.factor @@ -290,7 +290,7 @@ M: string other-execute? ( path -- ? ) OTHER-EXECUTE file-mode? ; dup length [ over [ pick set-timeval-nth ] [ 2drop ] if ] 2each ; : timestamp>timeval ( timestamp -- timeval ) - unix-1970 time- duration>milliseconds make-timeval ; + unix-1970 time- duration>microseconds make-timeval ; : timestamps>byte-array ( timestamps -- byte-array ) [ dup [ timestamp>timeval ] when ] map make-timeval-array ; diff --git a/basis/io/unix/kqueue/kqueue.factor b/basis/io/unix/kqueue/kqueue.factor index b3e69a453c..ba4240de7f 100644 --- a/basis/io/unix/kqueue/kqueue.factor +++ b/basis/io/unix/kqueue/kqueue.factor @@ -94,7 +94,7 @@ M: kqueue-mx unregister-io-task ( task mx -- ) : handle-kevents ( mx n -- ) [ over events>> kevent-nth handle-kevent ] with each ; -M: kqueue-mx wait-for-events ( ms mx -- ) +M: kqueue-mx wait-for-events ( us mx -- ) swap dup [ make-timespec ] when dupd wait-kevent handle-kevents ; diff --git a/basis/io/unix/select/select.factor b/basis/io/unix/select/select.factor index f2a802a859..530dfe7ab3 100644 --- a/basis/io/unix/select/select.factor +++ b/basis/io/unix/select/select.factor @@ -48,9 +48,9 @@ TUPLE: select-mx < mx read-fdset write-fdset ; [ write-fdset/tasks [ init-fdset ] [ underlying>> ] bi ] tri f ; -M:: select-mx wait-for-events ( ms mx -- ) +M:: select-mx wait-for-events ( us mx -- ) mx - [ init-fdsets ms dup [ make-timeval ] when select multiplexer-error ] + [ init-fdsets us dup [ make-timeval ] when select multiplexer-error ] [ [ read-fdset/tasks ] keep [ input-available ] check-fdset ] [ [ write-fdset/tasks ] keep [ output-available ] check-fdset ] tri ; diff --git a/basis/io/windows/nt/pipes/pipes.factor b/basis/io/windows/nt/pipes/pipes.factor index c9bf1ebf42..d498875c87 100644 --- a/basis/io/windows/nt/pipes/pipes.factor +++ b/basis/io/windows/nt/pipes/pipes.factor @@ -35,7 +35,7 @@ IN: io.windows.nt.pipes "-" % 32 random-bits # "-" % - millis # + micros # ] "" make ; M: winnt (pipe) ( -- pipe ) diff --git a/basis/smtp/smtp.factor b/basis/smtp/smtp.factor index c17bccf064..63603ad131 100644 --- a/basis/smtp/smtp.factor +++ b/basis/smtp/smtp.factor @@ -145,7 +145,7 @@ ERROR: invalid-header-string string ; "<" % 64 random-bits # "-" % - millis # + micros # "@" % smtp-domain get [ host-name ] unless* % ">" % diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index fdc4b4b35c..7ee46cb440 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -423,8 +423,8 @@ do-primitive alien-invoke alien-indirect alien-callback \ code-room { } { integer integer integer integer } define-primitive \ code-room make-flushable -\ millis { } { integer } define-primitive -\ millis make-flushable +\ micros { } { integer } define-primitive +\ micros make-flushable \ tag { object } { fixnum } define-primitive \ tag make-foldable diff --git a/basis/stack-checker/stack-checker.factor b/basis/stack-checker/stack-checker.factor index c990a51cc1..ff283ce9ca 100644 --- a/basis/stack-checker/stack-checker.factor +++ b/basis/stack-checker/stack-checker.factor @@ -24,4 +24,7 @@ M: callable infer ( quot -- effect ) : forget-effects ( -- ) forget-errors - all-words [ f "inferred-effect" set-word-prop ] each ; + all-words [ + dup subwords [ f "inferred-effect" set-word-prop ] each + f "inferred-effect" set-word-prop + ] each ; diff --git a/basis/threads/threads-docs.factor b/basis/threads/threads-docs.factor index 471cd2bd34..cc2216545d 100644 --- a/basis/threads/threads-docs.factor +++ b/basis/threads/threads-docs.factor @@ -100,7 +100,7 @@ HELP: sleep-queue { $var-description "A " { $link min-heap } " storing the queue of sleeping threads." } ; HELP: sleep-time -{ $values { "ms/f" "a non-negative integer or " { $link f } } } +{ $values { "us/f" "a non-negative integer or " { $link f } } } { $description "Outputs the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, outputs " { $link f } "." } ; HELP: stop diff --git a/basis/threads/threads.factor b/basis/threads/threads.factor index 8a4d433273..5dca7be633 100644 --- a/basis/threads/threads.factor +++ b/basis/threads/threads.factor @@ -93,7 +93,7 @@ PRIVATE> { { [ run-queue deque-empty? not ] [ 0 ] } { [ sleep-queue heap-empty? ] [ f ] } - [ sleep-queue heap-peek nip millis [-] ] + [ sleep-queue heap-peek nip micros [-] ] } cond ; DEFER: stop @@ -106,7 +106,7 @@ DEFER: stop : expire-sleep? ( heap -- ? ) dup heap-empty? - [ drop f ] [ heap-peek nip millis <= ] if ; + [ drop f ] [ heap-peek nip micros <= ] if ; : expire-sleep ( thread -- ) f >>sleep-entry resume ; @@ -184,7 +184,7 @@ M: f sleep-until GENERIC: sleep ( dt -- ) M: real sleep - millis + >integer sleep-until ; + micros + >integer sleep-until ; : interrupt ( thread -- ) dup state>> [ diff --git a/basis/tools/deploy/test/1/1.factor b/basis/tools/deploy/test/1/1.factor index 0ca85bca8c..63b382e2f6 100644 --- a/basis/tools/deploy/test/1/1.factor +++ b/basis/tools/deploy/test/1/1.factor @@ -1,6 +1,6 @@ IN: tools.deploy.test.1 USING: threads ; -: deploy-test-1 ( -- ) 1000 sleep ; +: deploy-test-1 ( -- ) 1000000 sleep ; MAIN: deploy-test-1 diff --git a/basis/tools/profiler/profiler-tests.factor b/basis/tools/profiler/profiler-tests.factor index f0c71aa311..197ace74d8 100644 --- a/basis/tools/profiler/profiler-tests.factor +++ b/basis/tools/profiler/profiler-tests.factor @@ -11,7 +11,7 @@ words ; [ ] [ [ 10 [ gc ] times ] profile ] unit-test -[ ] [ [ 1000 sleep ] profile ] unit-test +[ ] [ [ 1000000 sleep ] profile ] unit-test [ ] [ profile. ] unit-test diff --git a/basis/tools/threads/threads.factor b/basis/tools/threads/threads.factor index 1b75e46e25..fc4ba1f6b2 100644 --- a/basis/tools/threads/threads.factor +++ b/basis/tools/threads/threads.factor @@ -14,8 +14,8 @@ IN: tools.threads ] with-cell [ sleep-entry>> [ - key>> millis [-] number>string write - " ms" write + key>> micros [-] number>string write + " us" write ] when* ] with-cell ; diff --git a/basis/tools/time/time-docs.factor b/basis/tools/time/time-docs.factor index fe3d709f78..d8dba04486 100644 --- a/basis/tools/time/time-docs.factor +++ b/basis/tools/time/time-docs.factor @@ -7,7 +7,7 @@ ARTICLE: "timing" "Timing code" "A lower-level word puts timings on the stack, intead of printing:" { $subsection benchmark } "You can also read the system clock and garbage collection statistics directly:" -{ $subsection millis } +{ $subsection micros } { $subsection gc-stats } { $see-also "profiling" } ; @@ -15,7 +15,7 @@ ABOUT: "timing" HELP: benchmark { $values { "quot" "a quotation" } - { "runtime" "an integer denoting milliseconds" } } + { "runtime" "the runtime in microseconds" } } { $description "Runs a quotation, measuring the total wall clock time." } { $notes "A nicer word for interactive use is " { $link time } "." } ; @@ -23,4 +23,4 @@ HELP: time { $values { "quot" "a quotation" } } { $description "Runs a quotation and then prints the total run time and some garbage collection statistics." } ; -{ benchmark millis time } related-words +{ benchmark micros time } related-words diff --git a/basis/tools/time/time.factor b/basis/tools/time/time.factor index 6873d68316..f5187230de 100644 --- a/basis/tools/time/time.factor +++ b/basis/tools/time/time.factor @@ -5,20 +5,20 @@ namespaces system sequences splitting grouping assocs strings ; IN: tools.time : benchmark ( quot -- runtime ) - millis >r call millis r> - ; inline + micros >r call micros r> - ; inline : time. ( data -- ) unclip - "==== RUNNING TIME" print nl pprint " ms" print nl + "==== RUNNING TIME" print nl pprint " us" print nl 4 cut* "==== GARBAGE COLLECTION" print nl [ 6 group { "GC count:" - "Cumulative GC time (ms):" - "Longest GC pause (ms):" - "Average GC pause (ms):" + "Cumulative GC time (us):" + "Longest GC pause (us):" + "Average GC pause (us):" "Objects copied:" "Bytes copied:" } prefix @@ -37,4 +37,4 @@ IN: tools.time ] bi* ; : time ( quot -- ) - gc-reset millis >r call gc-stats millis r> - prefix time. ; inline + gc-reset micros >r call gc-stats micros r> - prefix time. ; inline diff --git a/basis/ui/gestures/gestures-docs.factor b/basis/ui/gestures/gestures-docs.factor index 3471bd2cdb..1db0d04f43 100644 --- a/basis/ui/gestures/gestures-docs.factor +++ b/basis/ui/gestures/gestures-docs.factor @@ -147,7 +147,7 @@ HELP: hand-last-button { $var-description "Global variable. The mouse button most recently pressed." } ; HELP: hand-last-time -{ $var-description "Global variable. The timestamp of the most recent mouse button click. This timestamp has the same format as the output value of " { $link millis } "." } ; +{ $var-description "Global variable. The timestamp of the most recent mouse button click. This timestamp has the same format as the output value of " { $link micros } "." } ; HELP: hand-buttons { $var-description "Global variable. A vector of mouse buttons currently held down." } ; diff --git a/basis/ui/gestures/gestures.factor b/basis/ui/gestures/gestures.factor index 2a29d32055..e37bea538f 100644 --- a/basis/ui/gestures/gestures.factor +++ b/basis/ui/gestures/gestures.factor @@ -94,7 +94,7 @@ SYMBOL: scroll-direction { 0 0 } scroll-direction set-global SYMBOL: double-click-timeout -300 double-click-timeout set-global +300 milliseconds double-click-timeout set-global : hand-moved? ( -- ? ) hand-loc get hand-click-loc get = not ; @@ -182,7 +182,7 @@ SYMBOL: drag-timer hand-click-loc get-global swap screen-loc v- ; : multi-click-timeout? ( -- ? ) - millis hand-last-time get - double-click-timeout get <= ; + now hand-last-time get time- double-click-timeout get before=? ; : multi-click-button? ( button -- button ? ) dup hand-last-button get = ; @@ -207,7 +207,7 @@ SYMBOL: drag-timer 1 hand-click# set ] if hand-last-button set - millis hand-last-time set + now hand-last-time set ] bind ; : update-clicked ( -- ) diff --git a/basis/ui/tools/interactor/interactor-tests.factor b/basis/ui/tools/interactor/interactor-tests.factor index 37f43faa8b..628570c3e3 100644 --- a/basis/ui/tools/interactor/interactor-tests.factor +++ b/basis/ui/tools/interactor/interactor-tests.factor @@ -38,7 +38,7 @@ tools.test kernel calendar parser accessors calendar io ; [ ] [ [ "interactor" get stream-read-quot drop ] "B" spawn drop ] unit-test -[ ] [ 1000 sleep ] unit-test +[ ] [ 1 seconds sleep ] unit-test [ ] [ "interactor" get interactor-eof ] unit-test @@ -57,11 +57,11 @@ tools.test kernel calendar parser accessors calendar io ; ] in-thread ] unit-test -[ ] [ 100 sleep ] unit-test +[ ] [ 100 milliseconds sleep ] unit-test [ ] [ "interactor" get evaluate-input ] unit-test -[ ] [ 100 sleep ] unit-test +[ ] [ 100 milliseconds sleep ] unit-test [ ] [ "interactor" get interactor-eof ] unit-test @@ -80,7 +80,7 @@ tools.test kernel calendar parser accessors calendar io ; ] in-thread ] unit-test -[ ] [ 100 sleep ] unit-test +[ ] [ 100 milliseconds sleep ] unit-test [ ] [ "interactor" get evaluate-input ] unit-test diff --git a/basis/ui/tools/listener/listener-tests.factor b/basis/ui/tools/listener/listener-tests.factor index 616226a9c5..28fdef6cb7 100644 --- a/basis/ui/tools/listener/listener-tests.factor +++ b/basis/ui/tools/listener/listener-tests.factor @@ -2,7 +2,8 @@ USING: continuations documents ui.tools.interactor ui.tools.listener hashtables kernel namespaces parser sequences tools.test ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.panes vocabs words tools.test.ui slots.private -threads arrays generic threads accessors listener math ; +threads arrays generic threads accessors listener math +calendar ; IN: ui.tools.listener.tests [ f ] [ "word" source-editor command-map commands>> empty? ] unit-test @@ -47,7 +48,7 @@ IN: ui.tools.listener.tests [ ] [ "listener" get restart-listener ] unit-test - [ ] [ 1000 sleep ] unit-test + [ ] [ 1 seconds sleep ] unit-test [ ] [ "listener" get com-end ] unit-test ] with-grafted-gadget diff --git a/basis/ui/tools/search/search-tests.factor b/basis/ui/tools/search/search-tests.factor index d477274520..c8c7c6c219 100644 --- a/basis/ui/tools/search/search-tests.factor +++ b/basis/ui/tools/search/search-tests.factor @@ -1,7 +1,7 @@ USING: assocs ui.tools.search help.topics io.files io.styles kernel namespaces sequences source-files threads tools.test ui.gadgets ui.gestures vocabs accessors -vocabs.loader words tools.test.ui debugger ; +vocabs.loader words tools.test.ui debugger calendar ; IN: ui.tools.search.tests [ f ] [ @@ -14,7 +14,7 @@ IN: ui.tools.search.tests : update-live-search ( search -- seq ) dup [ - 300 sleep + 300 milliseconds sleep list>> control-value ] with-grafted-gadget ; @@ -30,7 +30,7 @@ IN: ui.tools.search.tests "" all-words t dup [ { "set-word-prop" } over field>> set-control-value - 300 sleep + 300 milliseconds sleep search-value \ set-word-prop eq? ] with-grafted-gadget ] unit-test diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index f561f3cd49..dc868154bb 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -1,10 +1,10 @@ -! Copyright (C) 2006, 2007 Slava Pestov. +! Copyright (C) 2006, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs io kernel math models namespaces make prettyprint dlists deques sequences threads sequences words debugger ui.gadgets ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render continuations init combinators -hashtables concurrency.flags sets accessors ; +hashtables concurrency.flags sets accessors calendar ; IN: ui ! Assoc mapping aliens to gadgets @@ -142,7 +142,7 @@ SYMBOL: ui-hook [ notify-queued layout-queued redraw-worlds ] assert-depth ; : ui-wait ( -- ) - 10 sleep ; + 10 milliseconds sleep ; : ui-try ( quot -- ) [ ui-error ] recover ; diff --git a/basis/unix/time/time.factor b/basis/unix/time/time.factor index c664aa3bfb..9847b09778 100644 --- a/basis/unix/time/time.factor +++ b/basis/unix/time/time.factor @@ -11,14 +11,14 @@ C-STRUCT: timespec { "time_t" "sec" } { "long" "nsec" } ; -: make-timeval ( ms -- timeval ) - 1000 /mod 1000 * +: make-timeval ( us -- timeval ) + 1000000 /mod "timeval" [ set-timeval-usec ] keep [ set-timeval-sec ] keep ; -: make-timespec ( ms -- timespec ) - 1000 /mod 1000000 * +: make-timespec ( us -- timespec ) + 1000000 /mod 1000 * "timespec" [ set-timespec-nsec ] keep [ set-timespec-sec ] keep ; diff --git a/core/alien/alien-docs.factor b/core/alien/alien-docs.factor index ce3497439a..edac8c09cc 100644 --- a/core/alien/alien-docs.factor +++ b/core/alien/alien-docs.factor @@ -281,8 +281,8 @@ $nl "Gives all Factor threads a chance to run." } } { { - { $code "void factor_sleep(long ms)" } - "Gives all Factor threads a chance to run for " { $snippet "ms" } " milliseconds." + { $code "void factor_sleep(long us)" } + "Gives all Factor threads a chance to run for " { $snippet "us" } " microseconds." } } } ; diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 24faf81662..f0aefa53cb 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -443,7 +443,7 @@ tuple { "exit" "system" } { "data-room" "memory" } { "code-room" "memory" } - { "millis" "system" } + { "micros" "system" } { "modify-code-heap" "compiler.units" } { "dlopen" "alien" } { "dlsym" "alien" } diff --git a/core/io/backend/backend-docs.factor b/core/io/backend/backend-docs.factor index 48b49ed32b..e129a9b0bc 100644 --- a/core/io/backend/backend-docs.factor +++ b/core/io/backend/backend-docs.factor @@ -2,8 +2,8 @@ USING: help.markup help.syntax io io.backend strings byte-arrays ; HELP: io-multiplex -{ $values { "ms" "a non-negative integer" } } -{ $contract "Waits up to " { $snippet "ms" } " milliseconds for pending I/O requests to complete." } ; +{ $values { "us" "a non-negative integer" } } +{ $contract "Waits up to " { $snippet "us" } " microseconds for pending I/O requests to complete." } ; HELP: init-io { $contract "Initializes the I/O system. Called on startup." } ; diff --git a/core/io/streams/c/c.factor b/core/io/streams/c/c.factor index 1e12d7e956..287ee3ad95 100644 --- a/core/io/streams/c/c.factor +++ b/core/io/streams/c/c.factor @@ -67,7 +67,7 @@ M: c-io-backend init-io ; M: c-io-backend (init-stdio) init-c-stdio ; -M: c-io-backend io-multiplex 60 60 * 1000 * or (sleep) ; +M: c-io-backend io-multiplex 60 60 * 1000 * 1000 * or (sleep) ; M: c-io-backend (file-reader) "rb" fopen ; diff --git a/core/system/system-docs.factor b/core/system/system-docs.factor index acd42b094f..3adf82af7f 100644 --- a/core/system/system-docs.factor +++ b/core/system/system-docs.factor @@ -11,7 +11,7 @@ ARTICLE: "system" "System interface" { $subsection vm } { $subsection image } "Getting the current time:" -{ $subsection millis } +{ $subsection micros } "Exiting the Factor VM:" { $subsection exit } ; @@ -64,8 +64,13 @@ HELP: exit ( n -- ) { $values { "n" "an integer exit code" } } { $description "Exits the Factor process." } ; -HELP: millis ( -- n ) -{ $values { "n" integer } } +HELP: micros ( -- us ) +{ $values { "us" integer } } +{ $description "Outputs the number of microseconds ellapsed since midnight January 1, 1970." } +{ $notes "This is a low-level word. The " { $vocab-link "calendar" } " vocabulary provides features for date/time arithmetic and formatting." } ; + +HELP: millis ( -- ms ) +{ $values { "us" integer } } { $description "Outputs the number of milliseconds ellapsed since midnight January 1, 1970." } { $notes "This is a low-level word. The " { $vocab-link "calendar" } " vocabulary provides features for date/time arithmetic and formatting." } ; diff --git a/core/system/system.factor b/core/system/system.factor index 66662a23e1..2d8ed1b657 100644 --- a/core/system/system.factor +++ b/core/system/system.factor @@ -65,3 +65,5 @@ PRIVATE> ] "system" add-init-hook : embedded? ( -- ? ) 15 getenv ; + +: millis ( -- ms ) micros 1000 /i ; diff --git a/extra/crypto/timing/timing.factor b/extra/crypto/timing/timing.factor index a17d65d90b..8fdb807c6a 100644 --- a/extra/crypto/timing/timing.factor +++ b/extra/crypto/timing/timing.factor @@ -1,6 +1,6 @@ -USING: kernel math threads system ; +USING: kernel math threads system calendar ; IN: crypto.timing : with-timing ( quot n -- ) #! force the quotation to execute in, at minimum, n milliseconds - millis 2slip millis - + sleep ; inline + millis 2slip millis - + milliseconds sleep ; inline diff --git a/extra/jamshred/jamshred.factor b/extra/jamshred/jamshred.factor index 2357742fde..d0b74417d1 100755 --- a/extra/jamshred/jamshred.factor +++ b/extra/jamshred/jamshred.factor @@ -23,7 +23,7 @@ M: jamshred-gadget draw-gadget* ( gadget -- ) ] [ [ jamshred>> jamshred-update ] [ relayout-1 ] - [ 10 sleep yield jamshred-loop ] tri + [ 10 milliseconds sleep yield jamshred-loop ] tri ] if ; : fullscreen ( gadget -- ) diff --git a/extra/mason/test/test.factor b/extra/mason/test/test.factor index 0206df7db9..3de1fa643f 100644 --- a/extra/mason/test/test.factor +++ b/extra/mason/test/test.factor @@ -40,14 +40,17 @@ M: method-body word-vocabulary "method-generic" word-prop word-vocabulary ; : do-benchmarks ( -- ) run-benchmarks benchmarks-file to-file ; +: benchmark-ms ( quot -- ms ) + benchmark 1000 /i ; inline + : do-all ( -- ) ".." [ bootstrap-time get boot-time-file to-file - [ do-load do-compile-errors ] benchmark load-time-file to-file - [ generate-help ] benchmark html-help-time-file to-file - [ do-tests ] benchmark test-time-file to-file - [ do-help-lint ] benchmark help-lint-time-file to-file - [ do-benchmarks ] benchmark benchmark-time-file to-file + [ do-load do-compile-errors ] benchmark-ms load-time-file to-file + [ generate-help ] html-help-time-file to-file + [ do-tests ] benchmark-ms test-time-file to-file + [ do-help-lint ] benchmark-ms help-lint-time-file to-file + [ do-benchmarks ] benchmark-ms benchmark-time-file to-file ] with-directory ; MAIN: do-all \ No newline at end of file diff --git a/extra/nehe/4/4.factor b/extra/nehe/4/4.factor index 4c1545b4ae..10217c93cb 100644 --- a/extra/nehe/4/4.factor +++ b/extra/nehe/4/4.factor @@ -1,12 +1,13 @@ USING: arrays kernel math opengl opengl.gl opengl.glu -opengl.demo-support ui ui.gadgets ui.render threads accessors ; +opengl.demo-support ui ui.gadgets ui.render threads accessors +calendar ; IN: nehe.4 TUPLE: nehe4-gadget < gadget rtri rquad thread quit? ; : width 256 ; : height 256 ; -: redraw-interval 10 ; +: redraw-interval 10 milliseconds ; : ( -- gadget ) nehe4-gadget new-gadget diff --git a/extra/nehe/5/5.factor b/extra/nehe/5/5.factor index 59170ff964..2c9b51c63f 100755 --- a/extra/nehe/5/5.factor +++ b/extra/nehe/5/5.factor @@ -1,11 +1,12 @@ USING: arrays kernel math opengl opengl.gl opengl.glu -opengl.demo-support ui ui.gadgets ui.render threads accessors ; +opengl.demo-support ui ui.gadgets ui.render threads accessors +calendar ; IN: nehe.5 TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ; : width 256 ; : height 256 ; -: redraw-interval 10 ; +: redraw-interval 10 milliseconds ; : ( -- gadget ) nehe5-gadget new-gadget diff --git a/extra/openal/example/example.factor b/extra/openal/example/example.factor index ebdb6da5ce..ae0b50afff 100644 --- a/extra/openal/example/example.factor +++ b/extra/openal/example/example.factor @@ -2,17 +2,17 @@ ! See http://factorcode.org/license.txt for BSD license. ! IN: openal.example -USING: openal kernel alien threads sequences ; +USING: openal kernel alien threads sequences calendar ; : play-hello ( -- ) init-openal 1 gen-sources first dup AL_BUFFER alutCreateBufferHelloWorld set-source-param source-play - 1000 sleep ; + 1000 milliseconds sleep ; : (play-file) ( source -- ) - 100 sleep + 100 milliseconds sleep dup source-playing? [ (play-file) ] [ drop ] if ; : play-file ( filename -- ) diff --git a/vm/data_gc.c b/vm/data_gc.c index 9f8ffb625e..23836c560c 100755 --- a/vm/data_gc.c +++ b/vm/data_gc.c @@ -793,7 +793,7 @@ void garbage_collection(CELL gen, return; } - s64 start = current_millis(); + s64 start = current_micros(); performing_gc = true; growing_data_heap = growing_data_heap_; @@ -860,7 +860,7 @@ void garbage_collection(CELL gen, while(scan < newspace->here) scan = collect_next(scan); - CELL gc_elapsed = (current_millis() - start); + CELL gc_elapsed = (current_micros() - start); end_gc(gc_elapsed); @@ -887,14 +887,14 @@ void primitive_gc_stats(void) GROWABLE_ARRAY(stats); CELL i; - CELL total_gc_time = 0; + u64 total_gc_time = 0; for(i = 0; i < MAX_GEN_COUNT; i++) { F_GC_STATS *s = &gc_stats[i]; GROWABLE_ARRAY_ADD(stats,allot_cell(s->collections)); - GROWABLE_ARRAY_ADD(stats,allot_cell(s->gc_time)); - GROWABLE_ARRAY_ADD(stats,allot_cell(s->max_gc_time)); + GROWABLE_ARRAY_ADD(stats,tag_bignum(long_long_to_bignum(s->gc_time))); + GROWABLE_ARRAY_ADD(stats,tag_bignum(long_long_to_bignum(s->max_gc_time))); GROWABLE_ARRAY_ADD(stats,allot_cell(s->collections == 0 ? 0 : s->gc_time / s->collections)); GROWABLE_ARRAY_ADD(stats,allot_cell(s->object_count)); GROWABLE_ARRAY_ADD(stats,tag_bignum(long_long_to_bignum(s->bytes_copied))); @@ -902,7 +902,7 @@ void primitive_gc_stats(void) total_gc_time += s->gc_time; } - GROWABLE_ARRAY_ADD(stats,allot_cell(total_gc_time)); + GROWABLE_ARRAY_ADD(stats,tag_bignum(long_long_to_bignum(total_gc_time))); GROWABLE_ARRAY_ADD(stats,tag_bignum(long_long_to_bignum(cards_scanned))); GROWABLE_ARRAY_ADD(stats,tag_bignum(long_long_to_bignum(decks_scanned))); GROWABLE_ARRAY_ADD(stats,allot_cell(code_heap_scans)); diff --git a/vm/data_gc.h b/vm/data_gc.h index 0d63cc6bfe..a407ed761c 100755 --- a/vm/data_gc.h +++ b/vm/data_gc.h @@ -161,8 +161,8 @@ void init_data_heap(CELL gens, /* statistics */ typedef struct { CELL collections; - CELL gc_time; - CELL max_gc_time; + u64 gc_time; + u64 max_gc_time; CELL object_count; u64 bytes_copied; } F_GC_STATS; diff --git a/vm/factor.c b/vm/factor.c index 8e0aadb4fd..f198370ebe 100755 --- a/vm/factor.c +++ b/vm/factor.c @@ -91,7 +91,7 @@ void init_factor(F_PARAMETERS *p) if(p->image == NULL) p->image = default_image_path(); - srand(current_millis()); + srand(current_micros()); init_ffi(); init_stacks(p->ds_size,p->rs_size); load_image(p); @@ -216,8 +216,8 @@ void factor_yield(void) callback(); } -void factor_sleep(long ms) +void factor_sleep(long us) { void (*callback)() = alien_offset(userenv[SLEEP_CALLBACK_ENV]); - callback(ms); + callback(us); } diff --git a/vm/os-unix.c b/vm/os-unix.c index c11962f6e1..952d2683cf 100755 --- a/vm/os-unix.c +++ b/vm/os-unix.c @@ -16,16 +16,16 @@ void start_thread(void *(*start_routine)(void *)) static void *null_dll; -s64 current_millis(void) +s64 current_micros(void) { struct timeval t; gettimeofday(&t,NULL); - return (s64)t.tv_sec * 1000 + t.tv_usec / 1000; + return (s64)t.tv_sec * 1000000 + t.tv_usec; } -void sleep_millis(CELL msec) +void sleep_micros(CELL usec) { - usleep(msec * 1000); + usleep(usec); } void init_ffi(void) diff --git a/vm/os-unix.h b/vm/os-unix.h index 2c5cc20e8d..97b1b39129 100755 --- a/vm/os-unix.h +++ b/vm/os-unix.h @@ -50,7 +50,7 @@ void unix_init_signals(void); void signal_handler(int signal, siginfo_t* siginfo, void* uap); void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap); -s64 current_millis(void); -void sleep_millis(CELL msec); +s64 current_micros(void); +void sleep_micros(CELL usec); void open_console(void); diff --git a/vm/os-windows-ce.c b/vm/os-windows-ce.c index 02b51b82ed..621198ff7d 100755 --- a/vm/os-windows-ce.c +++ b/vm/os-windows-ce.c @@ -1,13 +1,13 @@ #include "master.h" -s64 current_millis(void) +s64 current_micros(void) { SYSTEMTIME st; FILETIME ft; GetSystemTime(&st); SystemTimeToFileTime(&st, &ft); return (((s64)ft.dwLowDateTime - | (s64)ft.dwHighDateTime<<32) - EPOCH_OFFSET) / 10000; + | (s64)ft.dwHighDateTime<<32) - EPOCH_OFFSET) / 10; } char *strerror(int err) diff --git a/vm/os-windows-ce.h b/vm/os-windows-ce.h index f1d6df6f3d..a2be5fe475 100755 --- a/vm/os-windows-ce.h +++ b/vm/os-windows-ce.h @@ -22,6 +22,6 @@ char *getenv(char *name); #define snprintf _snprintf #define snwprintf _snwprintf -s64 current_millis(void); +s64 current_micros(void); void c_to_factor_toplevel(CELL quot); void open_console(void); diff --git a/vm/os-windows-nt.c b/vm/os-windows-nt.c index e22ea1446b..f982abfb1b 100755 --- a/vm/os-windows-nt.c +++ b/vm/os-windows-nt.c @@ -1,11 +1,11 @@ #include "master.h" -s64 current_millis(void) +s64 current_micros(void) { FILETIME t; GetSystemTimeAsFileTime(&t); return (((s64)t.dwLowDateTime | (s64)t.dwHighDateTime<<32) - - EPOCH_OFFSET) / 10000; + - EPOCH_OFFSET) / 10; } long exception_handler(PEXCEPTION_POINTERS pe) diff --git a/vm/os-windows.c b/vm/os-windows.c index 7d486bb86b..0aeb77741b 100755 --- a/vm/os-windows.c +++ b/vm/os-windows.c @@ -166,7 +166,7 @@ long getpagesize(void) return g_pagesize; } -void sleep_millis(DWORD msec) +void sleep_micros(DWORD usec) { - Sleep(msec); + Sleep(msec / 1000); } diff --git a/vm/os-windows.h b/vm/os-windows.h index 8d0f15648a..b12d677af2 100755 --- a/vm/os-windows.h +++ b/vm/os-windows.h @@ -49,7 +49,7 @@ void ffi_dlopen(F_DLL *dll); void *ffi_dlsym(F_DLL *dll, F_SYMBOL *symbol); void ffi_dlclose(F_DLL *dll); -void sleep_millis(DWORD msec); +void sleep_micros(DWORD msec); INLINE void init_signals(void) {} INLINE void early_init(void) {} @@ -57,5 +57,5 @@ const F_CHAR *vm_executable_path(void); const F_CHAR *default_image_path(void); long getpagesize (void); -s64 current_millis(void); +s64 current_micros(void); diff --git a/vm/primitives.c b/vm/primitives.c index 69e77f81ed..5adb135c82 100755 --- a/vm/primitives.c +++ b/vm/primitives.c @@ -68,7 +68,7 @@ void *primitives[] = { primitive_exit, primitive_data_room, primitive_code_room, - primitive_millis, + primitive_micros, primitive_modify_code_heap, primitive_dlopen, primitive_dlsym, diff --git a/vm/run.c b/vm/run.c index c7d93d29c8..b8c8d78ba1 100755 --- a/vm/run.c +++ b/vm/run.c @@ -153,14 +153,14 @@ void primitive_exit(void) exit(to_fixnum(dpop())); } -void primitive_millis(void) +void primitive_micros(void) { - box_unsigned_8(current_millis()); + box_unsigned_8(current_micros()); } void primitive_sleep(void) { - sleep_millis(to_cell(dpop())); + sleep_micros(to_cell(dpop())); } void primitive_set_slot(void) diff --git a/vm/run.h b/vm/run.h index 2dbbcc8c06..378b93e8bd 100755 --- a/vm/run.h +++ b/vm/run.h @@ -236,7 +236,7 @@ void primitive_os_envs(void); void primitive_set_os_env(void); void primitive_unset_os_env(void); void primitive_set_os_envs(void); -void primitive_millis(void); +void primitive_micros(void); void primitive_sleep(void); void primitive_set_slot(void);