summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/syscall.c
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2017-12-14 15:29:06 +0900
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2018-01-15 20:01:14 +0000
commitc55cb0c0bcf04c7ad1f6f48d914850f516bd106c (patch)
tree973b776ec66dad876f42e3f89f641c216597e2c2 /libc/sysdeps/linux/common/syscall.c
parentfef474b437d14723f4b97608472f821ca67834b1 (diff)
syscall: Make common implementation match unistd.h
The definition of syscall() in unistd.h is with varargs. Traditionally the common implementation in uclibc has been with regular arguments. This patch updates that by using varargs. This has caused issues on architectures like or1k which have different calling conventions for varargs and regular arg parameters. The implementation here is based on an implementation from Joel Stanley <joel@jms.id.au>. There is a difference that I do not initialize the stack args with 0 as they are immediately overwritten by va_args. Signed-off-by: Stafford Horne <shorne@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common/syscall.c')
-rw-r--r--libc/sysdeps/linux/common/syscall.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/common/syscall.c b/libc/sysdeps/linux/common/syscall.c
index 61f798e2c..d173d2c54 100644
--- a/libc/sysdeps/linux/common/syscall.c
+++ b/libc/sysdeps/linux/common/syscall.c
@@ -4,9 +4,25 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <stdarg.h>
#include <sys/syscall.h>
+#include <unistd.h>
-long syscall(long sysnum, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
+long syscall(long sysnum, ...)
{
+
+ unsigned long arg1, arg2, arg3, arg4, arg5, arg6;
+ va_list arg;
+
+ va_start (arg, sysnum);
+ arg1 = va_arg (arg, unsigned long);
+ arg2 = va_arg (arg, unsigned long);
+ arg3 = va_arg (arg, unsigned long);
+ arg4 = va_arg (arg, unsigned long);
+ arg5 = va_arg (arg, unsigned long);
+ arg6 = va_arg (arg, unsigned long);
+ va_end (arg);
+
+ __asm__ volatile ( "" ::: "memory" );
return INLINE_SYSCALL_NCS(sysnum, 6, arg1, arg2, arg3, arg4, arg5, arg6);
}