aboutsummaryrefslogtreecommitdiff
path: root/core/runtime
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-04 00:50:28 +0000
committergingerBill <bill@gingerbill.org>2021-11-04 00:50:28 +0000
commit9ab71ca0da6a68806ff9825000799e8ddfbfc341 (patch)
tree981a837391fb65baf6ece23420527eb382f7b08b /core/runtime
parent3d06dddb72e00409b14df36959bb3bcdc8d42999 (diff)
Add `ODIN_NO_CRT` global constant
Diffstat (limited to 'core/runtime')
-rw-r--r--core/runtime/procs.odin37
-rw-r--r--core/runtime/procs_windows_amd64.odin16
2 files changed, 46 insertions, 7 deletions
diff --git a/core/runtime/procs.odin b/core/runtime/procs.odin
index 09ad25379..7ea6145b9 100644
--- a/core/runtime/procs.odin
+++ b/core/runtime/procs.odin
@@ -25,6 +25,43 @@ when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" {
return dst
}
+} else when ODIN_NO_CRT {
+ @(link_name="memset")
+ memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
+ if ptr != nil && len != 0 {
+ b := byte(val)
+ p := ([^]byte)(ptr)
+ for i in 0..<len {
+ p[i] = b
+ }
+ }
+ return ptr
+ }
+
+ @(link_name="memmove")
+ memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
+ if dst != src {
+ d, s := ([^]byte)(dst), ([^]byte)(src)
+ d_end, s_end := d[len:], s[len:]
+ for i := len-1; i >= 0; i -= 1 {
+ d[i] = s[i]
+ }
+ }
+ return dst
+
+ }
+ @(link_name="memcpy")
+ memcpy :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
+ if dst != src {
+ d, s := ([^]byte)(dst), ([^]byte)(src)
+ d_end, s_end := d[len:], s[len:]
+ for i := len-1; i >= 0; i -= 1 {
+ d[i] = s[i]
+ }
+ }
+ return dst
+
+ }
} else {
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
if ptr != nil && len != 0 {
diff --git a/core/runtime/procs_windows_amd64.odin b/core/runtime/procs_windows_amd64.odin
index e5f24e53b..8faed87e5 100644
--- a/core/runtime/procs_windows_amd64.odin
+++ b/core/runtime/procs_windows_amd64.odin
@@ -19,10 +19,12 @@ windows_trap_type_assertion :: proc "contextless" () -> ! {
windows_trap_array_bounds()
}
-// @private
-// @(link_name="_tls_index")
-// _tls_index: u32;
-
-// @private
-// @(link_name="_fltused")
-// _fltused: i32 = 0x9875;
+when ODIN_NO_CRT {
+ @private
+ @(link_name="_tls_index")
+ _tls_index: u32
+
+ @private
+ @(link_name="_fltused")
+ _fltused: i32 = 0x9875
+} \ No newline at end of file