xref: /linux/arch/s390/include/asm/vdso/getrandom.h (revision 20bed0d6ff62d985fe8222958825504b8aad4e88)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __ASM_VDSO_GETRANDOM_H
4 #define __ASM_VDSO_GETRANDOM_H
5 
6 #ifndef __ASSEMBLER__
7 
8 #include <vdso/datapage.h>
9 #include <asm/syscall.h>
10 #include <asm/unistd.h>
11 #include <asm/page.h>
12 
13 /**
14  * getrandom_syscall - Invoke the getrandom() syscall.
15  * @buffer:	Destination buffer to fill with random bytes.
16  * @len:	Size of @buffer in bytes.
17  * @flags:	Zero or more GRND_* flags.
18  * Returns:	The number of random bytes written to @buffer, or a negative value indicating an error.
19  */
20 static __always_inline ssize_t getrandom_syscall(void *buffer, size_t len, unsigned int flags)
21 {
22 	return syscall3(__NR_getrandom, (long)buffer, (long)len, (long)flags);
23 }
24 
25 #endif /* !__ASSEMBLER__ */
26 
27 #endif /* __ASM_VDSO_GETRANDOM_H */
28