odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
7.03k stars 624 forks source link

core:sys/linux - implemented inotify #4482

Closed A1029384756 closed 2 weeks ago

A1029384756 commented 2 weeks ago

broken on various platforms because SYS_inotify_init and friends are not defined for all architectures. is this something where we should add procs conditionally based on arch? this is tested and confirmed working on amd64

A1029384756 commented 2 weeks ago

some further elaboration, most of these syscalls exist on all platforms under different syscall numbers. those can be added relatively easily. the issue comes with inotify_init where it doesn't exist on arm64, riscv, and a bunch of other architectures. is that something we should just remove entirely or should we wrap in in a conditional block?

flysand7 commented 2 weeks ago

broken on various platforms because SYS_inotify_init and friends are not defined for all architectures. is this something where we should add procs conditionally based on arch? this is tested and confirmed working on amd64

How do you know they are not defined? Are they not in the header/definition files for linux syscalls?

flysand7 commented 2 weeks ago

Looked up, there is inotify_init1 on arm64. I guess this is the classic case of linux doing things "better" on newer architectures and discarding part of the "older" functionality. See https://arm64.syscall.sh/ for syscall numbers.

For the cases where a syscall is missing on one of the architectures, the sys/linux package should try to re-implement this syscall on the platforms where its missing. As an example you can look at fstat which is also missing on arm32 and arm64. The way it's implemented on those architectures is by supplying fstatat with default values for parameters that ensure it behaves the same as fstat.

In case the missing syscall can't be implemented using existing on the platform syscalls is where i'd give up and say it's not supported (procedure returns ENOSYS, or maybe assert).

A1029384756 commented 2 weeks ago

Looked up, there is inotify_init1 on arm64. I guess this is the classic case of linux doing things "better" on newer architectures and discarding part of the "older" functionality. See https://arm64.syscall.sh/ for syscall numbers.

For the cases where a syscall is missing on one of the architectures, the sys/linux package should try to re-implement this syscall on the platforms where its missing. As an example you can look at fstat which is also missing on arm32 and arm64. The way it's implemented on those architectures is by supplying fstatat with default values for parameters that ensure it behaves the same as fstat.

In case the missing syscall can't be implemented using existing on the platform syscalls is where i'd give up and say it's not supported (procedure returns ENOSYS, or maybe assert).

implemented the syscalls on the other architectures by calling to inotify_init1 with 0 for the flag parameter

A1029384756 commented 2 weeks ago

the IN_MOVE and IN_CLOSE bits were moved to constants since they are sets of multiple bits