1 /* Copyright (C) 2015 Bernhard Reutner-Fischer
2  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
3 */
4 
5 #ifndef	_SYS_RANDOM_H
6 #define	_SYS_RANDOM_H	1
7 
8 #include <features.h>
9 #include <stddef.h>
10 
11 __BEGIN_DECLS
12 
13 #include <bits/types.h>
14 
15 #ifndef __ssize_t_defined
16 typedef __ssize_t ssize_t;
17 # define __ssize_t_defined
18 #endif
19 
20 #if defined __UCLIBC_LINUX_SPECIFIC__
21 # if 0 /*def __ASSUME_GETRANDOM_SYSCALL */
22 #  include <linux/random.h>
23 # else
24 #  undef GRND_NONBLOCK
25 #  undef GRND_RANDOM
26 /*
27  * Flags for getrandom(2)
28  *
29  * GRND_NONBLOCK	Don't block and return EAGAIN instead
30  * GRND_RANDOM		Use the /dev/random pool instead of /dev/urandom
31  * GRND_INSECURE	Write random data that may not be cryptographically secure.
32  */
33 #  define GRND_NONBLOCK	0x0001
34 #  define GRND_RANDOM	0x0002
35 #  define GRND_INSECURE 0x0004
36 # endif
37 extern ssize_t getrandom(void *__buf, size_t count, unsigned int flags)
38 	   __nonnull ((1)) __wur;
39 
40 /* OpenBSD-compatible access to random bytes.
41    May be a cancellation point here, unlike in glibc/musl.  */
42 # ifndef __getentropy_defined
43 extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
44 #  define __getentropy_defined
45 # endif
46 #endif
47 
48 __END_DECLS
49 
50 #endif /* sys/random.h */
51