aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-02 19:15:28 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-02 19:29:27 -0400
commitac9484206b8fb79bd289049ab8c2f4b6488e9cfa (patch)
treecedb9037e3e3eab9cd95f46e03a521a36c58d9f9
parentf77ce359cec2cc50c5a98e4b4257e63ed702995e (diff)
Fix `STDIN`, `STDOUT`, `STDERR` handles for BSDs
Tested on FreeBSD 14.0 and NetBSD 10.0 OpenBSD is untested, but link names were sourced from: https://github.com/openbsd/src/blob/master/include/stdio.h According to this, OpenBSD shares the same layout as NetBSD. FreeBSD has the same as Darwin in this regard.
-rw-r--r--core/c/libc/stdio.odin14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/c/libc/stdio.odin b/core/c/libc/stdio.odin
index f17d3bd06..3e1d0f5a2 100644
--- a/core/c/libc/stdio.odin
+++ b/core/c/libc/stdio.odin
@@ -102,10 +102,12 @@ when ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD {
SEEK_END :: 2
foreign libc {
- stderr: ^FILE
- stdin: ^FILE
- stdout: ^FILE
+ __sF: [3]FILE
}
+
+ stdin: ^FILE = &__sF[0]
+ stdout: ^FILE = &__sF[1]
+ stderr: ^FILE = &__sF[2]
}
when ODIN_OS == .FreeBSD {
@@ -127,9 +129,9 @@ when ODIN_OS == .FreeBSD {
SEEK_END :: 2
foreign libc {
- stderr: ^FILE
- stdin: ^FILE
- stdout: ^FILE
+ @(link_name="__stderrp") stderr: ^FILE
+ @(link_name="__stdinp") stdin: ^FILE
+ @(link_name="__stdoutp") stdout: ^FILE
}
}