]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/system-info/macosx/macosx.factor
system-info: implement system-info.freebsd via sysctl
[factor.git] / basis / system-info / macosx / macosx.factor
index 61fb79ee8bf9dd510fe38fb36a11f3bfa48115a0..95f15d98bf9fdfdf14420b38014d77535702c85f 100644 (file)
@@ -1,10 +1,8 @@
 ! Copyright (C) 2008 Doug Coleman, John Benediktsson.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.data alien.strings alien.syntax
-arrays assocs byte-arrays core-foundation endian
-io.encodings.utf8 kernel libc sequences specialized-arrays
-splitting system system-info unix.users ;
-SPECIALIZED-ARRAY: int
+USING: alien.c-types alien.data alien.strings alien.syntax arrays
+assocs byte-arrays core-foundation endian io.encodings.utf8 kernel
+libc sequences splitting system system-info unix.sysctl unix.users ;
 IN: system-info.macosx
 
 <PRIVATE
@@ -57,25 +55,6 @@ M: macosx os-version
 
 ! See /usr/include/sys/sysctl.h for constants
 
-LIBRARY: libc
-FUNCTION: int sysctl ( int* name, uint namelen, void* oldp, size_t* oldlenp, void* newp, size_t newlen )
-
-: (sysctl-query) ( name namelen oldp oldlenp -- oldp )
-    over [ f 0 sysctl io-error ] dip ;
-
-: sysctl-query ( seq n -- byte-array )
-    [ [ int >c-array ] [ length ] bi ] dip
-    [ <byte-array> ] [ uint <ref> ] bi (sysctl-query) ;
-
-: sysctl-query-string ( seq -- n )
-    4096 sysctl-query utf8 alien>string ;
-
-: sysctl-query-uint ( seq -- n )
-    4 sysctl-query uint deref ;
-
-: sysctl-query-ulonglong ( seq -- n )
-    8 sysctl-query ulonglong deref ;
-
 : machine ( -- str ) { 6 1 } sysctl-query-string ;
 : model ( -- str ) { 6 2 } sysctl-query-string ;
 M: macosx cpus { 6 3 } sysctl-query-uint ;