aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeau McCartney <mccartney.beausl@gmail.com>2024-03-15 08:11:10 -0600
committerBeau McCartney <mccartney.beausl@gmail.com>2024-03-15 08:26:25 -0600
commitcf949e541f9a5abd1785c2a382f1de5b706dfd8b (patch)
treed0a00e4e54b0c26e227ff5e3b768d136bfab0390
parent44167800ad7cf7fd8824776f79c48d886808ff1a (diff)
helper function to convert Open_Flags bitset to a u32
- analagous to _sys_permission_mode() - uses the already-existing conversion logic in sys_open()
-rw-r--r--core/sys/darwin/xnu_system_call_helpers.odin23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/sys/darwin/xnu_system_call_helpers.odin b/core/sys/darwin/xnu_system_call_helpers.odin
index 753f7f058..06cf26178 100644
--- a/core/sys/darwin/xnu_system_call_helpers.odin
+++ b/core/sys/darwin/xnu_system_call_helpers.odin
@@ -87,6 +87,29 @@ _sys_permission_mode :: #force_inline proc (mode: Permission) -> u32 {
return cflags
}
+_sys_open_mode :: #force_inline proc(mode: Open_Flags) -> u32 {
+ cflags : u32 = 0
+
+ cflags |= OPEN_FLAG_RDONLY * u32(Open_Flags.RDONLY in mode)
+ cflags |= OPEN_FLAG_WRONLY * u32(Open_Flags.WRONLY in mode)
+ cflags |= OPEN_FLAG_RDWR * u32(Open_Flags.RDWR in mode)
+ cflags |= OPEN_FLAG_NONBLOCK * u32(Open_Flags.NONBLOCK in mode)
+ cflags |= OPEN_FLAG_CREAT * u32(Open_Flags.CREAT in mode)
+ cflags |= OPEN_FLAG_APPEND * u32(Open_Flags.APPEND in mode)
+ cflags |= OPEN_FLAG_TRUNC * u32(Open_Flags.TRUNC in mode)
+ cflags |= OPEN_FLAG_EXCL * u32(Open_Flags.EXCL in mode)
+ cflags |= OPEN_FLAG_SHLOCK * u32(Open_Flags.SHLOCK in mode)
+ cflags |= OPEN_FLAG_EXLOCK * u32(Open_Flags.EXLOCK in mode)
+ cflags |= OPEN_FLAG_DIRECTORY * u32(Open_Flags.DIRECTORY in mode)
+ cflags |= OPEN_FLAG_NOFOLLOW * u32(Open_Flags.NOFOLLOW in mode)
+ cflags |= OPEN_FLAG_SYMLINK * u32(Open_Flags.SYMLINK in mode)
+ cflags |= OPEN_FLAG_EVTONLY * u32(Open_Flags.EVTONLY in mode)
+ cflags |= OPEN_FLAG_CLOEXEC * u32(Open_Flags.CLOEXEC in mode)
+ cflags |= OPEN_FLAG_NOFOLLOW_ANY * u32(Open_Flags.NOFOLLOW_ANY in mode)
+
+ return cflags
+}
+
@(private)
clone_to_cstring :: proc(s: string, allocator: runtime.Allocator, loc := #caller_location) -> cstring {
c := make([]byte, len(s)+1, allocator, loc)