From 27d7d4e795f362d80c40c125d3868b9a6a13b265 Mon Sep 17 00:00:00 2001 From: stderr64 Date: Thu, 29 Oct 2026 22:38:01 +0200 Subject: Changed function names --- include/xorshift.h | 8 ++++---- xorshift.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/xorshift.h b/include/xorshift.h index 0e58967..fd33507 100644 --- a/include/xorshift.h +++ b/include/xorshift.h @@ -1,4 +1,4 @@ -bool initialize_states(); -uint32_t get_random_output(); -uint32_t get_uniform_uint( uint32_t min, uint32_t max ); -void clear_rng_state(); +bool xorshift_initialize_states(); +uint32_t xorshift_get_random_output(); +uint32_t xorshift_get_uniform_uint( uint32_t min, uint32_t max ); +void xorshift_clear_rng_state(); diff --git a/xorshift.c b/xorshift.c index 528f3db..a18fbc9 100644 --- a/xorshift.c +++ b/xorshift.c @@ -13,7 +13,7 @@ static struct rng_state global_rng_state; -__attribute__((visibility("default"))) bool initialize_states(){ +__attribute__((visibility("default"))) bool xorshift_initialize_states(){ assert( (sizeof(uint32_t) * CHAR_BIT) == 32 ); memset( (void*)&global_rng_state, 0, sizeof(struct rng_state) ); ssize_t state_bytes_read = 0; @@ -28,13 +28,13 @@ __attribute__((visibility("default"))) bool initialize_states(){ return true; } -__attribute__((visibility("default"))) uint32_t get_random_output(){ +__attribute__((visibility("default"))) uint32_t xorshift_get_random_output(){ size_t use_state = global_rng_state.state_idx; global_rng_state.state_idx = global_rng_state.states[use_state] >> SHIFT_VALUE; if ( global_rng_state.gen_period_ctr >= 0xffffffff ){ global_rng_state.period_end_ctr++; if ( global_rng_state.period_end_ctr >= STATE_SIZE ){ - assert( initialize_states() == true ); + assert( xorshift_initialize_states() == true ); global_rng_state.period_end_ctr = 0; } global_rng_state.gen_period_ctr = 0; @@ -46,20 +46,20 @@ __attribute__((visibility("default"))) uint32_t get_random_output(){ return global_rng_state.states[use_state] * OUTPUT_MULTIPLIER; } -__attribute__((visibility("default"))) uint32_t get_uniform_uint( uint32_t min, uint32_t max ){ +__attribute__((visibility("default"))) uint32_t xorshift_get_uniform_uint( uint32_t min, uint32_t max ){ if ( max <= min ) return min; uint32_t ncount = (max - min) + 1; uint32_t upper_bound = 0xffffffff - (0xffffffff % ncount); - uint32_t gen_output = get_random_output(); + uint32_t gen_output = xorshift_get_random_output(); if ( gen_output > upper_bound ){ while ( gen_output > upper_bound ) - gen_output = get_random_output(); + gen_output = xorshift_get_random_output(); } return (gen_output % max) + min; } -__attribute__((visibility("default"))) void clear_rng_state(){ +__attribute__((visibility("default"))) bool xorshift_clear_rng_state(){ memset( (void*)&global_rng_state, 0, sizeof(struct rng_state) ); - return; + return true; } -- cgit v1.3.1-9-g1d36