Remove system_micros from vm, implement gmt hook on windows
parent
570801ff3d
commit
e8d528ad93
|
|
@ -7,6 +7,8 @@ IN: calendar
|
||||||
|
|
||||||
HOOK: gmt-offset os ( -- hours minutes seconds )
|
HOOK: gmt-offset os ( -- hours minutes seconds )
|
||||||
|
|
||||||
|
HOOK: gmt os ( -- timestamp )
|
||||||
|
|
||||||
TUPLE: duration
|
TUPLE: duration
|
||||||
{ year real }
|
{ year real }
|
||||||
{ month real }
|
{ month real }
|
||||||
|
|
@ -371,10 +373,6 @@ M: duration time-
|
||||||
: timestamp>micros ( timestamp -- n )
|
: timestamp>micros ( timestamp -- n )
|
||||||
unix-1970 (time-) 1000000 * >integer ;
|
unix-1970 (time-) 1000000 * >integer ;
|
||||||
|
|
||||||
: gmt ( -- timestamp )
|
|
||||||
#! GMT time, right now
|
|
||||||
unix-1970 system-micros microseconds time+ ;
|
|
||||||
|
|
||||||
: now ( -- timestamp ) gmt >local-time ;
|
: now ( -- timestamp ) gmt >local-time ;
|
||||||
: hence ( duration -- timestamp ) now swap time+ ;
|
: hence ( duration -- timestamp ) now swap time+ ;
|
||||||
: ago ( duration -- timestamp ) now swap time- ;
|
: ago ( duration -- timestamp ) now swap time- ;
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,6 @@ windows.kernel32 kernel math combinators windows.errors
|
||||||
accessors classes.struct calendar.format math.functions ;
|
accessors classes.struct calendar.format math.functions ;
|
||||||
IN: calendar.windows
|
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 )
|
: timestamp>SYSTEMTIME ( timestamp -- SYSTEMTIME )
|
||||||
{
|
{
|
||||||
[ year>> ]
|
[ year>> ]
|
||||||
|
|
@ -34,5 +25,17 @@ M: windows gmt-offset ( -- hours minutes seconds )
|
||||||
[ wDay>> ]
|
[ wDay>> ]
|
||||||
[ wHour>> ]
|
[ wHour>> ]
|
||||||
[ wMinute>> ]
|
[ wMinute>> ]
|
||||||
[ [ wSecond>> ] [ wMilliseconds>> 1000 /f ] bi + ]
|
[ [ wSecond>> ] [ wMilliseconds>> 1000 / ] bi + ]
|
||||||
} cleave gmt-offset-duration <timestamp> ;
|
} 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 ;
|
||||||
|
|
|
||||||
|
|
@ -536,7 +536,6 @@ tuple
|
||||||
{ "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" (( ch n string -- )) }
|
{ "set-string-nth-fast" "strings.private" "primitive_set_string_nth_fast" (( ch n string -- )) }
|
||||||
{ "(exit)" "system" "primitive_exit" (( n -- * )) }
|
{ "(exit)" "system" "primitive_exit" (( n -- * )) }
|
||||||
{ "nano-count" "system" "primitive_nano_count" (( -- ns )) }
|
{ "nano-count" "system" "primitive_nano_count" (( -- ns )) }
|
||||||
{ "system-micros" "system" "primitive_system_micros" (( -- us )) }
|
|
||||||
{ "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) }
|
{ "(sleep)" "threads.private" "primitive_sleep" (( nanos -- )) }
|
||||||
{ "callstack-for" "threads.private" "primitive_callstack_for" (( context -- array )) }
|
{ "callstack-for" "threads.private" "primitive_callstack_for" (( context -- array )) }
|
||||||
{ "context-object-for" "threads.private" "primitive_context_object_for" (( n context -- obj )) }
|
{ "context-object-for" "threads.private" "primitive_context_object_for" (( n context -- obj )) }
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@ USING: calendar.windows system time windows.errors
|
||||||
windows.kernel32 kernel classes.struct calendar ;
|
windows.kernel32 kernel classes.struct calendar ;
|
||||||
IN: time.windows
|
IN: time.windows
|
||||||
|
|
||||||
: windows-system-time ( -- SYSTEMTIME )
|
|
||||||
SYSTEMTIME <struct> [ GetSystemTime ] keep ;
|
|
||||||
|
|
||||||
M: windows set-time
|
M: windows set-time
|
||||||
>gmt
|
>gmt
|
||||||
timestamp>SYSTEMTIME SetSystemTime win32-error=0/f ;
|
timestamp>SYSTEMTIME SetSystemTime win32-error=0/f ;
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,6 @@ THREADHANDLE start_thread(void *(*start_routine)(void *),void *args)
|
||||||
|
|
||||||
static void *null_dll;
|
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)
|
void sleep_nanos(u64 nsec)
|
||||||
{
|
{
|
||||||
timespec ts;
|
timespec ts;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ inline static THREADHANDLE thread_id() { return pthread_self(); }
|
||||||
void signal_handler(int signal, siginfo_t* siginfo, void* uap);
|
void signal_handler(int signal, siginfo_t* siginfo, void* uap);
|
||||||
void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap);
|
void dump_stack_signal(int signal, siginfo_t* siginfo, void* uap);
|
||||||
|
|
||||||
u64 system_micros();
|
|
||||||
u64 nano_count();
|
u64 nano_count();
|
||||||
void sleep_nanos(u64 nsec);
|
void sleep_nanos(u64 nsec);
|
||||||
void open_console();
|
void open_console();
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,6 @@
|
||||||
namespace factor
|
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)
|
char *strerror(int err)
|
||||||
{
|
{
|
||||||
/* strerror() is not defined on WinCE */
|
/* strerror() is not defined on WinCE */
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ char *getenv(char *name);
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define snwprintf _snwprintf
|
#define snwprintf _snwprintf
|
||||||
|
|
||||||
u64 system_micros();
|
|
||||||
void c_to_factor_toplevel(cell quot);
|
void c_to_factor_toplevel(cell quot);
|
||||||
void open_console();
|
void open_console();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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()
|
u64 nano_count()
|
||||||
{
|
{
|
||||||
static double scale_factor;
|
static double scale_factor;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ typedef wchar_t vm_char;
|
||||||
|
|
||||||
inline static void early_init() {}
|
inline static void early_init() {}
|
||||||
|
|
||||||
u64 system_micros();
|
|
||||||
u64 nano_count();
|
u64 nano_count();
|
||||||
void sleep_nanos(u64 nsec);
|
void sleep_nanos(u64 nsec);
|
||||||
long getpagesize();
|
long getpagesize();
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,6 @@ namespace factor
|
||||||
_(special_object) \
|
_(special_object) \
|
||||||
_(string) \
|
_(string) \
|
||||||
_(strip_stack_traces) \
|
_(strip_stack_traces) \
|
||||||
_(system_micros) \
|
|
||||||
_(tuple) \
|
_(tuple) \
|
||||||
_(tuple_boa) \
|
_(tuple_boa) \
|
||||||
_(unimplemented) \
|
_(unimplemented) \
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,6 @@ void factor_vm::primitive_exit()
|
||||||
exit((int)to_fixnum(ctx->pop()));
|
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()
|
void factor_vm::primitive_nano_count()
|
||||||
{
|
{
|
||||||
u64 nanos = nano_count();
|
u64 nanos = nano_count();
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,6 @@ struct factor_vm
|
||||||
|
|
||||||
// run
|
// run
|
||||||
void primitive_exit();
|
void primitive_exit();
|
||||||
void primitive_system_micros();
|
|
||||||
void primitive_nano_count();
|
void primitive_nano_count();
|
||||||
void primitive_sleep();
|
void primitive_sleep();
|
||||||
void primitive_set_slot();
|
void primitive_set_slot();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue