mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Add mem.simple_compare_values
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package mem
|
package mem
|
||||||
|
|
||||||
import "core:runtime"
|
import "core:runtime"
|
||||||
|
import "core:intrinsics"
|
||||||
|
|
||||||
set :: proc(data: rawptr, value: byte, len: int) -> rawptr {
|
set :: proc(data: rawptr, value: byte, len: int) -> rawptr {
|
||||||
return runtime.memset(data, i32(value), len);
|
return runtime.memset(data, i32(value), len);
|
||||||
@@ -70,6 +71,11 @@ compare_byte_ptrs :: proc(a, b: ^byte, n: int) -> int #no_bounds_check {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
simple_compare_values :: proc(a, b: $T) -> int where intrinsics.type_is_simple_compare(T) {
|
||||||
|
a, b := a, b;
|
||||||
|
return compare_byte_ptrs((^byte)(&a), (^byte)(&b), size_of(T));
|
||||||
|
}
|
||||||
|
|
||||||
compare_ptrs :: inline proc(a, b: rawptr, n: int) -> int {
|
compare_ptrs :: inline proc(a, b: rawptr, n: int) -> int {
|
||||||
return compare_byte_ptrs((^byte)(a), (^byte)(b), n);
|
return compare_byte_ptrs((^byte)(a), (^byte)(b), n);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user