]> gitweb.factorcode.org Git - factor.git/commitdiff
Remove system_micros from vm, implement gmt hook on windows
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 17 Jun 2010 04:39:16 +0000 (23:39 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 17 Jun 2010 04:39:16 +0000 (23:39 -0500)
13 files changed:
basis/calendar/calendar.factor
basis/calendar/windows/windows.factor
core/bootstrap/primitives.factor
extra/time/windows/windows.factor
vm/os-unix.cpp
vm/os-unix.hpp
vm/os-windows-ce.cpp
vm/os-windows-ce.hpp
vm/os-windows-nt.cpp
vm/os-windows.hpp
vm/primitives.hpp
vm/run.cpp
vm/vm.hpp

index 8758b8198b2df520b80631b02bec4a7205169a3e..d9a6dfb3702a37eff06c064ae5eb5f98b0921ba4 100644 (file)
@@ -7,6 +7,8 @@ IN: calendar
 
 HOOK: gmt-offset os ( -- hours minutes seconds )
 
+HOOK: gmt os ( -- timestamp )
+
 TUPLE: duration
     { year real }
     { month real }
@@ -371,10 +373,6 @@ M: duration time-
 : timestamp>micros ( timestamp -- n )
     unix-1970 (time-) 1000000 * >integer ;
 
-: gmt ( -- timestamp )
-    #! GMT time, right now
-    unix-1970 system-micros microseconds time+ ;
-
 : now ( -- timestamp ) gmt >local-time ;
 : hence ( duration -- timestamp ) now swap time+ ;
 : ago ( duration -- timestamp ) now swap time- ;
index abec2dcf9fd59a995e3f7d540805f40ada459cd3..80253ea91b77f1f6b28830c20dc8a5bd67a3dcb8 100644 (file)
@@ -3,15 +3,6 @@ windows.kernel32 kernel math combinators windows.errors
 accessors classes.struct calendar.format math.functions ;
 IN: calendar.windows
 
-M: windows gmt-offset ( -- hours minutes seconds )
-    TIME_ZONE_INFORMATION <struct>
-    dup GetTimeZoneInformation {
-        { TIME_ZONE_ID_INVALID [ win32-error-string throw ] }
-        { TIME_ZONE_ID_UNKNOWN [ Bias>> ] }
-        { TIME_ZONE_ID_STANDARD [ Bias>> ] }
-        { TIME_ZONE_ID_DAYLIGHT [ [ Bias>> ] [ DaylightBias>> ] bi + ] }
-    } case neg 60 /mod 0 ;
-
 : timestamp>SYSTEMTIME ( timestamp -- SYSTEMTIME )
     {
         [ year>> ]
@@ -34,5 +25,17 @@ M: windows gmt-offset ( -- hours minutes seconds )
         [ wDay>> ]
         [ wHour>> ]
         [ wMinute>> ]
-        [ [ wSecond>> ] [ wMilliseconds>> 1000 /f ] bi + ]
-    } cleave gmt-offset-duration <timestamp> ;
+        [ [ wSecond>> ] [ wMilliseconds>> 1000 / ] bi + ]
+    } cleave instant <timestamp> ;
+
+M: windows gmt-offset ( -- hours minutes seconds )
+    TIME_ZONE_INFORMATION <struct>
+    dup GetTimeZoneInformation {
+        { TIME_ZONE_ID_INVALID [ win32-error-string throw ] }
+        { TIME_ZONE_ID_UNKNOWN [ Bias>> ] }
+        { TIME_ZONE_ID_STANDARD [ Bias>> ] }
+        { TIME_ZONE_ID_DAYLIGHT [ [ Bias>> ] [ DaylightBias>> ] bi + ] }
+    } case neg 60 /mod 0 ;
+
+M: windows gmt
+    SYSTEMTIME <struct> [ GetSystemTime ] keep SYSTEMTIME>timestamp ;
index c00199e9b3dbecc4da406fc929db39a00704cb33..07f6e9ef9ad1694bb00167282e0194e3c6e9d8fd 100644 (file)
@@ -536,7 +536,6 @@ tuple
     { "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" (( ch n string -- )) }
     { "(exit)" "system" "primitive_exit" (( n -- * )) }
     { "nano-count" "system" "primitive_nano_count" (( -- ns )) }
-    { "system-micros" "system" "primitive_system_micros" (( -- us )) }
     { "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) }
     { "callstack-for" "threads.private" "primitive_callstack_for" (( context -- array )) }
     { "context-object-for" "threads.private" "primitive_context_object_for" (( n context -- obj )) }
index 1f2259d1375011c0cefd933282c4ea91b2beaf8d..e5d7f918d9fac2c9b696b0edcb046e73a6464dc0 100644 (file)
@@ -4,9 +4,6 @@ USING: calendar.windows system time windows.errors
 windows.kernel32 kernel classes.struct calendar ;
 IN: time.windows
 
-: windows-system-time ( -- SYSTEMTIME )
-    SYSTEMTIME <struct> [ GetSystemTime ] keep ;
-
 M: windows set-time
     >gmt
     timestamp>SYSTEMTIME SetSystemTime win32-error=0/f ;
index 034dfcbf5f2f7643e93615c0177bc8eb9adad727..e95b84f51a93a9a4283c464e61f2bb2bf9f1511e 100644 (file)
@@ -19,13 +19,6 @@ THREADHANDLE start_thread(void *(*start_routine)(void *),void *args)
 
 static void *null_dll;
 
-u64 system_micros()
-{
-       struct timeval t;
-       gettimeofday(&t,NULL);
-       return (u64)t.tv_sec * 1000000 + t.tv_usec;
-}
-
 void sleep_nanos(u64 nsec)
 {
        timespec ts;
index 3673c4e12114b5f09f7b0b78e4fd09d048f2c8c0..54e9d068ef42177963417dbcc3a20d8cac92376a 100644 (file)
@@ -42,7 +42,6 @@ inline static THREADHANDLE thread_id() { return pthread_self(); }
 void signal_handler(int signal, siginfo_t* siginfo, void* uap);
 void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap);
 
-u64 system_micros();
 u64 nano_count();
 void sleep_nanos(u64 nsec);
 void open_console();
index a57db667c421b76c549ad604b0681cb735c59e70..65e8ef5b09f2f876ae2586fb3927a107212c0b91 100644 (file)
@@ -3,16 +3,6 @@
 namespace factor
 {
 
-u64 system_micros()
-{
-       SYSTEMTIME st;
-       FILETIME ft;
-       GetSystemTime(&st);
-       SystemTimeToFileTime(&st, &ft);
-       return (((s64)ft.dwLowDateTime
-               | (s64)ft.dwHighDateTime<<32) - EPOCH_OFFSET) / 10;
-}
-
 char *strerror(int err)
 {
        /* strerror() is not defined on WinCE */
index 02de1cd4a8c7a097253592892a966d3d1e831036..892fc88be9870937490a508c3ae2a3691f86ca42 100755 (executable)
@@ -21,7 +21,6 @@ char *getenv(char *name);
 #define snprintf _snprintf
 #define snwprintf _snwprintf
 
-u64 system_micros();
 void c_to_factor_toplevel(cell quot);
 void open_console();
 
index 97cd2146afe50b54b5dc3910ea65a36574a521dc..7fdb882122b0d31368321de7619d3d15a9ca188e 100755 (executable)
@@ -8,14 +8,6 @@ THREADHANDLE start_thread(void *(*start_routine)(void *), void *args)
        return (void *)CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0);
 }
 
-u64 system_micros()
-{
-       FILETIME t;
-       GetSystemTimeAsFileTime(&t);
-       return (((u64)t.dwLowDateTime | (u64)t.dwHighDateTime<<32)
-               - EPOCH_OFFSET) / 10;
-}
-
 u64 nano_count()
 {
        static double scale_factor;
index 020a506038dc4d001531867c6b6c9bb62f6af0c8..ad8a9907a7645c1e4ebde78fe03b1f1c46bc666c 100755 (executable)
@@ -45,7 +45,6 @@ typedef wchar_t vm_char;
 
 inline static void early_init() {}
 
-u64 system_micros();
 u64 nano_count();
 void sleep_nanos(u64 nsec);
 long getpagesize();
index 9cda1db9a8d68e919de8397c1d485848f52a6399..5df73f5fac2066988e302667992f69917621f28f 100644 (file)
@@ -125,7 +125,6 @@ namespace factor
        _(special_object) \
        _(string) \
        _(strip_stack_traces) \
-       _(system_micros) \
        _(tuple) \
        _(tuple_boa) \
        _(unimplemented) \
index 6c8a8452e70d26c185ccb097901893ef20ae77c8..605fd9b7255d6d411044c4ff930f163c0a77033a 100755 (executable)
@@ -8,11 +8,6 @@ void factor_vm::primitive_exit()
        exit((int)to_fixnum(ctx->pop()));
 }
 
-void factor_vm::primitive_system_micros()
-{
-       ctx->push(from_unsigned_8(system_micros()));
-}
-
 void factor_vm::primitive_nano_count()
 {
        u64 nanos = nano_count();
index 147647b5283767fc70795b389ac9028f8ba1744a..40b3df5ecf1bb43bdb592b12f59d23b41032b284 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -146,7 +146,6 @@ struct factor_vm
 
        // run
        void primitive_exit();
-       void primitive_system_micros();
        void primitive_nano_count();
        void primitive_sleep();
        void primitive_set_slot();