aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorIsaac Andrade <andradei@proton.me>2024-08-23 19:56:45 -0600
committerIsaac Andrade <andradei@proton.me>2024-08-23 19:56:45 -0600
commit90aa7dff04d51a80fac118ee7006815381f80d7e (patch)
tree9f0d9164df15ba5e7f19e388a8c5ac5ee6d06458 /core/sys
parent1adea2f4d6016876ea53840bd56673f6e25887b7 (diff)
Add POSIX dirent struct for Linux.
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/posix/dirent.odin22
-rw-r--r--core/sys/posix/fcntl.odin3
-rw-r--r--core/sys/posix/sys_stat.odin3
3 files changed, 27 insertions, 1 deletions
diff --git a/core/sys/posix/dirent.odin b/core/sys/posix/dirent.odin
index 38ba2e8cf..127f7bc48 100644
--- a/core/sys/posix/dirent.odin
+++ b/core/sys/posix/dirent.odin
@@ -202,7 +202,27 @@ when ODIN_OS == .Darwin {
} else when ODIN_OS == .Linux {
- dirent :: struct {
+ when ODIN_ARCH == .i386 || ODIN_ARCH == .wasm32 || ODIN_ARCH == .arm32 {
+
+ dirent :: struct {
+ d_ino: ino_t32, /* [PSX] file number of entry */
+ d_off: off_t32, /* directory offset of the next entry */
+ d_reclen: c.uint16_t, /* length of this record */
+ d_type: D_Type, /* file type */
+ d_name: [256]c.char `fmt:"s,0"` /* [PSX] entry name */
+ }
+ } else when ODIN_ARCH == .amd64 || ODIN_ARCH == .wasm64p32 || ODIN_ARCH == .arm64 {
+
+ dirent :: struct {
+ d_ino: ino_t, /* [PSX] file number of entry */
+ d_off: off_t, /* directory offset of the next entry */
+ d_reclen: c.uint16_t, /* length of this record */
+ d_type: D_Type, /* file type */
+ d_name: [256]c.char `fmt:"s,0"` /* [PSX] entry name */
+ }
+ }
+
+ dirent64 :: struct {
d_ino: ino_t, /* [PSX] file number of entry */
d_off: off_t, /* directory offset of the next entry */
d_reclen: c.uint16_t, /* length of this record */
diff --git a/core/sys/posix/fcntl.odin b/core/sys/posix/fcntl.odin
index ca030a9a5..617fa408f 100644
--- a/core/sys/posix/fcntl.odin
+++ b/core/sys/posix/fcntl.odin
@@ -410,6 +410,9 @@ when ODIN_OS == .Darwin {
l_whence: c.short, /* [PSX] flag (Whence) of starting offset */
}
+} else when ODIN_OS == .Linux {
+ off_t :: distinct c.uint64_t
+ off_t32 :: distinct c.uint32_t
} else {
#panic("posix is unimplemented for the current target")
}
diff --git a/core/sys/posix/sys_stat.odin b/core/sys/posix/sys_stat.odin
index dd66d7d14..5760175b1 100644
--- a/core/sys/posix/sys_stat.odin
+++ b/core/sys/posix/sys_stat.odin
@@ -427,6 +427,9 @@ when ODIN_OS == .Darwin {
UTIME_NOW :: -2
UTIME_OMIT :: -1
+} when ODIN_OS == .Linux {
+ ino_t :: distinct c.unit64_t
+ ino_t32 :: distinct c.unit32_t
} else {
#panic("posix is unimplemented for the current target")
}