mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

While the GCC and Clang compilers already define __ASSEMBLER__ automatically when compiling assembler code, __ASSEMBLY__ is a macro that only gets defined by the Makefiles in the kernel. This is bad since macros starting with two underscores are names that are reserved by the C language. It can also be very confusing for the developers when switching between userspace and kernelspace coding, or when dealing with uapi headers that rather should use __ASSEMBLER__ instead. So let's now standardize on the __ASSEMBLER__ macro that is provided by the compilers. This is almost a completely mechanical patch (done with a simple "sed -i" statement), with one comment tweaked manually in the arch/loongarch/include/asm/cpu.h file (it was missing the trailing underscores). Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
33 lines
832 B
C
33 lines
832 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2024 Xi Ruoyao <xry111@xry111.site>. All Rights Reserved.
|
|
*/
|
|
#ifndef __ASM_VDSO_GETRANDOM_H
|
|
#define __ASM_VDSO_GETRANDOM_H
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
#include <asm/unistd.h>
|
|
#include <asm/vdso/vdso.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(
|
|
" syscall 0\n"
|
|
: "=r" (ret)
|
|
: "r" (nr), "r" (buffer), "r" (len), "r" (flags)
|
|
: "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8",
|
|
"memory");
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* !__ASSEMBLER__ */
|
|
|
|
#endif /* __ASM_VDSO_GETRANDOM_H */
|