diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-09-03 16:30:31 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-09-03 16:30:31 +0200 |
| commit | 4eafb0ce7fc8590f9466c8cdbe421b4211e5daaa (patch) | |
| tree | f8d9a1baead5e16d7ea75dd81d9240e798933cd2 /core/sys/unix | |
| parent | 0171c276f0880d6915254b728e9519ad5fc49256 (diff) | |
[sys/info] Move macOS sysctl to sys/unix.
Diffstat (limited to 'core/sys/unix')
| -rw-r--r-- | core/sys/unix/sysctl_darwin.odin | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/sys/unix/sysctl_darwin.odin b/core/sys/unix/sysctl_darwin.odin new file mode 100644 index 000000000..92b14e6e1 --- /dev/null +++ b/core/sys/unix/sysctl_darwin.odin @@ -0,0 +1,43 @@ +//+build darwin +package unix + +import "core:sys/darwin" +import "core:intrinsics" + +sysctl :: proc(mib: []i32, val: ^$T) -> (ok: bool) { + mib := mib + result_size := i64(size_of(T)) + + res := intrinsics.syscall( + darwin.unix_offset_syscall(.sysctl), + uintptr(raw_data(mib)), uintptr(len(mib)), + uintptr(val), uintptr(&result_size), + uintptr(0), uintptr(0), + ) + return res == 0 +} + +// See sysctl.h for darwin for details +CTL_KERN :: 1 + KERN_OSTYPE :: 1 // Darwin + KERN_OSRELEASE :: 2 // 21.5.0 for 12.4 Monterey + KERN_OSREV :: 3 // i32: system revision + KERN_VERSION :: 4 // Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:darwin-8020.121.3~4/RELEASE_X86_64 + KERN_OSRELDATE :: 26 // i32: OS release date + KERN_OSVERSION :: 65 // Build number, e.g. 21F79 +CTL_VM :: 2 +CTL_VFS :: 3 +CTL_NET :: 4 +CTL_DEBUG :: 5 +CTL_HW :: 6 + HW_MACHINE :: 1 // x86_64 + HW_MODEL :: 2 // MacbookPro14,1 + 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 // u64 + HW_AVAILCPU :: 25 /* int: number of available CPUs */ + +CTL_MACHDEP :: 7 +CTL_USER :: 8
\ No newline at end of file |