Browse Source

Add getrusage syscall for mac/darwin

The syscall number existed but the wrapper for calling it
did not. Also adds the RUsage struct to receive the data.

Naming is kept the same as in sys/linux
Ian Simonson 1 year ago
parent
commit
26d107ce64
2 changed files with 28 additions and 0 deletions
  1. 24 0
      core/sys/darwin/darwin.odin
  2. 4 0
      core/sys/darwin/xnu_system_call_wrappers.odin

+ 24 - 0
core/sys/darwin/darwin.odin

@@ -2,3 +2,27 @@
 package darwin
 
 Bool :: b8
+
+timespec :: struct {
+        seconds:      int,
+        microseconds: int,
+}
+
+RUsage :: struct {
+        utime:         timespec,
+        stime:         timespec,
+        maxrss_word:   int,
+        ixrss_word:    int,
+        idrss_word:    int,
+        isrss_word:    int,
+        minflt_word:   int,
+        majflt_word:   int,
+        nswap_word:    int,
+        inblock_word:  int,
+        oublock_word:  int,
+        msgsnd_word:   int,
+        msgrcv_word:   int,
+        nsignals_word: int,
+        nvcsw_word:    int,
+        nivcsw_word:   int,
+}

+ 4 - 0
core/sys/darwin/xnu_system_call_wrappers.odin

@@ -417,3 +417,7 @@ syscall_chdir :: #force_inline proc "contextless" (path: cstring) -> c.int {
 syscall_fchdir :: #force_inline proc "contextless" (fd: c.int, path: cstring) -> c.int {
 	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(fd), transmute(uintptr)path)
 }
+
+syscall_getrusage :: #force_inline proc "contextless" (who: c.int, rusage: ^RUsage) -> c.int {
+	return cast(c.int) intrinsics.syscall(unix_offset_syscall(.getrusage), uintptr(who), uintptr(rusage))
+}