Removed mention of gtk3x-client from README.msys2
[freeciv.git] / utility / rand.h
blob3c9d37ff8628eea5031793b2a3ea3f1d9f8a93b1
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.
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
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 #include <stdint.h>
22 /* Utility */
23 #include "log.h"
24 #include "support.h" /* bool type */
26 /* This is duplicated in shared.h to avoid extra includes: */
27 #define MAX_UINT32 0xFFFFFFFF
29 typedef uint32_t RANDOM_TYPE;
31 typedef struct {
32 RANDOM_TYPE v[56];
33 int j, k, x;
34 bool is_init; /* initially 0 for static storage */
35 } RANDOM_STATE;
37 #define fc_rand(_size) \
38 fc_rand_debug((_size), "fc_rand", __FC_LINE__, __FILE__)
40 RANDOM_TYPE fc_rand_debug(RANDOM_TYPE size, const char *called_as,
41 int line, const char *file);
43 void fc_srand(RANDOM_TYPE seed);
45 bool fc_rand_is_init(void);
46 RANDOM_STATE fc_rand_state(void);
47 void fc_rand_set_state(RANDOM_STATE state);
49 void test_random1(int n);
51 /*===*/
53 #define fc_randomly(_seed, _size) \
54 fc_randomly_debug((_seed), (_size), "fc_randomly", __FC_LINE__, __FILE__)
56 RANDOM_TYPE fc_randomly_debug(RANDOM_TYPE seed, RANDOM_TYPE size,
57 const char *called_as,
58 int line, const char *file);
60 #ifdef __cplusplus
62 #endif /* __cplusplus */
64 #endif /* FC__RAND_H */