aboutsummaryrefslogtreecommitdiff
path: root/core/runtime
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-05-27 20:17:58 +0100
committergingerBill <bill@gingerbill.org>2020-05-27 20:17:58 +0100
commit1d7f99cbdf28236e8d55e7c36ec14c693d139f3f (patch)
tree37b6d9ff17c2aca817737904f34a91eaa4e8d38b /core/runtime
parent3d4a3730b084f26e64929b32a554cd2a592f6860 (diff)
Remove `mem_zero` from `make`; Implement custom `memset` for windows amd64
Diffstat (limited to 'core/runtime')
-rw-r--r--core/runtime/core.odin4
-rw-r--r--core/runtime/procs_windows_amd64.odin10
2 files changed, 9 insertions, 5 deletions
diff --git a/core/runtime/core.odin b/core/runtime/core.odin
index 11b267661..5399db9a3 100644
--- a/core/runtime/core.odin
+++ b/core/runtime/core.odin
@@ -631,7 +631,7 @@ make_aligned :: proc($T: typeid/[]$E, auto_cast len: int, alignment: int, alloca
if data == nil && size_of(E) != 0 {
return nil;
}
- mem_zero(data, size_of(E)*len);
+ // mem_zero(data, size_of(E)*len);
s := Raw_Slice{data, len};
return transmute(T)s;
}
@@ -659,7 +659,7 @@ make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, auto_cast len: int, a
if data == nil && size_of(E) != 0 {
s.len, s.cap = 0, 0;
}
- mem_zero(data, size_of(E)*cap);
+ // mem_zero(data, size_of(E)*cap);
return transmute(T)s;
}
diff --git a/core/runtime/procs_windows_amd64.odin b/core/runtime/procs_windows_amd64.odin
index ebcbbe44e..7b906f398 100644
--- a/core/runtime/procs_windows_amd64.odin
+++ b/core/runtime/procs_windows_amd64.odin
@@ -30,10 +30,14 @@ memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
// @(link_name="memset")
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
- foreign kernel32 {
- RtlFillMemory :: proc "c" (dst: rawptr, len: int, fill: byte) ---
+ b := byte(val);
+
+ p_start := uintptr(ptr);
+ p_end := p_start + uintptr(max(len, 0));
+ for p := p_start; p < p_end; p += 1 {
+ (^byte)(p)^ = b;
}
- RtlFillMemory(ptr, len, byte(val));
+
return ptr;
}