]> git.proxmox.com Git - libgit2.git/blob - src/util/rand.h
New upstream version 1.5.0+ds
[libgit2.git] / src / util / rand.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_rand_h__
8 #define INCLUDE_rand_h__
9
10 #include "git2_util.h"
11
12 /**
13 * Initialize the random number generation subsystem. This will
14 * seed the random number generator with the system's entropy pool,
15 * if available, and will fall back to the current time and
16 * system information if not.
17 */
18 int git_rand_global_init(void);
19
20 /**
21 * Seed the pseudo-random number generator. This is not needed to be
22 * called; the PRNG is seeded by `git_rand_global_init`, but it may
23 * be useful for testing. When the same seed is specified, the same
24 * sequence of random numbers from `git_rand_next` is emitted.
25 *
26 * @param seed the seed to use
27 */
28 void git_rand_seed(uint64_t seed);
29
30 /**
31 * Get the next pseudo-random number in the sequence.
32 *
33 * @return a 64-bit pseudo-random number
34 */
35 uint64_t git_rand_next(void);
36
37 #endif