mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 19:13:47 +02:00
While the GCC and Clang compilers already define __ASSEMBLER__ automatically when compiling assembly code, __ASSEMBLY__ is a macro that only gets defined by the Makefiles in the kernel. This can be very confusing when switching between userspace and kernelspace coding, or when dealing with uapi headers that rather should use __ASSEMBLER__ instead. So let's standardize on the __ASSEMBLER__ macro that is provided by the compilers now. This originally was a completely mechanical patch (done with a simple "sed -i" statement), with some manual fixups during rebasing of the patch later. Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: linux-riscv@lists.infradead.org Signed-off-by: Thomas Huth <thuth@redhat.com> Link: https://lore.kernel.org/r/20250606070952.498274-3-thuth@redhat.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
31 lines
752 B
C
31 lines
752 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2025 Xi Ruoyao <xry111@xry111.site>. All Rights Reserved.
|
|
*/
|
|
#ifndef __ASM_VDSO_GETRANDOM_H
|
|
#define __ASM_VDSO_GETRANDOM_H
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
#include <asm/unistd.h>
|
|
|
|
static __always_inline ssize_t getrandom_syscall(void *_buffer, size_t _len, unsigned int _flags)
|
|
{
|
|
register long ret asm("a0");
|
|
register long nr asm("a7") = __NR_getrandom;
|
|
register void *buffer asm("a0") = _buffer;
|
|
register size_t len asm("a1") = _len;
|
|
register unsigned int flags asm("a2") = _flags;
|
|
|
|
asm volatile ("ecall\n"
|
|
: "=r" (ret)
|
|
: "r" (nr), "r" (buffer), "r" (len), "r" (flags)
|
|
: "memory");
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* !__ASSEMBLER__ */
|
|
|
|
#endif /* __ASM_VDSO_GETRANDOM_H */
|