File tree Expand file tree Collapse file tree 12 files changed +18
-14
lines changed
Expand file tree Collapse file tree 12 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ const wyp2 = u64(0x8ebc6af09c88c6e3)
2121const wyp3 = u64 (0x589965cc75374cc3 )
2222const wyp4 = u64 (0x1d8e4e27c47d124f )
2323
24- @[inline]
24+ @[ignore_overflow; inline]
2525fn wyrotr (v u64 , k u32 ) u64 {
2626 return (v >> k) | (v << (64 - k))
2727}
2828
2929// wymum returns a hash by performing multiply and mix on `a` and `b`.
30- @[inline]
30+ @[ignore_overflow; inline]
3131pub fn wymum (a u64 , b u64 ) u64 {
3232 /*
3333 mut r := u128(a)
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ fn get_first_state(seed_data []u32) []u64 {
7272}
7373
7474// calculate_state returns a random state array calculated from the `seed_data`.
75+ @[ignore_overflow]
7576fn calculate_state (seed_data []u32 , mut state []u64 ) []u64 {
7677 lo := u64 (seed_data[0 ])
7778 hi := u64 (seed_data[1 ])
@@ -145,7 +146,7 @@ pub fn (mut rng MT19937RNG) u32() u32 {
145146const mag01 = [u64 (0 ), u64 (matrix_a)]
146147
147148// u64 returns a pseudorandom 64bit int in range `[0, 2⁶⁴)`.
148- @[direct_array_access; inline]
149+ @[direct_array_access; ignore_overflow; inline]
149150pub fn (mut rng MT19937RNG) u64 () u64 {
150151 mut x := u64 (0 )
151152 mut i := int (0 )
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ fn temper(prev u32) u32 {
7070}
7171
7272// u32 returns a pseudorandom 32-bit unsigned integer (`u32`).
73+ @[ignore_overflow]
7374pub fn (mut rng MuslRNG) u32 () u32 {
7475 rng.state = rng.state * 1103515245 + 12345
7576 // We are not dividing by 2 (or shifting right by 1)
Original file line number Diff line number Diff line change 2121// seed seeds the PCG32RNG with 4 `u32` values.
2222// The first 2 represent the 64-bit initial state as `[lower 32 bits, higher 32 bits]`
2323// The last 2 represent the 64-bit stream/step of the PRNG.
24+ @[ignore_overflow]
2425pub fn (mut rng PCG32RNG) seed (seed_data []u32 ) {
2526 if seed_data.len != 4 {
2627 eprintln ('PCG32RNG needs 4 u32s to be seeded. First two the initial state and the last two the stream/step. Both in little endian format: [lower, higher].' )
@@ -69,7 +70,7 @@ pub fn (mut rng PCG32RNG) u16() u16 {
6970}
7071
7172// u32 returns a pseudorandom unsigned `u32`.
72- @[inline]
73+ @[ignore_overflow; inline]
7374pub fn (mut rng PCG32RNG) u32 () u32 {
7475 oldstate := rng.state
7576 rng.state = oldstate * (6364136223846793005 ) + rng.inc
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ pub fn new_uuid_v7_session() UUIDSession {
8282}
8383
8484// next get a new uuid_v7 from current session.
85+ @[ignore_overflow]
8586pub fn (mut u UUIDSession) next () string {
8687 timestamp := u64 (time.now ().unix_nano ())
8788 // make place for holding 4 bits `version`
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module seed
66import time
77
88// nr_next returns a next value based on the previous value `prev`.
9- @[inline]
9+ @[ignore_overflow; inline]
1010fn nr_next (prev u32 ) u32 {
1111 return prev * 1664525 + 1013904223
1212}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ pub fn (mut rng SplitMix64RNG) u32() u32 {
7575}
7676
7777// u64 returns a pseudorandom 64bit int in range `[0, 2⁶⁴)`.
78- @[inline]
78+ @[ignore_overflow; inline]
7979pub fn (mut rng SplitMix64RNG) u64 () u64 {
8080 rng.state + = (0x9e3779b97f4a7c15 )
8181 mut z := rng.state
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ pub fn (mut rng WyRandRNG) u32() u32 {
8282}
8383
8484// u64 returns a pseudorandom 64bit int in range `[0, 2⁶⁴)`.
85- @[inline]
85+ @[ignore_overflow; inline]
8686pub fn (mut rng WyRandRNG) u64 () u64 {
8787 unsafe {
8888 mut seed1 := rng.state
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ pub fn (mut rng XOROS128PPRNG) u32() u32 {
8383}
8484
8585// u64 returns a pseudorandom 64-bit unsigned `u64`.
86- @[inline]
86+ @[ignore_overflow; inline]
8787pub fn (mut rng XOROS128PPRNG) u64 () u64 {
8888 oldstate0 := rng.state0
8989 mut oldstate1 := rng.state1
Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ fn test_time2_copied_from_time1_should_be_equal() {
371371fn test_subtract () {
372372 d_seconds := 3
373373 d_nanoseconds := 13
374- duration := d_seconds * second + d_nanoseconds * nanosecond
374+ duration := i64 ( d_seconds) * second + d_nanoseconds * nanosecond
375375 t1 := new (Time{
376376 year: 2000
377377 month: 5
You can’t perform that action at this time.
0 commit comments