]> gitweb.factorcode.org Git - factor.git/blob - basis/system-info/linux/linux.factor
factor: rename files that are not loadable on mac, too
[factor.git] / basis / system-info / linux / linux.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types alien.syntax byte-arrays io
4 io.encodings.string io.encodings.utf8 io.streams.byte-array
5 libc kernel sequences splitting strings system system-info unix
6 unix.linux.proc math ;
7 IN: system-info.linux
8
9 FUNCTION-ALIAS: (uname)
10     int uname ( c-string buf )
11
12 : uname ( -- seq )
13     65536 <byte-array> [ (uname) io-error ] keep >string
14     "\0" split harvest dup length 6 assert= ;
15
16 : sysname ( -- string ) 0 uname nth ;
17 : nodename ( -- string ) 1 uname nth ;
18 : release ( -- string ) 2 uname nth ;
19 : version ( -- string ) 3 uname nth ;
20 : machine ( -- string ) 4 uname nth ;
21 : domainname ( -- string ) 5 uname nth ;
22
23 M: linux os-version release ;
24 M: linux cpus parse-proc-cpuinfo sort-cpus cpu-counts 2drop ;
25 : cores ( -- n ) parse-proc-cpuinfo sort-cpus cpu-counts drop nip ;
26 : hyperthreads ( -- n ) parse-proc-cpuinfo sort-cpus cpu-counts 2nip ;
27 M: linux cpu-mhz parse-proc-cpuinfo first cpu-mhz>> 1,000,000 * ;
28 M: linux physical-mem parse-proc-meminfo mem-total>> ;