diff --git a/basis/calendar/unix/unix.factor b/basis/calendar/unix/unix.factor index 40475b4d40..a1e83cc1c1 100644 --- a/basis/calendar/unix/unix.factor +++ b/basis/calendar/unix/unix.factor @@ -29,6 +29,12 @@ IN: calendar.unix M: unix gmt-offset ( -- hours minutes seconds ) get-time gmtoff>> 3600 /mod 60 /mod ; +: current-timeval ( -- timeval ) + timeval f [ gettimeofday io-error ] 2keep drop ; + +: system-micros ( -- n ) + current-timeval + [ sec>> 1,000,000 * ] [ usec>> ] bi + ; + M: unix gmt - timeval f [ gettimeofday io-error ] 2keep drop - timeval>unix-time ; + current-timeval timeval>unix-time ; diff --git a/basis/core-foundation/run-loop/run-loop.factor b/basis/core-foundation/run-loop/run-loop.factor index 793efefbe8..5396b83dca 100644 --- a/basis/core-foundation/run-loop/run-loop.factor +++ b/basis/core-foundation/run-loop/run-loop.factor @@ -1,10 +1,12 @@ ! Copyright (C) 2008, 2010 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.c-types alien.syntax kernel math -namespaces sequences destructors combinators threads heaps -deques calendar system core-foundation core-foundation.strings -core-foundation.file-descriptors core-foundation.timers -core-foundation.time ; +USING: accessors alien alien.c-types alien.syntax calendar +classes.struct combinators core-foundation +core-foundation.file-descriptors core-foundation.strings +core-foundation.time core-foundation.timers deques destructors +heaps kernel math namespaces sequences system threads unix +unix.time ; +FROM: calendar.unix => system-micros ; IN: core-foundation.run-loop CONSTANT: kCFRunLoopRunFinished 1 diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index a652c500ba..0721e61a2a 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -459,7 +459,6 @@ M: bad-executable summary \ special-object { fixnum } { object } define-primitive \ special-object make-flushable \ string-nth-fast { fixnum string } { fixnum } define-primitive \ string-nth-fast make-flushable \ strip-stack-traces { } { } define-primitive -\ system-micros { } { integer } define-primitive \ system-micros make-flushable \ tag { object } { fixnum } define-primitive \ tag make-foldable \ unimplemented { } { } define-primitive \ word-code { word } { integer integer } define-primitive \ word-code make-flushable diff --git a/core/system/system-docs.factor b/core/system/system-docs.factor index 8ef3b3e42a..b14cb90a68 100644 --- a/core/system/system-docs.factor +++ b/core/system/system-docs.factor @@ -14,10 +14,6 @@ ARTICLE: "system" "System interface" vm image } -"Getting the current time:" -{ $subsections - system-micros -} "Getting a monotonically increasing nanosecond count:" { $subsections nano-count } "Exiting the Factor VM:" @@ -78,15 +74,10 @@ HELP: exit ( n -- ) { $values { "n" "an integer exit code" } } { $description "Exits the Factor process." } ; -HELP: system-micros ( -- us ) -{ $values { "us" integer } } -{ $description "Outputs the number of microseconds elapsed 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. For timing code, use " { $link nano-count } "." } ; - HELP: nano-count ( -- ns ) { $values { "ns" integer } } { $description "Outputs a monotonically increasing count of nanoseconds elapsed since an arbitrary starting time. The difference of two calls to this word allows timing. This word is unaffected by system clock changes." } -{ $notes "This is a low-level word. The " { $vocab-link "tools.time" } " vocabulary defines words to time code execution time. For system time, use " { $link system-micros } "." } ; +{ $notes "This is a low-level word. The " { $vocab-link "tools.time" } " vocabulary defines words to time code execution time." } ; HELP: image { $values { "path" "a pathname string" } }