Files
2026-04-14 14:03:04 -04:00

45 lines
1.3 KiB
C

/* SplitMix32 test program
* Copyright (c) 2022 Joel K. Pettersson
* <joelkpettersson@gmail.com>.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "testwrite.h"
#include "muvaror32.h"
/*
* Here's SplitMix32 for comparison and a quick test.
*/
//FIBH32 = 2654435769U
/**
* Get next value for and update \p pos.
*/
static inline uint32_t splitmix32(uint32_t *restrict pos) {
uint32_t s = *pos += FIBH32;
s ^= s >> 16;
s *= 0x85ebca6b;
s ^= s >> 13;
s *= 0xc2b2ae35;
s ^= s >> 16;
return s;
}
int main(int argc, char *argv[]) {
uint32_t pos = 0;
for (;;) {
/* SplitMix32 test */
add_output(splitmix32(&pos));
}
return 0;
}