Răsfoiți Sursa

sys_open() calls _sys_open_mode() to get a permission flags integer

_sys_open_mode() does exactly what sys_open() was originally doing
inline, I simply factored it into a separate function so that other
wrappers could call it (similar to _sys_permission_mode())
Beau McCartney 1 an în urmă
părinte
comite
24f9e16dfd
1 a modificat fișierele cu 1 adăugiri și 16 ștergeri
  1. 1 16
      core/sys/darwin/xnu_system_call_helpers.odin

+ 1 - 16
core/sys/darwin/xnu_system_call_helpers.odin

@@ -128,22 +128,7 @@ sys_open :: proc(path: string, oflag: Open_Flags, mode: Permission) -> (c.int, b
 
 	cflags = _sys_permission_mode(mode)
 
-	cmode |= OPEN_FLAG_RDONLY       * u32(Open_Flags.RDONLY in oflag)
-	cmode |= OPEN_FLAG_WRONLY       * u32(Open_Flags.WRONLY in oflag)
-	cmode |= OPEN_FLAG_RDWR         * u32(Open_Flags.RDWR in oflag)
-	cmode |= OPEN_FLAG_NONBLOCK     * u32(Open_Flags.NONBLOCK in oflag)
-	cmode |= OPEN_FLAG_CREAT        * u32(Open_Flags.CREAT in oflag)
-	cmode |= OPEN_FLAG_APPEND       * u32(Open_Flags.APPEND in oflag)
-	cmode |= OPEN_FLAG_TRUNC        * u32(Open_Flags.TRUNC in oflag)
-	cmode |= OPEN_FLAG_EXCL         * u32(Open_Flags.EXCL in oflag)
-	cmode |= OPEN_FLAG_SHLOCK       * u32(Open_Flags.SHLOCK in oflag)
-	cmode |= OPEN_FLAG_EXLOCK       * u32(Open_Flags.EXLOCK in oflag)
-	cmode |= OPEN_FLAG_DIRECTORY    * u32(Open_Flags.DIRECTORY in oflag)
-	cmode |= OPEN_FLAG_NOFOLLOW     * u32(Open_Flags.NOFOLLOW in oflag)
-	cmode |= OPEN_FLAG_SYMLINK      * u32(Open_Flags.SYMLINK in oflag)
-	cmode |= OPEN_FLAG_EVTONLY      * u32(Open_Flags.EVTONLY in oflag)
-	cmode |= OPEN_FLAG_CLOEXEC      * u32(Open_Flags.CLOEXEC in oflag)
-	cmode |= OPEN_FLAG_NOFOLLOW_ANY * u32(Open_Flags.NOFOLLOW_ANY in oflag)
+	cmode = _sys_open_mode(oflag)
 	
 	result := syscall_open(cpath, cmode, cflags)
 	state  := result != -1