aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakubtomsu <66876057+jakubtomsu@users.noreply.github.com>2026-02-17 18:34:37 +0100
committerjakubtomsu <66876057+jakubtomsu@users.noreply.github.com>2026-02-17 18:34:37 +0100
commite8aac50f8b244eed0fc872010788c19a12f8a87b (patch)
tree28a9ceed45c8b4ea747222ccbfb2c4306b531e95
parent97e09b19d14528a216b502d46b3ea8090a1d1887 (diff)
math/rand math/bits dependency
-rw-r--r--core/math/rand/rand_xoshiro256.odin12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/math/rand/rand_xoshiro256.odin b/core/math/rand/rand_xoshiro256.odin
index 7326ba8d5..6f5dbe545 100644
--- a/core/math/rand/rand_xoshiro256.odin
+++ b/core/math/rand/rand_xoshiro256.odin
@@ -3,8 +3,6 @@ package rand
import "base:intrinsics"
import "base:runtime"
-import "core:math/bits"
-
/*
The state for a xoshiro256** pseudorandom generator.
*/
@@ -17,7 +15,7 @@ xoshiro256_random_generator_proc :: proc(data: rawptr, mode: runtime.Random_Gene
read_u64 :: proc "contextless" (r: ^Xoshiro256_Random_State) -> u64 {
// xoshiro256** output function and state transition
- result := bits.rotate_left64(r.s[1] * 5, 7) * 9
+ result := rotate_left64(r.s[1] * 5, 7) * 9
t := r.s[1] << 17
r.s[2] = r.s[2] ~ r.s[0]
@@ -25,9 +23,15 @@ xoshiro256_random_generator_proc :: proc(data: rawptr, mode: runtime.Random_Gene
r.s[1] = r.s[1] ~ r.s[2]
r.s[0] = r.s[0] ~ r.s[3]
r.s[2] = r.s[2] ~ t
- r.s[3] = bits.rotate_left64(r.s[3], 45)
+ r.s[3] = rotate_left64(r.s[3], 45)
return result
+
+ rotate_left64 :: proc "contextless" (x: u64, k: int) -> u64 {
+ n :: 64
+ s := uint(k) & (n-1)
+ return x << s | x >> (n-s)
+ }
}
@(thread_local)