MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / period_certification

Function period_certification

deps/jemalloc/test/src/SFMT.c:383–409  ·  view source on GitHub ↗

* This function certificate the period of 2^{MEXP} */

Source from the content-addressed store, hash-verified

381 * This function certificate the period of 2^{MEXP}
382 */
383static void period_certification(sfmt_t *ctx) {
384 int inner = 0;
385 int i, j;
386 uint32_t work;
387 uint32_t *psfmt32 = &ctx->sfmt[0].u[0];
388
389 for (i = 0; i < 4; i++)
390 inner ^= psfmt32[idxof(i)] & parity[i];
391 for (i = 16; i > 0; i >>= 1)
392 inner ^= inner >> i;
393 inner &= 1;
394 /* check OK */
395 if (inner == 1) {
396 return;
397 }
398 /* check NG, and modification */
399 for (i = 0; i < 4; i++) {
400 work = 1;
401 for (j = 0; j < 32; j++) {
402 if ((work & parity[i]) != 0) {
403 psfmt32[idxof(i)] ^= work;
404 return;
405 }
406 work = work << 1;
407 }
408 }
409}
410
411/*----------------
412 PUBLIC FUNCTIONS

Callers 2

init_gen_randFunction · 0.70
init_by_arrayFunction · 0.70

Calls 1

idxofFunction · 0.70

Tested by

no test coverage detected