[v2,3/5] LoongArch: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux

Message ID 20230325140815.4170296-4-xry111@xry111.site
State Dropped
Series linux: Avoid va_list for generic syscall wrappers if possible |


Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Xi Ruoyao March 25, 2023, 2:08 p.m. UTC
  LoongArch calling convention treats the non-floating-point variable
arguments same as named ones, and when each argument is an integer
not wider than long or a pointer, the ith argument is in register $ai
(0 <= i < 8) or the stack slot at ($sp + sizeof(long) * (i - 8))
(i >= 8) no matter how many arguments are passed. So we can define
__ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack stores in the
syscall wrappers caused by va_start.
 .../sysv/linux/loongarch/kernel-features.h    | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/kernel-features.h


diff --git a/sysdeps/unix/sysv/linux/loongarch/kernel-features.h b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h
new file mode 100644
index 0000000000..f862d0623f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h
@@ -0,0 +1,29 @@ 
+/* Set flags signalling availability of kernel features based on given
+   kernel version number.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   Lesser General Public License for more details.
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+#include_next <kernel-features.h>
+/* Define this if the calling convention for passing x named arguments and y
+   variable arguments is same as passing (x + y) named arguments, while each
+   argument is either an integer of which the width is less than or equal to
+   "long", or a pointer; and an argument can be fetched from the same register
+   or the same offset from the stack pointer no matter how many (maybe zero)
+   arguments are passed after it.  It avoids useless stack stores caused by
+   usage of va_start.  */