cctools
random.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 The University of Notre Dame
3  * This software is distributed under the GNU General Public License.
4  * See the file COPYING for details.
5  */
6 
7 #ifndef RANDOM_H
8 #define RANDOM_H
9 
10 #include <stdint.h>
11 #include <stdlib.h>
12 
20 void random_init (void);
21 
26 #define random_int() ((int) random_int64())
27 
32 #define random_uint() ((unsigned) random_int64())
33 
38 #define random_int32() ((int32_t) random_int64())
39 
44 int64_t random_int64 (void);
45 
50 double random_double (void);
51 
57 void random_array (void *m, size_t l);
58 
64 void random_hex (char *s, size_t l);
65 
66 #endif
67 
68 /* vim: set noexpandtab tabstop=8: */
random_array
void random_array(void *m, size_t l)
Insert random data into an array.
random_double
double random_double(void)
Get a random double from (0, 1)
random_int64
int64_t random_int64(void)
Get a random int64_t.
random_init
void random_init(void)
Initialize the random number generator.
random_hex
void random_hex(char *s, size_t l)
Insert a random string in hexadecimal.