From d8f2eb271758e7ddedece6b8010b2bae6843b112 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 12 Feb 2026 14:37:28 +0100 Subject: [PATCH] Remove `core:mem` import from `core:math/big`. --- core/math/big/private.odin | 15 +++++++-------- core/math/big/radix.odin | 13 ++++++------- core/math/big/radix_os.odin | 4 ++-- core/math/rand/rand.odin | 7 +++---- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/core/math/big/private.odin b/core/math/big/private.odin index caed8c8b9..8cf7a2a77 100644 --- a/core/math/big/private.odin +++ b/core/math/big/private.odin @@ -19,7 +19,6 @@ package math_big */ import "base:intrinsics" -import "core:mem" /* Multiplies |a| * |b| and only computes upto digs digits of result. @@ -817,7 +816,7 @@ _private_int_sqr_karatsuba :: proc(dest, src: ^Int, allocator := context.allocat x1.used = src.used - B #force_inline internal_copy_digits(x0, src, x0.used) - #force_inline mem.copy_non_overlapping(&x1.digit[0], &src.digit[B], size_of(DIGIT) * x1.used) + intrinsics.mem_copy_non_overlapping(&x1.digit[0], &src.digit[B], size_of(DIGIT) * x1.used) #force_inline internal_clamp(x0) /* @@ -882,9 +881,9 @@ _private_int_sqr_toom :: proc(dest, src: ^Int, allocator := context.allocator) - a1.used = B a2.used = src.used - 2 * B - #force_inline mem.copy_non_overlapping(&a0.digit[0], &src.digit[ 0], size_of(DIGIT) * a0.used) - #force_inline mem.copy_non_overlapping(&a1.digit[0], &src.digit[ B], size_of(DIGIT) * a1.used) - #force_inline mem.copy_non_overlapping(&a2.digit[0], &src.digit[2 * B], size_of(DIGIT) * a2.used) + intrinsics.mem_copy_non_overlapping(&a0.digit[0], &src.digit[ 0], size_of(DIGIT) * a0.used) + intrinsics.mem_copy_non_overlapping(&a1.digit[0], &src.digit[ B], size_of(DIGIT) * a1.used) + intrinsics.mem_copy_non_overlapping(&a2.digit[0], &src.digit[2 * B], size_of(DIGIT) * a2.used) internal_clamp(a0) internal_clamp(a1) @@ -2340,7 +2339,7 @@ _private_int_dr_reduce :: proc(x, n: ^Int, k: DIGIT, allocator := context.alloca /* Zero words above m. */ - mem.zero_slice(x.digit[m + 1:][:x.used - m]) + _zero(x.digit[m + 1:][:x.used - m]) /* Clamp, sub and return. @@ -3137,7 +3136,7 @@ _private_copy_digits :: proc(dest, src: ^Int, digits: int, offset := int(0)) -> } digits = min(digits, len(src.digit), len(dest.digit)) - mem.copy_non_overlapping(&dest.digit[0], &src.digit[offset], size_of(DIGIT) * digits) + intrinsics.mem_copy_non_overlapping(&dest.digit[0], &src.digit[offset], size_of(DIGIT) * digits) return nil } @@ -3175,7 +3174,7 @@ _private_int_shl_leg :: proc(quotient: ^Int, digits: int, allocator := context.a } quotient.used += digits - mem.zero_slice(quotient.digit[:digits]) + _zero(quotient.digit[:digits]) return nil } diff --git a/core/math/big/radix.odin b/core/math/big/radix.odin index 0d57bc071..b4f5f875e 100644 --- a/core/math/big/radix.odin +++ b/core/math/big/radix.odin @@ -15,8 +15,7 @@ package math_big - Also look at extracting and splatting several digits at once. */ -import "base:intrinsics" -import "core:mem" +import "base:intrinsics" /* This version of `itoa` allocates on behalf of the caller. The caller must free the string. @@ -143,7 +142,7 @@ int_itoa_raw :: proc(a: ^Int, radix: i8, buffer: []u8, size := int(-1), zero_ter written = len(buffer) - available if written < size { diff := size - written - mem.copy(&buffer[0], &buffer[diff], written) + intrinsics.mem_copy(&buffer[0], &buffer[diff], written) } return written, nil } @@ -176,7 +175,7 @@ int_itoa_raw :: proc(a: ^Int, radix: i8, buffer: []u8, size := int(-1), zero_ter written = len(buffer) - available if written < size { diff := size - written - mem.copy(&buffer[0], &buffer[diff], written) + intrinsics.mem_copy(&buffer[0], &buffer[diff], written) } return written, nil } @@ -217,7 +216,7 @@ int_itoa_raw :: proc(a: ^Int, radix: i8, buffer: []u8, size := int(-1), zero_ter written = len(buffer) - available if written < size { diff := size - written - mem.copy(&buffer[0], &buffer[diff], written) + intrinsics.mem_copy(&buffer[0], &buffer[diff], written) } return written, nil } @@ -640,7 +639,7 @@ _itoa_raw_full :: proc(a: ^Int, radix: i8, buffer: []u8, zero_terminate := false written = len(buffer) - available if written < len(buffer) { diff := len(buffer) - written - mem.copy(&buffer[0], &buffer[diff], written) + intrinsics.mem_copy(&buffer[0], &buffer[diff], written) } return written, nil } @@ -688,7 +687,7 @@ _itoa_raw_old :: proc(a: ^Int, radix: i8, buffer: []u8, zero_terminate := false, written = len(buffer) - available if written < len(buffer) { diff := len(buffer) - written - mem.copy(&buffer[0], &buffer[diff], written) + intrinsics.mem_copy(&buffer[0], &buffer[diff], written) } return written, nil } \ No newline at end of file diff --git a/core/math/big/radix_os.odin b/core/math/big/radix_os.odin index 50454b679..793a6c88a 100644 --- a/core/math/big/radix_os.odin +++ b/core/math/big/radix_os.odin @@ -17,7 +17,7 @@ package math_big - Also look at extracting and splatting several digits at once. */ -import "core:mem" +import "base:runtime" import "core:os" /* @@ -69,7 +69,7 @@ internal_int_write_to_ascii_file :: proc(a: ^Int, filename: string, radix := i8( l := len(as) assert(l > 0) - data := transmute([]u8)mem.Raw_Slice{ + data := transmute([]u8)runtime.Raw_Slice{ data = raw_data(as), len = l, } diff --git a/core/math/rand/rand.odin b/core/math/rand/rand.odin index 2ed2c9e70..738de07e5 100644 --- a/core/math/rand/rand.odin +++ b/core/math/rand/rand.odin @@ -4,7 +4,6 @@ package rand import "base:intrinsics" import "base:runtime" import "core:math" -import "core:mem" Generator :: runtime.Random_Generator @@ -1031,11 +1030,11 @@ Returns: - err: An allocator error if one occured, `nil` otherwise Example: + import "base:runtime" import "core:math/rand" - import "core:mem" import "core:fmt" - perm_example :: proc() -> (err: mem.Allocator_Error) { + perm_example :: proc() -> (err: runtime.Allocator_Error) { data := rand.perm(4) or_return fmt.println(data) defer delete(data, context.allocator) @@ -1050,7 +1049,7 @@ Possible Output: */ @(require_results) -perm :: proc(n: int, allocator := context.allocator, gen := context.random_generator) -> (res: []int, err: mem.Allocator_Error) #optional_allocator_error { +perm :: proc(n: int, allocator := context.allocator, gen := context.random_generator) -> (res: []int, err: runtime.Allocator_Error) #optional_allocator_error { m := make([]int, n, allocator) or_return for i := 0; i < n; i += 1 { j := int_max(i+1, gen)