aboutsummaryrefslogtreecommitdiff
path: root/base/runtime/os_specific_bsd.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-01-28 23:11:38 +0000
committergingerBill <bill@gingerbill.org>2024-01-28 23:11:38 +0000
commit535b8a94832e7f0935bd7a6ccdc6a59bf68d4d9f (patch)
tree0074f9665d97e9ed5be880478caead2cbcb5737d /base/runtime/os_specific_bsd.odin
parent038086d1d90e93a093caa438dd4a1c8f23c440c2 (diff)
Remove `core:os` dependency completely from `base:runtime`
Diffstat (limited to 'base/runtime/os_specific_bsd.odin')
-rw-r--r--base/runtime/os_specific_bsd.odin21
1 files changed, 21 insertions, 0 deletions
diff --git a/base/runtime/os_specific_bsd.odin b/base/runtime/os_specific_bsd.odin
new file mode 100644
index 000000000..93ed9b4e6
--- /dev/null
+++ b/base/runtime/os_specific_bsd.odin
@@ -0,0 +1,21 @@
+//+build freebsd, openbsd
+//+private
+package runtime
+
+foreign import libc "system:c"
+
+foreign libc {
+ @(link_name="write")
+ _unix_write :: proc(fd: uintptr, buf: rawptr, size: int) -> int ---
+
+ __error :: proc() -> ^i32 ---
+}
+
+_os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
+ ret := _unix_write(2, raw_data(data), len(data))
+ if ret < len(data) {
+ err := __error()
+ return int(ret), _OS_Errno(err^ if err != nil else 0)
+ }
+ return int(ret), 0
+}