make hardware-info load on windows

db4
Doug Coleman 2008-02-04 17:10:49 -06:00
parent 8f642133ca
commit c0c08985c5
5 changed files with 21 additions and 27 deletions

View File

@ -1,12 +1,13 @@
USING: alien.syntax kernel math prettyprint system
combinators vocabs.loader hardware-info.backend ;
USING: alien.syntax kernel math prettyprint
combinators vocabs.loader hardware-info.backend system ;
IN: hardware-info
: kb. ( x -- ) 10 2^ /f . ;
: megs. ( x -- ) 20 2^ /f . ;
: gigs. ( x -- ) 30 2^ /f . ;
<< {
<<
{
{ [ windows? ] [ "hardware-info.windows" ] }
{ [ linux? ] [ "hardware-info.linux" ] }
{ [ macosx? ] [ "hardware-info.macosx" ] }

View File

@ -1,6 +0,0 @@
IN: hardware-info.windows.backend
TUPLE: wince ;
TUPLE: winnt ;
UNION: windows wince winnt ;

View File

@ -2,8 +2,8 @@ USING: alien.c-types hardware-info kernel math namespaces
windows windows.kernel32 hardware-info.backend ;
IN: hardware-info.windows.ce
TUPLE: wince ;
T{ wince } os set-global
TUPLE: wince-os ;
T{ wince-os } os set-global
: memory-status ( -- MEMORYSTATUS )
"MEMORYSTATUS" <c-object>

View File

@ -1,16 +1,15 @@
USING: alien alien.c-types hardware-info.windows.backend
USING: alien alien.c-types
kernel libc math namespaces hardware-info.backend
windows windows.advapi32 windows.kernel32 ;
IN: hardware-info.windows.nt
TUPLE: winnt ;
T{ winnt } os set-global
TUPLE: winnt-os ;
T{ winnt-os } os set-global
: system-info ( -- SYSTEM_INFO )
"SYSTEM_INFO" <c-object> [ GetSystemInfo ] keep ;
M: winnt cpus ( -- n )
M: winnt-os cpus ( -- n )
system-info SYSTEM_INFO-dwNumberOfProcessors ;
: memory-status ( -- MEMORYSTATUSEX )
@ -18,25 +17,25 @@ M: winnt cpus ( -- n )
"MEMORYSTATUSEX" heap-size over set-MEMORYSTATUSEX-dwLength
[ GlobalMemoryStatusEx ] keep swap zero? [ win32-error ] when ;
M: winnt memory-load ( -- n )
M: winnt-os memory-load ( -- n )
memory-status MEMORYSTATUSEX-dwMemoryLoad ;
M: winnt physical-mem ( -- n )
M: winnt-os physical-mem ( -- n )
memory-status MEMORYSTATUSEX-ullTotalPhys ;
M: winnt available-mem ( -- n )
M: winnt-os available-mem ( -- n )
memory-status MEMORYSTATUSEX-ullAvailPhys ;
M: winnt total-page-file ( -- n )
M: winnt-os total-page-file ( -- n )
memory-status MEMORYSTATUSEX-ullTotalPageFile ;
M: winnt available-page-file ( -- n )
M: winnt-os available-page-file ( -- n )
memory-status MEMORYSTATUSEX-ullAvailPageFile ;
M: winnt total-virtual-mem ( -- n )
M: winnt-os total-virtual-mem ( -- n )
memory-status MEMORYSTATUSEX-ullTotalVirtual ;
M: winnt available-virtual-mem ( -- n )
M: winnt-os available-virtual-mem ( -- n )
memory-status MEMORYSTATUSEX-ullAvailVirtual ;
: computer-name ( -- string )
@ -54,4 +53,3 @@ M: winnt available-virtual-mem ( -- n )
] [
[ alien>u16-string ] keep free
] if ;

View File

@ -1,7 +1,7 @@
USING: alien alien.c-types kernel libc math namespaces
windows windows.kernel32 windows.advapi32
hardware-info.windows.backend
words combinators vocabs.loader hardware-info.backend ;
words combinators vocabs.loader hardware-info.backend
system ;
IN: hardware-info.windows
: system-info ( -- SYSTEM_INFO )
@ -63,7 +63,8 @@ IN: hardware-info.windows
: system-windows-directory ( -- str )
\ GetSystemWindowsDirectory get-directory ;
<<
{
{ [ wince? ] [ "hardware-info.windows.ce" ] }
{ [ winnt? ] [ "hardware-info.windows.nt" ] }
} cond [ require ] when*
} cond [ require ] when* >>