xref: /linux/tools/include/nolibc/sys/random.h (revision 015a99fa76650e7d6efa3e36f20c0f5b346fe9ce)
1*801f020bSThomas Weißschuh /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2*801f020bSThomas Weißschuh /*
3*801f020bSThomas Weißschuh  * random definitions for NOLIBC
4*801f020bSThomas Weißschuh  * Copyright (C) 2025 Thomas Weißschuh <thomas.weissschuh@linutronix.de>
5*801f020bSThomas Weißschuh  */
6*801f020bSThomas Weißschuh 
7*801f020bSThomas Weißschuh /* make sure to include all global symbols */
8*801f020bSThomas Weißschuh #include "../nolibc.h"
9*801f020bSThomas Weißschuh 
10*801f020bSThomas Weißschuh #ifndef _NOLIBC_SYS_RANDOM_H
11*801f020bSThomas Weißschuh #define _NOLIBC_SYS_RANDOM_H
12*801f020bSThomas Weißschuh 
13*801f020bSThomas Weißschuh #include "../arch.h"
14*801f020bSThomas Weißschuh #include "../sys.h"
15*801f020bSThomas Weißschuh 
16*801f020bSThomas Weißschuh #include <linux/random.h>
17*801f020bSThomas Weißschuh 
18*801f020bSThomas Weißschuh /*
19*801f020bSThomas Weißschuh  * ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
20*801f020bSThomas Weißschuh  */
21*801f020bSThomas Weißschuh 
22*801f020bSThomas Weißschuh static __attribute__((unused))
sys_getrandom(void * buf,size_t buflen,unsigned int flags)23*801f020bSThomas Weißschuh ssize_t sys_getrandom(void *buf, size_t buflen, unsigned int flags)
24*801f020bSThomas Weißschuh {
25*801f020bSThomas Weißschuh        return my_syscall3(__NR_getrandom, buf, buflen, flags);
26*801f020bSThomas Weißschuh }
27*801f020bSThomas Weißschuh 
28*801f020bSThomas Weißschuh static __attribute__((unused))
getrandom(void * buf,size_t buflen,unsigned int flags)29*801f020bSThomas Weißschuh ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)
30*801f020bSThomas Weißschuh {
31*801f020bSThomas Weißschuh        return __sysret(sys_getrandom(buf, buflen, flags));
32*801f020bSThomas Weißschuh }
33*801f020bSThomas Weißschuh 
34*801f020bSThomas Weißschuh #endif /* _NOLIBC_SYS_RANDOM_H */
35