sys/linux IPC_Flags_Bits and Sem_Buf #3975
-
Hi, I am following the Beej's Guide to Unix Interproces Communication and rewriting the examples in Odin (version dev-2024-07) using the sys/linux package. I encountered some issues with //IPC_Flags_Bits.IPC_CREAT | 0o666
ret := linux.syscall(linux.SYS_msgget, key, i16(0o1666))
//or
msgid, lerrno := linux.msgget(key, transmute(linux.IPC_Flags)(i16(0o1666))) A similar issue occurs with the Sem_Buf structure. Where the man page forsemop indicates that the Sembuf :: struct {
num :u16,
op :i16,
flg :IPC_Flags
}
...
sb := Sembuf{op = 1}
...
lerrno = linux.semop(key, {transmute(linux.Sem_Buf) sb}) Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Odin should match the linux syscall interface relatively closely, aside from the following exceptions:
If you believe that Odin's functions are wrong, feel free to make an issue, I'll fix it within a week (when I have the time). Some of these functions in linux syscall interface weren't tested so I'm not sure if any of them still contain mistakes. Also please note that the book you have linked uses POSIX interface (a C library), not linux syscalls directly. As of right now, Odin does not provide significant bindings for posix interfaces, and right now we're only implementing the syscall interface, which looks similar to posix and has functions with similar names, but their interface is fundamentally different, as it wraps over the kernel syscalls. I apologize for the inconvenience, but if you want to follow a book properly I'm afraid you'd have to either do it in C, or write the necessary libc bindings yourself. I don't think posix interfaces will be in Odin's standard library, at least any time soon. Hopefully the work we're doing on the |
Beta Was this translation helpful? Give feedback.
Odin should match the linux syscall interface relatively closely, aside from the following exceptions:
If you believe that Odin's functions are wrong, feel free to make an issue, I'll fix it within a week (when I have the time). Some of these functions in linux syscall interface weren't tested so I'm not sure if any of them still contain mistakes.
Also please note that the book you have linked uses POSIX i…