[go: up one dir, main page]

File: random.h

package info (click to toggle)
cctools 9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 44,624 kB
  • sloc: ansic: 192,539; python: 20,827; cpp: 20,199; sh: 11,719; perl: 4,106; xml: 3,688; makefile: 1,224
file content (62 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * Copyright (C) 2014- The University of Notre Dame
 * This software is distributed under the GNU General Public License.
 * See the file COPYING for details.
 */

#ifndef RANDOM_H
#define RANDOM_H

#include <stdint.h>
#include <stdlib.h>

/** @file random.h A PRNG library.
 */

/** Initialize the random number generator.
 *
 * Uses system PRNG devices to seed the library PRNG.
 */
void    random_init (void);

/** Get a random int.
 *
 * @return a random int.
 */
#define random_int()   ((int) random_int64())

/** Get a random unsigned int.
 *
 * @return a random unsigned int.
 */
#define random_uint()   ((unsigned) random_int64())

/** Get a random int32_t.
 *
 * @return a random int32_t.
 */
#define random_int32() ((int32_t) random_int64())

/** Get a random int64_t.
 *
 * @return a random int64_t.
 */
int64_t random_int64 (void);

/** Insert random data into an array.
 *
 * @param m the memory to fill.
 * @param l the length of the m.
 */
void    random_array (void *m, size_t l);

/** Insert a random string in hexadecimal.
 *
 * @param s the location in the string.
 * @param l the number of characters to insert. Includes NUL byte!
 */
void    random_hex   (char *s, size_t l);

#endif

/* vim: set noexpandtab tabstop=4: */