This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 07/11] nds32: Linux Syscall Interface



On 06/05/2018 11:41, vincentc wrote:
> This patch contains the Linux system call interface, as well as the
> definitions of a handful of system calls.
> ---
>  sysdeps/unix/sysv/linux/nds32/arch-fork.h      |  27 ++
>  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/readahead.c      |  36 +++
>  sysdeps/unix/sysv/linux/nds32/syscall.c        |  39 +++
>  sysdeps/unix/sysv/linux/nds32/syscalls.list    |   2 +
>  sysdeps/unix/sysv/linux/nds32/sysdep.c         |  30 +++
>  sysdeps/unix/sysv/linux/nds32/sysdep.h         | 337 +++++++++++++++++++++++++
>  9 files changed, 569 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/nds32/arch-fork.h
>  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/readahead.c
>  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/arch-fork.h b/sysdeps/unix/sysv/linux/nds32/arch-fork.h
> new file mode 100644
> index 0000000..e86143a
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/nds32/arch-fork.h
> @@ -0,0 +1,27 @@
> +/* ARCH_FORK definition for Linux fork implementation, Andes Linux/nds32 version.
> +   Copyright (C) 2002-2018 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
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <sched.h>
> +#include <sysdep.h>
> +#include <tls.h>
> +
> +#define ARCH_FORK() \
> +  INLINE_SYSCALL (clone, 5,                                                  \
> +                 CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0,     \
> +                 NULL, NULL, &THREAD_SELF->tid)
> +

The clone syscall for fork implementation was consolidate (commit
3dc214977beccc95f0df3b90fa4ca2557fe1bdd2).  The new ports need to redefine
it iff the clone kernel ABI does not follow the generic expect one
(check sysdeps/unix/sysv/linux/kernel-features.h:119).


> diff --git a/sysdeps/unix/sysv/linux/nds32/readahead.c b/sysdeps/unix/sysv/linux/nds32/readahead.c
> new file mode 100644
> index 0000000..5559619
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/nds32/readahead.c

Joseph already noted this files should not be required.

> diff --git a/sysdeps/unix/sysv/linux/nds32/syscall.c b/sysdeps/unix/sysv/linux/nds32/syscall.c
> new file mode 100644
> index 0000000..77af6bb
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/nds32/syscall.c
> @@ -0,0 +1,39 @@
> +/* System call interface, Andes nds32 version.
> +   Copyright (C) 2001-2018 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
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <errno.h>
> +#include <stdarg.h>
> +#include <sysdep.h>
> +long int syscall (long int __sysno, ...)
> +{
> +
> +	int result;
> +	unsigned long arg1,arg2,arg3,arg4,arg5,arg6;
> +	va_list arg;
> +	va_start (arg, __sysno);
> +	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" );
> +	result = INLINE_SYSCALL_NCS(__sysno,6,arg1,arg2,arg3,arg4,arg5,arg6);
> +	return result;
> +}

Maybe we could it as a generic version, the only points I am not sure if why
you need a compiler memory barrier here.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]