]>
git.proxmox.com Git - libgit2.git/blob - src/util/rand.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_rand_h__
8 #define INCLUDE_rand_h__
10 #include "git2_util.h"
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.
18 int git_rand_global_init(void);
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.
26 * @param seed the seed to use
28 void git_rand_seed(uint64_t seed
);
31 * Get the next pseudo-random number in the sequence.
33 * @return a 64-bit pseudo-random number
35 uint64_t git_rand_next(void);