Freeciv-3.3
Loading...
Searching...
No Matches
Functions
randseed.c File Reference
#include "fc_prehdrs.h"
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include "fcintl.h"
#include "log.h"
#include "randseed.h"

Go to the source code of this file.

Functions

static bool generate_seed_getentropy (randseed *ret)
 
static bool generate_seed_bcryptgenrandom (randseed *ret)
 
static bool generate_seed_urandom (randseed *ret)
 
static bool generate_seed_clock_gettime (randseed *ret)
 
static bool generate_seed_time (randseed *ret)
 
randseed generate_game_seed (void)
 

Function Documentation

◆ generate_game_seed()

randseed generate_game_seed ( void  )

Return a random 32-bit value to use as game seed, by whatever means the underlying system provides.

Definition at line 192 of file randseed.c.

Referenced by init_game_seed().

◆ generate_seed_bcryptgenrandom()

static bool generate_seed_bcryptgenrandom ( randseed ret)
static

Read a 32-bit random value using BCryptGenRandom(), if available. (Windows) Return FALSE on error, otherwise return TRUE and store seed in *ret.

Definition at line 77 of file randseed.c.

Referenced by generate_game_seed().

◆ generate_seed_clock_gettime()

static bool generate_seed_clock_gettime ( randseed ret)
static

Generate a 32-bit random-ish value from the current time, using clock_gettime(), if available. (POSIX-compatible systems.) Return FALSE on error, otherwise return TRUE and store seed in *ret.

Definition at line 148 of file randseed.c.

Referenced by generate_game_seed().

◆ generate_seed_getentropy()

static bool generate_seed_getentropy ( randseed ret)
static

Read a 32-bit random value using getentropy(), if available. (Linux, FreeBSD, OpenBSD, macOS) Return FALSE on error, otherwise return TRUE and store seed in *ret.

Definition at line 52 of file randseed.c.

Referenced by generate_game_seed().

◆ generate_seed_time()

static bool generate_seed_time ( randseed ret)
static

Generate a lousy 32-bit random-ish value from the current time. Return TRUE and store seed in *ret.

Definition at line 180 of file randseed.c.

Referenced by generate_game_seed().

◆ generate_seed_urandom()

static bool generate_seed_urandom ( randseed ret)
static

Read a 32-bit random value using /dev/urandom, if available. (Most Unix-like systems) Return FALSE on error, otherwise return TRUE and store seed in *ret.

Definition at line 98 of file randseed.c.

Referenced by generate_game_seed().