From patchwork Sat Jun 29 15:41:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 1124801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-103361-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="RlvCqUEv"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45bdFh4Js3z9s5c for ; Sun, 30 Jun 2019 01:43:20 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=aOEkc 6oUXsdBx/uG/zMqU9H0gjBLCS2j2G9kUc4scjulzGlmXTFj8A28lc2pvk2Nhixu/ osxlngVHGgvpSaKxmt5mxoxzknYedmAJnaK+jv+ZfWJrz+svuazvijdXkm6GtCGq Js51+K+3buPKRitWWWMHC1TQw2zuNArs10Nr2k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=W2ceAcXs65d iQS3WnXCE8l7hNt8=; b=RlvCqUEv4epK8qPiEVFk0bwvtdEzSbiOY/TvVpH1Ivy cBcFRP1yLwr9QaObs1QC7Yg8ifM+0er6AVpeX/IKwcqwdav5f03UWv4GO/pTJkJO rItHJxtBxI72rsK0tlGmMdio2OOkSg/EVmX9hy7DbWHq6UzUGkcoCXrJ0OrafoAU = Received: (qmail 99902 invoked by alias); 29 Jun 2019 15:42:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 99831 invoked by uid 89); 29 Jun 2019 15:42:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RDNS_DYNAMIC, SPF_PASS, TVD_RCVD_IP autolearn=ham version=3.3.1 spammy= X-HELO: ATCSQR.andestech.com From: Vincent Chen To: , CC: , , Vincent Chen Subject: [PATCH v6 07/11] nds32: Linux Syscall Interface Date: Sat, 29 Jun 2019 23:41:26 +0800 Message-ID: <1561822890-23219-8-git-send-email-vincentc@andestech.com> In-Reply-To: <1561822890-23219-1-git-send-email-vincentc@andestech.com> References: <1561822890-23219-1-git-send-email-vincentc@andestech.com> MIME-Version: 1.0 X-DNSRBL: X-MAIL: ATCSQR.andestech.com x5TFYDvT032399 This patch contains the Linux system call interface, as well as the definitions of a handful of system calls. 2019-06-29 Vincent Chen 2019-06-29 CheWei Chuang * sysdeps/unix/sysv/linux/nds32/clone.S: New file. * sysdeps/unix/sysv/linux/nds32/profil-counter.h: Likewise. * sysdeps/unix/sysv/linux/nds32/pt-vfork.S: Likewise. * sysdeps/unix/sysv/linux/nds32/syscall.c: Likewise. * sysdeps/unix/sysv/linux/nds32/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/nds32/sysdep.c: Likewise. * sysdeps/unix/sysv/linux/nds32/sysdep.h: Likewise. --- sysdeps/unix/sysv/linux/nds32/clone.S | 66 +++++ sysdeps/unix/sysv/linux/nds32/profil-counter.h | 31 +++ sysdeps/unix/sysv/linux/nds32/pt-vfork.S | 1 + sysdeps/unix/sysv/linux/nds32/syscall.c | 39 +++ sysdeps/unix/sysv/linux/nds32/syscalls.list | 2 + sysdeps/unix/sysv/linux/nds32/sysdep.c | 29 +++ sysdeps/unix/sysv/linux/nds32/sysdep.h | 340 +++++++++++++++++++++++++ 7 files changed, 508 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/nds32/clone.S create mode 100644 sysdeps/unix/sysv/linux/nds32/profil-counter.h create mode 100644 sysdeps/unix/sysv/linux/nds32/pt-vfork.S create mode 100644 sysdeps/unix/sysv/linux/nds32/syscall.c create mode 100644 sysdeps/unix/sysv/linux/nds32/syscalls.list create mode 100644 sysdeps/unix/sysv/linux/nds32/sysdep.c create mode 100644 sysdeps/unix/sysv/linux/nds32/sysdep.h diff --git a/sysdeps/unix/sysv/linux/nds32/clone.S b/sysdeps/unix/sysv/linux/nds32/clone.S new file mode 100644 index 0000000..bb2e87d --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/clone.S @@ -0,0 +1,66 @@ +/* Wrapper around clone system call, Andes LINUX/nds32 version. + Copyright (C) 2018-2019 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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 + . */ + +/* clone() is even more special than fork() as it mucks with stacks + and invokes a function in the right context after its all over. */ + +#include +#define _ERRNO_H 1 +#include + +/* int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, + void *parent_tidptr, void *tls, void *child_tidptr). */ + +ENTRY(__clone) + /* Sanity check arguments. */ + beqz $r0, 1f + bnez $r1, 2f +1: + movi $r0, -EINVAL +5: + j SYSCALL_ERROR_LABEL +2: + /* Child's $sp will be $r1, push to child's stack only. */ + addi $r1, $r1, -4 + swi.p $r3, [$r1], -4 + swi $r0, [$r1] + + /* Do the system call. */ + move $r0, $r2 + move $r2, $r4 + move $r3, $r5 + lwi $r4, [$sp] + __do_syscall (clone) + + beqz $r0, 4f + bltz $r0, 5b + ret +4: + .cfi_undefined lp + /* Restore the arg for user's function. */ + pop $r1 /* Function pointer. */ + pop $r0 /* Argument pointer. */ + + /* Call the user's function. */ + bral $r1 + + __do_syscall (exit) + +PSEUDO_END (__clone) +libc_hidden_def (__clone) +weak_alias (__clone, clone) diff --git a/sysdeps/unix/sysv/linux/nds32/profil-counter.h b/sysdeps/unix/sysv/linux/nds32/profil-counter.h new file mode 100644 index 0000000..43c8f36 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/profil-counter.h @@ -0,0 +1,31 @@ +/* Low-level statistical profiling support function, Andes Linux/nds32 version. + Copyright (C) 2018-2019 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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 + . */ + +#include +#include + +static void +__profil_counter (int signo, struct ucontext_t * scp) +{ + profil_count ((void *) GET_PC (scp)); + + /* This is a hack to prevent the compiler from implementing the + * above function call as a sibcall. The sibcall would overwrite + * the signal context. */ + asm volatile (""); +} diff --git a/sysdeps/unix/sysv/linux/nds32/pt-vfork.S b/sysdeps/unix/sysv/linux/nds32/pt-vfork.S new file mode 100644 index 0000000..1cc8931 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/pt-vfork.S @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/sysdeps/unix/sysv/linux/nds32/syscall.c b/sysdeps/unix/sysv/linux/nds32/syscall.c new file mode 100644 index 0000000..27cb1a1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/syscall.c @@ -0,0 +1,39 @@ +/* System call interface. Andes nds32 version. + Copyright (C) 2018-2019 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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 + . */ + +#include +#include +#include +long int +syscall (long int __sysno, ...) +{ + int result; + unsigned long int arg1, arg2, arg3, arg4, arg5, arg6; + va_list arg; + va_start (arg, __sysno); + arg1 = va_arg (arg, unsigned long int); + arg2 = va_arg (arg, unsigned long int); + arg3 = va_arg (arg, unsigned long int); + arg4 = va_arg (arg, unsigned long int); + arg5 = va_arg (arg, unsigned long int); + arg6 = va_arg (arg, unsigned long int); + va_end (arg); + result = INLINE_SYSCALL_NCS (__sysno, 6, + arg1, arg2, arg3, arg4, arg5, arg6); + return result; +} diff --git a/sysdeps/unix/sysv/linux/nds32/syscalls.list b/sysdeps/unix/sysv/linux/nds32/syscalls.list new file mode 100644 index 0000000..02b1eca --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/syscalls.list @@ -0,0 +1,2 @@ +# File name Caller Syscall name Args Strong name Weak names +cacheflush - cacheflush i:pii __cacheflush cacheflush diff --git a/sysdeps/unix/sysv/linux/nds32/sysdep.c b/sysdeps/unix/sysv/linux/nds32/sysdep.c new file mode 100644 index 0000000..30e1a5c --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sysdep.c @@ -0,0 +1,29 @@ +/* Fill error number to errno. + Copyright (C) 2018-2019 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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 + . */ + +#include +#include + +/* This routine is jumped to by all the syscall handlers, to stash + an error number into errno. */ +long int +__syscall_error (long int err) +{ + __set_errno (-err); + return -1; +} diff --git a/sysdeps/unix/sysv/linux/nds32/sysdep.h b/sysdeps/unix/sysv/linux/nds32/sysdep.h new file mode 100644 index 0000000..0c5366d --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sysdep.h @@ -0,0 +1,340 @@ +/* Assembly macros. Andes nds32 version. + Copyright (C) 2018-2019 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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 + . */ + + +#ifndef _LINUX_NDS32_SYSDEP_H +#define _LINUX_NDS32_SYSDEP_H 1 + + +/* Always enable vsyscalls on nds32. */ +#define ALWAYS_USE_VSYSCALL 1 + +#include +#include +#include + +#include + +#include + +/* In order to get __set_errno() definition in INLINE_SYSCALL. */ +#ifndef __ASSEMBLER__ +# include +#endif + +#undef SYS_ify +#define SYS_ify(syscall_name) __NR_##syscall_name + +#ifdef __ASSEMBLER__ + +# define __do_syscall(syscall_name) \ + movi $r15, SYS_ify (syscall_name); \ + syscall 0x0; + +# define ADJUST_GP \ + smw.adm $sp,[$sp],$sp,#0x6; \ + cfi_startproc; \ + .cfi_adjust_cfa_offset 8; \ + .cfi_rel_offset gp, 0; \ + .cfi_rel_offset lp, 4; \ + GET_GTABLE ($gp) + +# define RECOVER_GP \ + lmw.bim $sp,[$sp],$sp,#0x6; \ + .cfi_adjust_cfa_offset -8; \ + .cfi_restore gp; \ + .cfi_restore lp; \ + cfi_endproc; + +# undef PSEUDO +# define PSEUDO(name, syscall_name, args) \ + .align 2; \ + ENTRY (name); \ + __do_syscall (syscall_name); \ + bgez $r0, 2f; \ + sltsi $r1, $r0, -4096; \ + beqz $r1, SYSCALL_ERROR_LABEL; \ + 2: + +# undef PSEUDO_END +# define PSEUDO_END(sym) \ + cfi_endproc; \ + SYSCALL_ERROR_HANDLER \ + cfi_startproc; \ + END (sym) + +/* Performs a system call, not setting errno. */ +# define PSEUDO_NOERRNO(name, syscall_name, args) \ + ENTRY (name); \ + __do_syscall (syscall_name); + +# undef PSEUDO_END_NOERRNO +# define PSEUDO_END_NOERRNO(name) \ + END (name) + +/* Perfroms a system call, returning the error code. */ +# undef PSEUDO_ERRVAL +# define PSEUDO_ERRVAL(name, syscall_name, args) \ + PSEUDO_NOERRNO (name, syscall_name, args) \ + neg $r0, $r0; + +# undef PSEUDO_END_ERRVAL +# define PSEUDO_END_ERRVAL(sym) END (sym) + +# define ret_ERRVAL ret + +# define ret_NOERRNO ret + +# if !IS_IN (libc) +# if RTLD_PRIVATE_ERRNO +# define SYSCALL_ERROR_HANDLER \ +SYSCALL_ERROR_LABEL: \ + ADJUST_GP \ + la $r1, (rtld_errno@GOT); \ + neg $r0, $r0; \ + sw $r0, [$r1]; \ + li $r0, -1; \ + RECOVER_GP \ + ret; +# else +# ifdef __PIC__ +# define SYSCALL_ERROR_HANDLER \ +SYSCALL_ERROR_LABEL: \ + ADJUST_GP \ + neg $r0, $r0; \ + sethi $r15, hi20(errno@GOTTPOFF); \ + ori $r15, $r15, lo12(errno@GOTTPOFF); \ + lw $r15, [$r15 + $gp]; \ + sw $r0, [$r25 + $r15]; \ + li $r0, -1; \ + RECOVER_GP \ + ret; +# else +# define SYSCALL_ERROR_HANDLER \ +SYSCALL_ERROR_LABEL: \ + neg $r0, $r0; \ + sethi $r15, hi20(errno@GOTTPOFF); \ + lwi $r15, [$r15 + lo12(errno@GOTTPOFF)]; \ + sw $r0, [$r25 + $r15]; \ + li $r0, -1; \ + ret; +# endif /* !__PIC__ */ +# endif /* !RTLD_PRIVATE_ERRNO */ +# else +# ifdef __PIC__ +# define SYSCALL_ERROR_HANDLER \ +SYSCALL_ERROR_LABEL: \ + ADJUST_GP \ + bal __syscall_error; \ + RECOVER_GP \ + ret; +# else +# define SYSCALL_ERROR_HANDLER \ +SYSCALL_ERROR_LABEL: \ + b __syscall_error; +# endif /* !__PIC__ */ +# endif /* In LIBC */ + +#else + +/* List of system calls which are supported as vsyscalls. */ +# define HAVE_GETTIMEOFDAY_VSYSCALL 1 +# define HAVE_CLOCK_GETRES_VSYSCALL 1 +# define HAVE_CLOCK_GETTIME_VSYSCALL 1 + +# define __issue_syscall(syscall_name) "syscall 0x0;\n" + +/* Define a macro which expands into the inline wrapper code for a system + call. */ +# undef INLINE_SYSCALL +# define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + INTERNAL_SYSCALL_DECL (err); \ + long int result_var = INTERNAL_SYSCALL (name, err, nr, args); \ + if (INTERNAL_SYSCALL_ERROR_P (result_var, err)) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \ + result_var = -1; \ + } \ + result_var; \ + }) + +# undef INLINE_SYSCALL_NC +# define INLINE_SYSCALL_NCS(name, nr, args...) \ + ({ \ + INTERNAL_SYSCALL_DECL (err); \ + long int result_var = INTERNAL_SYSCALL_NCS (name, err, nr, args); \ + if (INTERNAL_SYSCALL_ERROR_P (result_var, err)) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \ + result_var = -1; \ + } \ + result_var; \ + }) +# undef INTERNAL_SYSCALL_DECL +# define INTERNAL_SYSCALL_DECL(err) do { } while (0) + +# undef INTERNAL_SYSCALL_ERROR_P +# define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned int) (val) >= 0xfffff001u) + +# undef INTERNAL_SYSCALL_ERRNO +# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) + +# undef INTERNAL_SYSCALL +# define INTERNAL_SYSCALL(name, err, nr, args...) \ + internal_syscall##nr (__NR_##name, err, args) + +# undef INTERNAL_SYSCALL_NCS +# define INTERNAL_SYSCALL_NCS(syscallno, err, nr, args...) \ + internal_syscall##nr (syscallno, err, args) + +# define internal_syscall0(name, err, dummy...) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define internal_syscall1(name, err, arg1) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + register long int __arg1 asm ("$r0") = (long int) (arg1); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + , "r" (__arg1) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define internal_syscall2(name, err, arg1, arg2) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + register long int __arg1 asm ("$r0") = (long int) (arg1); \ + register long int __arg2 asm ("$r1") = (long int) (arg2); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + , "r" (__arg1) \ + , "r" (__arg2) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define internal_syscall3(name, err, arg1, arg2, arg3) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + register long int __arg1 asm ("$r0") = (long int) (arg1); \ + register long int __arg2 asm ("$r1") = (long int) (arg2); \ + register long int __arg3 asm ("$r2") = (long int) (arg3); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + , "r" (__arg1) \ + , "r" (__arg2) \ + , "r" (__arg3) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define internal_syscall4(name, err, arg1, arg2, arg3, arg4) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + register long int __arg1 asm ("$r0") = (long int) (arg1); \ + register long int __arg2 asm ("$r1") = (long int) (arg2); \ + register long int __arg3 asm ("$r2") = (long int) (arg3); \ + register long int __arg4 asm ("$r3") = (long int) (arg4); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + , "r" (__arg1) \ + , "r" (__arg2) \ + , "r" (__arg3) \ + , "r" (__arg4) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define internal_syscall5(name, err, arg1, arg2, arg3, arg4, arg5) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + register long int __arg1 asm ("$r0") = (long int) (arg1); \ + register long int __arg2 asm ("$r1") = (long int) (arg2); \ + register long int __arg3 asm ("$r2") = (long int) (arg3); \ + register long int __arg4 asm ("$r3") = (long int) (arg4); \ + register long int __arg5 asm ("$r4") = (long int) (arg5); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + , "r" (__arg1) \ + , "r" (__arg2) \ + , "r" (__arg3) \ + , "r" (__arg4) \ + , "r" (__arg5) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define internal_syscall6(name, err, arg1, arg2, arg3, arg4, arg5, arg6) \ + ({ \ + register long int __res asm ("$r0"); \ + register long int __num asm ("$r15") = (long int) (name); \ + register long int __arg1 asm ("$r0") = (long int) (arg1); \ + register long int __arg2 asm ("$r1") = (long int) (arg2); \ + register long int __arg3 asm ("$r2") = (long int) (arg3); \ + register long int __arg4 asm ("$r3") = (long int) (arg4); \ + register long int __arg5 asm ("$r4") = (long int) (arg5); \ + register long int __arg6 asm ("$r5") = (long int) (arg6); \ + __asm__ volatile ( \ + __issue_syscall (name) \ + : "=r" (__res) \ + : "r" (__num) \ + , "r" (__arg1) \ + , "r" (__arg2) \ + , "r" (__arg3) \ + , "r" (__arg4) \ + , "r" (__arg5) \ + , "r" (__arg6) \ + : __SYSCALL_CLOBBERS); \ + __res; \ + }) + +# define __SYSCALL_CLOBBERS "memory" + +#endif /* !__ASSEMBLER__. */ + +#define PTR_MANGLE(var) (void) (var) +#define PTR_DEMANGLE(var) (void) (var) + +#endif /* _LINUX_NDS32_SYSDEP_H. */