* This function certificate the period of 2^{MEXP} */
| 381 | * This function certificate the period of 2^{MEXP} |
| 382 | */ |
| 383 | static 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 |
no test coverage detected