File Index
Files and directories
Sign in
FILE

getrandom.h

File preview with syntax highlighting.

linux-6.19.14/arch/riscv/include/asm/vdso/getrandom.h C
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright (C) 2025 Xi Ruoyao <xry111@xry111.site>. All Rights Reserved.
 4 */
 5#ifndef __ASM_VDSO_GETRANDOM_H
 6#define __ASM_VDSO_GETRANDOM_H
 7
 8#ifndef __ASSEMBLER__
 9
10#include <asm/unistd.h>
11
12static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsigned int _flags)
13{
14	register long ret asm("a0");
15	register long nr asm("a7") = __NR_getrandom;
16	register void *buffer asm("a0") = _buffer;
17	register size_t len asm("a1") = _len;
18	register unsigned int flags asm("a2") = _flags;
19
20	asm volatile ("ecall\n"
21		      : "=r" (ret)
22		      : "r" (nr), "r" (buffer), "r" (len), "r" (flags)
23		      : "memory");
24
25	return ret;
26}
27
28#endif /* !__ASSEMBLER__ */
29
30#endif /* __ASM_VDSO_GETRANDOM_H */
~/ Read-only file preview.