From 71c526d36af47acc0ff170b02c06a7a8a3530646 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 24 Apr 2013 12:05:51 -0700 Subject: [PATCH] system-info.linux: Implement the system-report. word. --- basis/system-info/linux/linux.factor | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/basis/system-info/linux/linux.factor b/basis/system-info/linux/linux.factor index 13121a851e..c2d17fe118 100644 --- a/basis/system-info/linux/linux.factor +++ b/basis/system-info/linux/linux.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.c-types alien.syntax byte-arrays io +USING: accessors alien.c-types alien.syntax byte-arrays io io.encodings.string io.encodings.utf8 io.streams.byte-array -kernel sequences splitting strings system system-info unix ; +kernel sequences splitting strings system system-info unix +unix.linux.proc math ; IN: system-info.linux FUNCTION-ALIAS: (uname) @@ -19,4 +20,9 @@ FUNCTION-ALIAS: (uname) : machine ( -- string ) 4 uname nth ; : domainname ( -- string ) 5 uname nth ; -M: linux os-version release ; \ No newline at end of file +M: linux os-version release ; +M: linux cpus parse-proc-cpuinfo sort-cpus cpu-counts 2drop ; +: cores ( -- n ) parse-proc-cpuinfo sort-cpus cpu-counts drop nip ; +: hyperthreads ( -- n ) parse-proc-cpuinfo sort-cpus cpu-counts 2nip ; +M: linux cpu-mhz parse-proc-cpuinfo first cpu-mhz>> 1,000,000 * ; +M: linux physical-mem parse-proc-meminfo mem-total>> ;