]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/random-util.h
rlimit: don't assume getrlimit() always succeeds
[thirdparty/systemd.git] / src / basic / random-util.h
CommitLineData
3df3e884
RC
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
f0d09059 22#include <stdbool.h>
11c3a366 23#include <stddef.h>
3df3e884
RC
24#include <stdint.h>
25
f0d09059 26int acquire_random_bytes(void *p, size_t n, bool high_quality_required);
6a06b1a5 27void pseudorandom_bytes(void *p, size_t n);
3df3e884
RC
28void random_bytes(void *p, size_t n);
29void initialize_srand(void);
30
31static inline uint64_t random_u64(void) {
32 uint64_t u;
33 random_bytes(&u, sizeof(u));
34 return u;
35}
36
37static inline uint32_t random_u32(void) {
38 uint32_t u;
39 random_bytes(&u, sizeof(u));
40 return u;
41}