1 /* Indirect system call.  Linux generic implementation.
2    Copyright (C) 1997-2021 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library.  If not, see
17    <https://www.gnu.org/licenses/>.  */
18 
19 #include <stdarg.h>
20 #include <sysdep.h>
21 
22 long int
syscall(long int number,...)23 syscall (long int number, ...)
24 {
25   va_list args;
26 
27   va_start (args, number);
28   long int a0 = va_arg (args, long int);
29   long int a1 = va_arg (args, long int);
30   long int a2 = va_arg (args, long int);
31   long int a3 = va_arg (args, long int);
32   long int a4 = va_arg (args, long int);
33   long int a5 = va_arg (args, long int);
34   va_end (args);
35 
36   int r = INTERNAL_SYSCALL_NCS_CALL (number, a0, a1, a2, a3, a4, a5);
37   if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r)))
38     {
39       __set_errno (-r);
40       return -1;
41     }
42   return r;
43 }
44