lib: Add _sys_call_5 for Linux RISC-V64.

* include/linux/syscall.h (_sys_call5): Declare 5-argument syscall needed
for SYS_renameat2, currently only used on RISC-V64.
* lib/linux/riscv64-mes-gcc/syscall.c (__sys_call5, _sys_call5):
Implement it.
This commit is contained in:
W. J. van der Laan 2021-04-04 08:07:24 +00:00 committed by Janneke Nieuwenhuizen
parent f5d6a7b100
commit e07d1052aa
2 changed files with 33 additions and 0 deletions

View file

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -26,6 +27,7 @@ long _sys_call1 (long sys_call, long one);
long _sys_call2 (long sys_call, long one, long two);
long _sys_call3 (long sys_call, long one, long two, long three);
long _sys_call4 (long sys_call, long one, long two, long three, long four);
long _sys_call5 (long sys_call, long one, long two, long three, long four, long five);
long _sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six);
#endif //__MES_SYSCALL_H

View file

@ -93,6 +93,23 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
);
return __a0;
}
long
__sys_call5 (long sys_call, long one, long two, long three, long four, long five)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
register long __a1 asm ("a1") = two;
register long __a2 asm ("a2") = three;
register long __a3 asm ("a3") = four;
register long __a4 asm ("a4") = five;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), "r" (__a4)
);
return __a0;
}
// *INDENT-ON*
long
@ -164,3 +181,17 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
errno = 0;
return r;
}
long
_sys_call5 (long sys_call, long one, long two, long three, long four, long five)
{
long r = __sys_call5 (sys_call, one, two, three, four, five);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}