mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Clean-up libc usage
This commit is contained in:
@@ -98,6 +98,14 @@ when ODIN_OS == .Haiku {
|
|||||||
ERANGE :: B_POSIX_ERROR_BASE + 17
|
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
|
// 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
|
// 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
|
// error value to errno. To work around this, just expose it as a function like
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ when ODIN_OS == .Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GLIBC and MUSL compatible.
|
// GLIBC and MUSL compatible.
|
||||||
when ODIN_OS == .Linux {
|
when ODIN_OS == .Linux || ODIN_OS == .JS {
|
||||||
fpos_t :: struct #raw_union { _: [16]char, _: longlong, _: double, }
|
fpos_t :: struct #raw_union { _: [16]char, _: longlong, _: double, }
|
||||||
|
|
||||||
_IOFBF :: 0
|
_IOFBF :: 0
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ when ODIN_OS == .Windows {
|
|||||||
foreign import libc "system:c"
|
foreign import libc "system:c"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention="c")
|
||||||
foreign libc {
|
foreign libc {
|
||||||
// 7.24.2 Copying functions
|
// 7.24.2 Copying functions
|
||||||
memcpy :: proc(s1, s2: rawptr, n: size_t) -> rawptr ---
|
memcpy :: proc(s1, s2: rawptr, n: size_t) -> rawptr ---
|
||||||
|
|||||||
@@ -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")
|
@(default_calling_convention="c")
|
||||||
foreign libc {
|
foreign libc {
|
||||||
// 7.27.2 Time manipulation functions
|
// 7.27.2 Time manipulation functions
|
||||||
|
|||||||
Vendored
+1
-2
@@ -1,6 +1,6 @@
|
|||||||
package stb_image
|
package stb_image
|
||||||
|
|
||||||
import c "core:c/libc"
|
import "core:c"
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
LIB :: (
|
LIB :: (
|
||||||
@@ -20,7 +20,6 @@ when LIB != "" {
|
|||||||
|
|
||||||
when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
|
when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
|
||||||
foreign import stbi "../lib/stb_image_wasm.o"
|
foreign import stbi "../lib/stb_image_wasm.o"
|
||||||
foreign import stbi { LIB }
|
|
||||||
} else when LIB != "" {
|
} else when LIB != "" {
|
||||||
foreign import stbi { LIB }
|
foreign import stbi { LIB }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package stb_image
|
package stb_image
|
||||||
|
|
||||||
import c "core:c/libc"
|
import "core:c"
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
RESIZE_LIB :: (
|
RESIZE_LIB :: (
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package stb_image
|
package stb_image
|
||||||
|
|
||||||
import c "core:c/libc"
|
import "core:c"
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
WRITE_LIB :: (
|
WRITE_LIB :: (
|
||||||
|
|||||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ The `js_wasm32` target assumes that the WASM output will be ran within a web bro
|
|||||||
## Example for `js_wasm32`
|
## Example for `js_wasm32`
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- Copy `vendor:wasm/js/odin.js` into your web server -->
|
<!-- Copy `core:sys/wasm/js/odin.js` into your web server -->
|
||||||
<script type="text/javascript" src="odin.js"></script>
|
<script type="text/javascript" src="odin.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
odin.runWasm(pathToWasm, consolePreElement);
|
odin.runWasm(pathToWasm, consolePreElement);
|
||||||
|
|||||||
Reference in New Issue
Block a user