MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gen_rand64

Function gen_rand64

app/redis-6.2.6/deps/jemalloc/test/src/SFMT.c:482–508  ·  view source on GitHub ↗

* This function generates and returns 64-bit pseudorandom number. * init_gen_rand or init_by_array must be called before this function. * The function gen_rand64 should not be called after gen_rand32, * unless an initialization is again executed. * @return 64-bit pseudorandom number */

Source from the content-addressed store, hash-verified

480 * @return 64-bit pseudorandom number
481 */
482uint64_t gen_rand64(sfmt_t *ctx) {
483#if defined(BIG_ENDIAN64) && !defined(ONLY64)
484 uint32_t r1, r2;
485 uint32_t *psfmt32 = &ctx->sfmt[0].u[0];
486#else
487 uint64_t r;
488 uint64_t *psfmt64 = (uint64_t *)&ctx->sfmt[0].u[0];
489#endif
490
491 assert(ctx->initialized);
492 assert(ctx->idx % 2 == 0);
493
494 if (ctx->idx >= N32) {
495 gen_rand_all(ctx);
496 ctx->idx = 0;
497 }
498#if defined(BIG_ENDIAN64) && !defined(ONLY64)
499 r1 = psfmt32[ctx->idx];
500 r2 = psfmt32[ctx->idx + 1];
501 ctx->idx += 2;
502 return ((uint64_t)r2 << 32) | r1;
503#else
504 r = psfmt64[ctx->idx / 2];
505 ctx->idx += 2;
506 return r;
507#endif
508}
509
510/* Generate a random integer in [0..limit). */
511uint64_t gen_rand64_range(sfmt_t *ctx, uint64_t limit) {

Callers 4

TEST_BEGINFunction · 0.85
TEST_BEGINFunction · 0.85
gen_rand64_rangeFunction · 0.85
genrand_res53Function · 0.85

Calls 1

gen_rand_allFunction · 0.70

Tested by

no test coverage detected