aboutsummaryrefslogtreecommitdiff
path: root/core/c
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-09-22 13:20:45 +0100
committergingerBill <bill@gingerbill.org>2024-09-22 13:20:45 +0100
commit26d00925ccd24b81bfe578be316c1ff2fd8faac9 (patch)
treedb26426ecb7b47c20197cad825758b5ec87655c5 /core/c
parent634fa7aa306c076a7a63047b0e448e01df156919 (diff)
Clean-up `libc` usage
Diffstat (limited to 'core/c')
-rw-r--r--core/c/libc/errno.odin8
-rw-r--r--core/c/libc/stdio.odin2
-rw-r--r--core/c/libc/string.odin1
-rw-r--r--core/c/libc/time.odin2
4 files changed, 11 insertions, 2 deletions
diff --git a/core/c/libc/errno.odin b/core/c/libc/errno.odin
index 843b2f1b6..de429a6ec 100644
--- a/core/c/libc/errno.odin
+++ b/core/c/libc/errno.odin
@@ -98,6 +98,14 @@ when ODIN_OS == .Haiku {
ERANGE :: B_POSIX_ERROR_BASE + 17
}
+when ODIN_OS == .JS {
+ _ :: libc
+ _get_errno :: proc "c" () -> ^int {
+ @(static) errno: int
+ return &errno
+ }
+}
+
// Odin has no way to make an identifier "errno" behave as a function call to
// read the value, or to produce an lvalue such that you can assign a different
// error value to errno. To work around this, just expose it as a function like
diff --git a/core/c/libc/stdio.odin b/core/c/libc/stdio.odin
index 019389b0d..f02453bba 100644
--- a/core/c/libc/stdio.odin
+++ b/core/c/libc/stdio.odin
@@ -59,7 +59,7 @@ when ODIN_OS == .Windows {
}
// GLIBC and MUSL compatible.
-when ODIN_OS == .Linux {
+when ODIN_OS == .Linux || ODIN_OS == .JS {
fpos_t :: struct #raw_union { _: [16]char, _: longlong, _: double, }
_IOFBF :: 0
diff --git a/core/c/libc/string.odin b/core/c/libc/string.odin
index cde9c7e6b..4ec4f3a7a 100644
--- a/core/c/libc/string.odin
+++ b/core/c/libc/string.odin
@@ -12,6 +12,7 @@ when ODIN_OS == .Windows {
foreign import libc "system:c"
}
+@(default_calling_convention="c")
foreign libc {
// 7.24.2 Copying functions
memcpy :: proc(s1, s2: rawptr, n: size_t) -> rawptr ---
diff --git a/core/c/libc/time.odin b/core/c/libc/time.odin
index 48def707e..6828793ec 100644
--- a/core/c/libc/time.odin
+++ b/core/c/libc/time.odin
@@ -45,7 +45,7 @@ when ODIN_OS == .Windows {
}
}
-when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .Haiku {
+when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD || ODIN_OS == .Haiku || ODIN_OS == .JS {
@(default_calling_convention="c")
foreign libc {
// 7.27.2 Time manipulation functions