Browse Source

darwin: sys_shm_open() helper

wraps syscall_shm_open() in the same way that sys_open() wraps
syscall_open()
Beau McCartney 1 year ago
parent
commit
56a29685b4
1 changed files with 17 additions and 0 deletions
  1. 17 0
      core/sys/darwin/xnu_system_call_helpers.odin

+ 17 - 0
core/sys/darwin/xnu_system_call_helpers.odin

@@ -206,3 +206,20 @@ sys_lstat :: proc(path: string, status: ^stat) -> bool {
 	cpath: cstring = clone_to_cstring(path, context.temp_allocator)
 	cpath: cstring = clone_to_cstring(path, context.temp_allocator)
 	return syscall_lstat(cpath, status) != -1
 	return syscall_lstat(cpath, status) != -1
 }
 }
+
+sys_shm_open :: proc(name: string, oflag: Open_Flags, mode: Permission) -> (c.int, bool) {
+	runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
+
+	cmode: u32 = 0
+	cflags: u32 = 0
+	cname: cstring = clone_to_cstring(name, context.temp_allocator)
+
+	cflags = _sys_permission_mode(mode)
+
+	cmode = _sys_open_mode(oflag)
+
+	result := syscall_shm_open(cname, cmode, cflags)
+	state  := result != -1
+
+	return result * cast(c.int)state, state
+}