aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-04 17:24:28 +0000
committergingerBill <bill@gingerbill.org>2021-11-04 17:24:28 +0000
commitadcfca966e2ce725cd968f8702a553fcee741a56 (patch)
treed225f95db70cb128b46d9712239ee306bd2cf410 /core
parentd8e34bd9b77c1e92e07f0e2bb9d9ff81fda28daa (diff)
Use `Rtl*Memory` procedures with `-no-crt` on Windows
Diffstat (limited to 'core')
-rw-r--r--core/runtime/procs.odin30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/runtime/procs.odin b/core/runtime/procs.odin
index c69e5b00a..a403c2265 100644
--- a/core/runtime/procs.odin
+++ b/core/runtime/procs.odin
@@ -1,6 +1,6 @@
package runtime
-when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" || ODIN_NO_CRT {
+when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" || (ODIN_NO_CRT && ODIN_OS != "windows") {
@(link_name="memset", linkage="strong", require)
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
if ptr != nil && len != 0 {
@@ -37,6 +37,34 @@ when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" || ODIN_NO_CRT {
return dst
}
+} else when ODIN_NO_CRT && ODIN_OS == "windows" {
+ foreign import Kernel32 "system:Kernel32.lib"
+
+ @(private="file")
+ @(default_calling_convention="std")
+ foreign Kernel32 {
+ RtlMoveMemory :: proc(dst, src: rawptr, length: int) ---
+ RtlFillMemory :: proc(dst: rawptr, length: int, fill: i32) ---
+ }
+
+ @(link_name="memset", linkage="strong", require)
+ memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
+ RtlFillMemory(ptr, len, val)
+ return ptr
+ }
+
+ @(link_name="memmove", linkage="strong", require)
+ memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
+ RtlMoveMemory(dst, src, len)
+ return dst
+
+ }
+ @(link_name="memcpy", linkage="strong", require)
+ memcpy :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
+ RtlMoveMemory(dst, src, len)
+ return dst
+
+ }
} else {
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
if ptr != nil && len != 0 {