From 45691a462282016368d1740fccb4488a331ca172 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 2 Sep 2022 02:14:48 +0200 Subject: [PATCH] [sys/info] Add sysctl MIBs for MacOS. --- core/sys/info/platform_darwin.odin | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index f0b572d2b..21153a6ad 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -13,9 +13,6 @@ init_os_version :: proc "c" () { init_ram :: proc() { // Retrieve RAM info using `sysinfo` - CTL_HW :: 6 - HW_MEMSIZE :: 24 - mib := []i32{CTL_HW, HW_MEMSIZE} mem_size: i64 ok := sysctl(mib, &mem_size) @@ -34,4 +31,30 @@ sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { uintptr(0), uintptr(0), ) return res == 0 -} \ No newline at end of file +} + +// See sysctl.h for xnu/dwrwin for details +CTL_KERN :: 1 + KERN_OSTYPE :: 1 /* string: system version */ + KERN_OSRELEASE :: 2 /* string: system release */ + KERN_OSREV :: 3 /* int: system revision */ + KERN_VERSION :: 4 /* string: compile time info */ + KERN_OSRELDATE :: 26 /* int: OS release date */ + KERN_OSVERSION :: 65 /* for build number i.e. 9A127 */ +CTL_VM :: 2 +CTL_VFS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 /* string: machine class */ + HW_MODEL :: 2 /* string: specific machine model */ + HW_NCPU :: 3 /* int: number of cpus */ + HW_BYTEORDER :: 4 /* int: machine byte order */ + HW_MACHINE_ARCH :: 12 /* string: machine architecture */ + HW_VECTORUNIT :: 13 /* int: has HW vector unit? */ + HW_MEMSIZE :: 24 /* uint64_t: physical ram size */ + HW_AVAILCPU :: 25 /* int: number of available CPUs */ + +CTL_MACHDEP :: 7 +CTL_USER :: 8 +