riscv64: fix linking with binutils 2.40
[uclibc-ng.git] / libc / sysdeps / linux / metag / syscall.c
blob93aabf3e02d1ee88967e511754ec26e5642ef025
1 /* syscall for META/uClibc
3 * Copyright (C) 2013 Imagination Technologies
5 * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
6 */
8 #include <features.h>
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <sys/syscall.h>
13 long syscall(long sysnum,
14 long arg1, long arg2, long arg3,
15 long arg4, long arg5, long arg6)
18 register long __call __asm__ ("D1Re0") = sysnum;
19 register long __res __asm__ ("D0Re0");
20 register long __a __asm__ ("D1Ar1") = arg1;
21 register long __b __asm__ ("D0Ar2") = arg2;
22 register long __c __asm__ ("D1Ar3") = arg3;
23 register long __d __asm__ ("D0Ar4") = arg4;
24 register long __e __asm__ ("D1Ar5") = arg5;
25 register long __f __asm__ ("D0Ar6") = arg6;
28 __asm__ __volatile__ ("SWITCH #0x440001"
29 : "=d" (__res)
30 : "d" (__call), "d" (__a), "d" (__b),
31 "d" (__c), "d" (__d), "d" (__e) , "d" (__f)
32 : "memory");
34 if(__res >= (unsigned long) -4095) {
35 long err = __res;
36 (*__errno_location()) = (-err);
37 __res = (unsigned long) -1;
39 return (long) __res;