FreeBSD kernel kern code
subr_prng.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/pcpu.h>
#include <sys/prng.h>
#include <sys/smp.h>
#include <sys/systm.h>
Include dependency graph for subr_prng.c:

Go to the source code of this file.

Data Structures

struct  pcg64u_random_t
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void pcg64u_srandom_r (pcg64u_random_t *state64, uint64_t seed)
 
static uint64_t pcg64u_random_r (pcg64u_random_t *state64)
 
static uint64_t pcg64u_boundedrand_r (pcg64u_random_t *state64, uint64_t bound)
 
 DPCPU_DEFINE_STATIC (pcg32u_random_t, pcpu_prng32_state)
 
 DPCPU_DEFINE_STATIC (pcg64u_random_t, pcpu_prng64_state)
 
static void prng_init (void *dummy __unused)
 
 SYSINIT (prng_init, SI_SUB_CPU, SI_ORDER_ANY, prng_init, NULL)
 
uint32_t prng32 (void)
 
uint32_t prng32_bounded (uint32_t bound)
 
uint64_t prng64 (void)
 
uint64_t prng64_bounded (uint64_t bound)
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DPCPU_DEFINE_STATIC() [1/2]

DPCPU_DEFINE_STATIC ( pcg32u_random_t  ,
pcpu_prng32_state   
)

◆ DPCPU_DEFINE_STATIC() [2/2]

DPCPU_DEFINE_STATIC ( pcg64u_random_t  ,
pcpu_prng64_state   
)

◆ pcg64u_boundedrand_r()

static uint64_t pcg64u_boundedrand_r ( pcg64u_random_t state64,
uint64_t  bound 
)
inlinestatic

Definition at line 59 of file subr_prng.c.

References pcg64u_random_r().

Referenced by prng64_bounded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcg64u_random_r()

static uint64_t pcg64u_random_r ( pcg64u_random_t state64)
inlinestatic

Definition at line 52 of file subr_prng.c.

References pcg64u_random_t::states.

Referenced by pcg64u_boundedrand_r(), and prng64().

Here is the caller graph for this function:

◆ pcg64u_srandom_r()

static void pcg64u_srandom_r ( pcg64u_random_t state64,
uint64_t  seed 
)
inlinestatic

Definition at line 45 of file subr_prng.c.

References pcg64u_random_t::states.

Referenced by prng_init().

Here is the caller graph for this function:

◆ prng32()

uint32_t prng32 ( void  )

Definition at line 90 of file subr_prng.c.

◆ prng32_bounded()

uint32_t prng32_bounded ( uint32_t  bound)

Definition at line 101 of file subr_prng.c.

Referenced by vn_lock_pair_pause().

Here is the caller graph for this function:

◆ prng64()

uint64_t prng64 ( void  )

Definition at line 112 of file subr_prng.c.

References pcg64u_random_r().

Here is the call graph for this function:

◆ prng64_bounded()

uint64_t prng64_bounded ( uint64_t  bound)

Definition at line 123 of file subr_prng.c.

References pcg64u_boundedrand_r().

Here is the call graph for this function:

◆ prng_init()

static void prng_init ( void *dummy  __unused)
static

Definition at line 74 of file subr_prng.c.

References pcg64u_srandom_r().

Here is the call graph for this function:

◆ SYSINIT()

SYSINIT ( prng_init  ,
SI_SUB_CPU  ,
SI_ORDER_ANY  ,
prng_init  ,
NULL   
)