diff --git a/basis/windows/kernel32/kernel32.factor b/basis/windows/kernel32/kernel32.factor index 54d3fe6f4d..80f50ef2b0 100755 --- a/basis/windows/kernel32/kernel32.factor +++ b/basis/windows/kernel32/kernel32.factor @@ -1622,8 +1622,8 @@ FUNCTION: HANDLE OpenProcess ( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD ! FUNCTION: QueryDosDeviceW ! FUNCTION: QueryInformationJobObject ! FUNCTION: QueryMemoryResourceNotification -! FUNCTION: QueryPerformanceCounter -! FUNCTION: QueryPerformanceFrequency +FUNCTION: BOOL QueryPerformanceCounter ( LARGE_INTEGER* lpPerformanceCount ) ; +FUNCTION: BOOL QueryPerformanceFrequency ( LARGE_INTEGER* lpFrequency ) ; ! FUNCTION: QueryWin31IniFilesMappedToRegistry ! FUNCTION: QueueUserAPC ! FUNCTION: QueueUserWorkItem diff --git a/extra/monotonic-clock/authors.txt b/extra/monotonic-clock/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/monotonic-clock/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/monotonic-clock/monotonic-clock.factor b/extra/monotonic-clock/monotonic-clock.factor new file mode 100755 index 0000000000..1dead952b2 --- /dev/null +++ b/extra/monotonic-clock/monotonic-clock.factor @@ -0,0 +1,7 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: system ; +IN: monotonic-clock + +HOOK: monotonic-count os ( -- n ) + diff --git a/extra/monotonic-clock/unix/linux/authors.txt b/extra/monotonic-clock/unix/linux/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/monotonic-clock/unix/linux/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/monotonic-clock/unix/linux/linux.factor b/extra/monotonic-clock/unix/linux/linux.factor new file mode 100755 index 0000000000..2ceb0c398b --- /dev/null +++ b/extra/monotonic-clock/unix/linux/linux.factor @@ -0,0 +1,4 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: ; +IN: monotonic-clock.unix.linux diff --git a/extra/monotonic-clock/unix/linux/tags.txt b/extra/monotonic-clock/unix/linux/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/extra/monotonic-clock/unix/linux/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/extra/monotonic-clock/unix/macosx/authors.txt b/extra/monotonic-clock/unix/macosx/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/monotonic-clock/unix/macosx/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/monotonic-clock/unix/macosx/macosx.factor b/extra/monotonic-clock/unix/macosx/macosx.factor new file mode 100755 index 0000000000..5bdb8ffa29 --- /dev/null +++ b/extra/monotonic-clock/unix/macosx/macosx.factor @@ -0,0 +1,24 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien.syntax classes.struct kernel math +monotonic-clock system unix.types ; +IN: monotonic-clock.unix.macosx + +STRUCT: mach_timebase_info + { numer uint32_t } + { denom uint32_t } ; + +TYPEDEF: mach_timebase_info* mach_timebase_info_t +TYPEDEF: mach_timebase_info mach_timebase_info_data_t + +FUNCTION: uint64_t mach_absolute_time ( ) ; +FUNCTION: kern_return_t mach_timebase_info ( mach_timebase_info_t info ) ; +FUNCTION: kern_return_t mach_wait_until ( uint64_t deadline ) ; + +ERROR: mach-timebase-info ret ; + +M: macosx monotonic-count + mach_absolute_time + \ mach_timebase_info [ + mach_timebase_info [ mach-timebase-info ] unless-zero + ] keep [ numer>> ] [ denom>> ] bi / * ; diff --git a/extra/monotonic-clock/unix/macosx/tags.txt b/extra/monotonic-clock/unix/macosx/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/extra/monotonic-clock/unix/macosx/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/extra/monotonic-clock/windows/authors.txt b/extra/monotonic-clock/windows/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/monotonic-clock/windows/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/monotonic-clock/windows/tags.txt b/extra/monotonic-clock/windows/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/extra/monotonic-clock/windows/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/extra/monotonic-clock/windows/windows.factor b/extra/monotonic-clock/windows/windows.factor new file mode 100755 index 0000000000..85732e32fd --- /dev/null +++ b/extra/monotonic-clock/windows/windows.factor @@ -0,0 +1,19 @@ +! Copyright (C) 2009 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: alien.c-types alien.data fry kernel monotonic-clock +system windows.errors windows.kernel32 ; +IN: monotonic-clock.windows + + ] dip + '[ _ execute win32-error=0/f ] keep *ulonglong ; inline + +PRIVATE> + +M: windows monotonic-count ( -- n ) + \ QueryPerformanceCounter execute-performance-query ; + +: cpu-frequency ( -- n ) + \ QueryPerformanceFrequency execute-performance-query ;