mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-12 22:33:36 +00:00
Remove core:mem import from core:math/big.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user