Changeset 6a823241
- Timestamp:
- Feb 11, 2022, 8:33:38 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 5910fc0
- Parents:
- 454b4e0
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.cfa
r454b4e0 r6a823241 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jan 15 14:33:21202213 // Update Count : 59512 // Last Modified On : Thu Feb 10 22:41:39 2022 13 // Update Count : 602 14 14 // 15 15 … … 230 230 void set_seed( PRNG & prng, uint32_t seed_ ) with( prng ) { state = seed = seed_; GENERATOR( state ); } // set seed 231 231 232 void set_seed( uint32_t seed ) { __global_random_s eed = seed; GENERATOR( __global_random_state ); }232 void set_seed( uint32_t seed ) { __global_random_state = __global_random_seed = seed; GENERATOR( __global_random_state ); } 233 233 uint32_t get_seed() { return __global_random_seed; } 234 234 uint32_t prng( void ) { return GENERATOR( __global_random_state ); } // [0,UINT_MAX] -
libcfa/src/stdlib.hfa
r454b4e0 r6a823241 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jan 15 09:57:28 202213 // Update Count : 64 012 // Last Modified On : Thu Feb 10 18:34:58 2022 13 // Update Count : 641 14 14 // 15 15 … … 412 412 void set_seed( PRNG & prng, uint32_t seed_ ); 413 413 static inline { 414 uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )) with( prng ) { callcnt += 1; return LCG( state ); } // [0,UINT_MAX]415 414 void ?{}( PRNG & prng ) { set_seed( prng, rdtscl() ); } // random seed 416 415 void ?{}( PRNG & prng, uint32_t seed ) { set_seed( prng, seed ); } // fixed seed 417 416 uint32_t get_seed( PRNG & prng ) __attribute__(( warn_unused_result )) with( prng ) { return seed; } // get seed 417 uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )) with( prng ) { callcnt += 1; return LCG( state ); } // [0,UINT_MAX] 418 418 uint32_t prng( PRNG & prng, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( prng ) % u; } // [0,u) 419 419 uint32_t prng( PRNG & prng, uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( prng, u - l + 1 ) + l; } // [l,u]
Note: See TracChangeset
for help on using the changeset viewer.