MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / pick

Function pick

3rd/mimalloc-2.0.9/test/test-stress.c:67–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65typedef uintptr_t* random_t;
66
67static uintptr_t pick(random_t r) {
68 uintptr_t x = *r;
69#if (UINTPTR_MAX > UINT32_MAX)
70 // by Sebastiano Vigna, see: <http://xoshiro.di.unimi.it/splitmix64.c>
71 x ^= x >> 30;
72 x *= 0xbf58476d1ce4e5b9UL;
73 x ^= x >> 27;
74 x *= 0x94d049bb133111ebUL;
75 x ^= x >> 31;
76#else
77 // by Chris Wellons, see: <https://nullprogram.com/blog/2018/07/31/>
78 x ^= x >> 16;
79 x *= 0x7feb352dUL;
80 x ^= x >> 15;
81 x *= 0x846ca68bUL;
82 x ^= x >> 16;
83#endif
84 *r = x;
85 return x;
86}
87
88static bool chance(size_t perc, random_t r) {
89 return (pick(r) % 100 <= perc);

Callers 3

chanceFunction · 0.85
stressFunction · 0.85
leakFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected