Freeciv-3.1: /fast/freeciv/nightly/S3_1/utility/rand.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
rand.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__RAND_H
14#define FC__RAND_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20#include <stdint.h>
21
22/* Utility */
23#include "log.h"
24#include "support.h" /* bool type */
25
26 typedef uint32_t RANDOM_TYPE;
27
28 typedef struct {
29 RANDOM_TYPE v[56];
30 int j, k, x;
31 bool is_init; /* initially FALSE for static storage */
32} RANDOM_STATE;
33
34#define fc_rand(_size) \
35 fc_rand_debug((_size), "fc_rand", __FC_LINE__, __FILE__)
36
37 RANDOM_TYPE fc_rand_debug(RANDOM_TYPE size, const char *called_as,
38 int line, const char *file);
39
40void fc_srand(RANDOM_TYPE seed);
41
42void fc_rand_uninit(void);
43bool fc_rand_is_init(void);
44 RANDOM_STATE fc_rand_state(void);
45void fc_rand_set_state(RANDOM_STATE state);
46
47void test_random1(int n);
48
49/*===*/
50
51#define fc_randomly(_seed, _size) \
52 fc_randomly_debug((_seed), (_size), "fc_randomly", __FC_LINE__, __FILE__)
53
54 RANDOM_TYPE fc_randomly_debug(RANDOM_TYPE seed, RANDOM_TYPE size,
55 const char *called_as,
56 int line, const char *file);
57
58#ifdef __cplusplus
59}
60#endif /* __cplusplus */
61
62#endif /* FC__RAND_H */
n
#define n
Definition astring.c:77
log.h
fc_rand_is_init
bool fc_rand_is_init(void)
Definition rand.c:167
fc_rand_state
RANDOM_STATE fc_rand_state(void)
Definition rand.c:175
fc_rand_debug
RANDOM_TYPE fc_rand_debug(RANDOM_TYPE size, const char *called_as, int line, const char *file)
Definition rand.c:81
fc_srand
void fc_srand(RANDOM_TYPE seed)
Definition rand.c:128
RANDOM_TYPE
uint32_t RANDOM_TYPE
Definition rand.h:26
fc_randomly_debug
RANDOM_TYPE fc_randomly_debug(RANDOM_TYPE seed, RANDOM_TYPE size, const char *called_as, int line, const char *file)
Definition rand.c:259
test_random1
void test_random1(int n)
Definition rand.c:220
fc_rand_uninit
void fc_rand_uninit(void)
Definition rand.c:159
fc_rand_set_state
void fc_rand_set_state(RANDOM_STATE state)
Definition rand.c:196
size
size_t size
Definition specvec.h:72
RANDOM_STATE
Definition rand.h:28
RANDOM_STATE::is_init
bool is_init
Definition rand.h:31
RANDOM_STATE::j
int j
Definition rand.h:30
support.h