mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
9b51beeb2a
Previously, __internal_syscall() compiled into asm-code that unconditionally sets the syscall argument registers a0 to a5. For example, the instruction sequence for a exit syscall looked like this: li a0, 1 # in ther caller of exit() # ... # in newlib: li a1, 0 # unused arguments li a2, 0 li a3, 0 li a4, 0 li a5, 0 li a7, 93 # exit syscall number (i.e. the binary contains then 5 superfluous instructions for this one argument syscall) This commit changes the RISC-V syscall code such that only the required syscall argument registers are set. GCC detects that argc is known at compile time and thus evaluates all the if-statements where argc is used at compile time (tested with -O2 and -Os).
9 lines
238 B
C
9 lines
238 B
C
#include <machine/syscall.h>
|
|
#include "internal_syscall.h"
|
|
|
|
/* Establish a new name for an existing file. */
|
|
int _link(const char *old_name, const char *new_name)
|
|
{
|
|
return syscall_errno (SYS_link, 2, old_name, new_name, 0, 0, 0, 0);
|
|
}
|