[RFC PATCH 09/10] C-SKY: Linux Syscall Interface

Mao Han han_mao@c-sky.com
Fri Mar 16 09:59:00 GMT 2018


Contains the Linux system call interface.

        *sysdeps/unix/sysv/linux/csky/abiv2_brk.c: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_clone.S: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_getcontext.S: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_mmap.S: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_setcontext.S: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_socket.S: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_syscall.S: New file
        *sysdeps/unix/sysv/linux/csky/abiv2_vfork.S: New file
        *sysdeps/unix/sysv/linux/csky/alphasort64.c: New file
        *sysdeps/unix/sysv/linux/csky/brk.c: New file
        *sysdeps/unix/sysv/linux/csky/clone.S: New file
        *sysdeps/unix/sysv/linux/csky/ftruncate64.c: New file
        *sysdeps/unix/sysv/linux/csky/fxstat.c: New file
        *sysdeps/unix/sysv/linux/csky/fxstatat.c: New file
        *sysdeps/unix/sysv/linux/csky/getcontext.S: New file
        *sysdeps/unix/sysv/linux/csky/getdents64.c: New file
        *sysdeps/unix/sysv/linux/csky/libc-read_tp.S: New file
        *sysdeps/unix/sysv/linux/csky/lockf64.c: New file
        *sysdeps/unix/sysv/linux/csky/lxstat.c: New file
        *sysdeps/unix/sysv/linux/csky/mmap.S: New file
        *sysdeps/unix/sysv/linux/csky/pt-vfork.S: New file
        *sysdeps/unix/sysv/linux/csky/read_tp.S: New file
        *sysdeps/unix/sysv/linux/csky/readahead.c: New file
        *sysdeps/unix/sysv/linux/csky/readdir64.c: New file
        *sysdeps/unix/sysv/linux/csky/readdir64_r.c: New file
        *sysdeps/unix/sysv/linux/csky/scandir64.c: New file
        *sysdeps/unix/sysv/linux/csky/socket.S: New file
        *sysdeps/unix/sysv/linux/csky/syscall.S: New file
        *sysdeps/unix/sysv/linux/csky/syscalls.list: New file
        *sysdeps/unix/sysv/linux/csky/versionsort64.c: New file
        *sysdeps/unix/sysv/linux/csky/vfork.S: New file
        *sysdeps/unix/sysv/linux/csky/xstat.c: New file
        *sysdeps/unix/sysv/linux/csky/____longjmp_chk.S: New file
---
 sysdeps/unix/sysv/linux/csky/____longjmp_chk.S  | 129 ++++++++++++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_brk.c        |  56 ++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_clone.S      | 133 ++++++++++++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_getcontext.S |  72 ++++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_mmap.S       |  62 +++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_setcontext.S |  95 +++++++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_socket.S     | 152 +++++++++++++++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_syscall.S    |  69 ++++++++++
 sysdeps/unix/sysv/linux/csky/abiv2_vfork.S      |  45 +++++++
 sysdeps/unix/sysv/linux/csky/alphasort64.c      |   1 +
 sysdeps/unix/sysv/linux/csky/brk.c              |  61 +++++++++
 sysdeps/unix/sysv/linux/csky/clone.S            | 125 +++++++++++++++++
 sysdeps/unix/sysv/linux/csky/ftruncate64.c      |  41 ++++++
 sysdeps/unix/sysv/linux/csky/fxstat.c           |   1 +
 sysdeps/unix/sysv/linux/csky/fxstatat.c         |   1 +
 sysdeps/unix/sysv/linux/csky/getcontext.S       | 108 +++++++++++++++
 sysdeps/unix/sysv/linux/csky/getdents64.c       |   1 +
 sysdeps/unix/sysv/linux/csky/libc-read_tp.S     |   1 +
 sysdeps/unix/sysv/linux/csky/lockf64.c          |   1 +
 sysdeps/unix/sysv/linux/csky/lxstat.c           |   2 +
 sysdeps/unix/sysv/linux/csky/mmap.S             |  65 +++++++++
 sysdeps/unix/sysv/linux/csky/pt-vfork.S         |  50 +++++++
 sysdeps/unix/sysv/linux/csky/read_tp.S          |  47 +++++++
 sysdeps/unix/sysv/linux/csky/readahead.c        |  44 ++++++
 sysdeps/unix/sysv/linux/csky/readdir64.c        |   1 +
 sysdeps/unix/sysv/linux/csky/readdir64_r.c      |   1 +
 sysdeps/unix/sysv/linux/csky/scandir64.c        |   1 +
 sysdeps/unix/sysv/linux/csky/socket.S           | 171 ++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/csky/syscall.S          |  61 +++++++++
 sysdeps/unix/sysv/linux/csky/syscalls.list      |   7 +
 sysdeps/unix/sysv/linux/csky/versionsort64.c    |   1 +
 sysdeps/unix/sysv/linux/csky/vfork.S            |  49 +++++++
 sysdeps/unix/sysv/linux/csky/xstat.c            |   1 +
 33 files changed, 1655 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/csky/____longjmp_chk.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_brk.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_clone.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_mmap.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_socket.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_syscall.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/abiv2_vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/alphasort64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/brk.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/ftruncate64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/fxstat.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/fxstatat.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/getdents64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/libc-read_tp.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/lockf64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/lxstat.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/mmap.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/pt-vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/read_tp.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/readahead.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/readdir64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/readdir64_r.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/scandir64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/socket.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/syscall.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/syscalls.list
 create mode 100644 sysdeps/unix/sysv/linux/csky/versionsort64.c
 create mode 100644 sysdeps/unix/sysv/linux/csky/vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/csky/xstat.c

diff --git a/sysdeps/unix/sysv/linux/csky/____longjmp_chk.S b/sysdeps/unix/sysv/linux/csky/____longjmp_chk.S
new file mode 100644
index 0000000..1b8e954
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/____longjmp_chk.S
@@ -0,0 +1,129 @@
+/* Copyright (C) 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 <sysdep.h>
+
+	.section .rodata.str1.8,"aMS",@progbits,1
+	.align  2 
+	.type   longjmp_msg,@object
+longjmp_msg:
+	.string "longjmp causes uninitialized stack frame"
+	.size   longjmp_msg, .-longjmp_msg
+	.text
+
+#define __longjmp ____longjmp_chk
+
+#ifdef	__PIC__
+# ifdef	__CSKYABIV2__
+#  define CALL_FAIL	\
+	subi    sp, 8;						\
+	stw     gb, (sp, 0);					\
+	grs     gb, .Lgetpc1;					\
+.Lgetpc1:							\
+	lrw     t0, .Lgetpc1@GOTPC;				\
+	addu	gb, gb, t0;					\
+	lrw     a0, longjmp_msg@GOTOFF;				\
+	addu	a0, a0, gb;					\
+	lrw     t0, (HIDDEN_JUMPTARGET(__fortify_fail))@PLT;	\
+	ldr.w	t0, (gb, t0 << 0);				\
+	jsr     t0;						\
+	ldw     gb, (sp, 0);					\
+	addi    sp, 8;
+# else /* __CSKYABIV2__ */
+#  define CALL_FAIL	\
+	subi    sp, 8;						\
+	stw     gb, (sp);					\
+	stw     r15, (sp, 4);					\
+	bsr     .Lgetpc2;					\
+.Lgetpc2:							\
+	lrw     gb, .Lgetpc2@GOTPC;				\
+	add     gb, r15;					\
+	lrw     a0, longjmp_msg@GOTOFF;				\
+	addu	a0, gb;						\
+	lrw     r7, (HIDDEN_JUMPTARGET(__fortify_fail))@PLT;	\
+	add     r7, gb;         				\
+	ldw     r7, (r7);       				\
+	jsr     r7;             				\
+	ldw     gb, (sp, 0);    				\
+	ldw     r15,(sp, 4);    				\
+	addi    sp, 8;          
+# endif /* __CSKYABIV2__ */
+#else /* __PIC__ */
+# define CALL_FAIL	\
+	lrw     a0, longjmp_msg;				\
+	jsri    HIDDEN_JUMPTARGET(__fortify_fail);
+#endif/* __PIC__ */
+
+#ifdef	__CSKYABIV2__
+# define  CHECK_SP(reg)	\
+	cmplt   sp, reg;					\
+	bt      .Lok1;						\
+	mov     r9, a0;						\
+	mov     t0, r7;						\
+	lrw     r7, __NR_sigaltstack;				\
+	movi	a0, 0;						\
+	subi	sp, 12;	/* sizeof (stack_t) */			\
+	mov     a1, sp;						\
+	trap    0;						\
+	mov     r7, t0;						\
+	cmpnei  a0, 0;						\
+	bt      .Lok;						\
+	ldw     a1, (sp, 4);					\
+	btsti   a1, 1;						\
+	bt      .Lfail;						\
+	ldw     a1, (sp, 0);					\
+	ldw     a3, (sp, 8);					\
+	add     a1, a3;						\
+	sub     a1, reg;					\
+	cmphs   a1, a3;						\
+	bt      .Lok;						\
+.Lfail:								\
+	addi    sp, 12;						\
+	CALL_FAIL						\
+.Lok:								\
+	mov     a0, r9;						\
+.Lok1:						
+#else
+# define  CHECK_SP(reg)	\
+	cmplt   sp, reg;					\
+	bt      .Lok1;						\
+	mov     r9, a0;						\
+	lrw     r1, __NR_sigaltstack;				\
+	movi	a0, 0;						\
+	subi	sp, 12;	/* sizeof (stack_t) */			\
+	mov     a1, sp;						\
+	trap    0;						\
+	cmpnei  a0, 0;						\
+	bt      .Lok;						\
+	ldw     a1, (sp, 4);					\
+	btsti   a1, 1;						\
+	bt      .Lfail;						\
+	ldw     a1, (sp, 0);					\
+	ldw     a3, (sp, 8);					\
+	add     a1, a3;						\
+	sub     a1, reg;					\
+	cmphs   a1, a3;						\
+	bt      .Lok;						\
+.Lfail:								\
+	addi    sp, 12;						\
+	CALL_FAIL						\
+.Lok:								\
+	mov     a0, r9;						\
+.Lok1:						
+#endif
+
+#include <__longjmp.S>
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_brk.c b/sysdeps/unix/sysv/linux/csky/abiv2_brk.c
new file mode 100644
index 0000000..a564276
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_brk.c
@@ -0,0 +1,56 @@
+/* brk system call for Linux/C-SKY.
+   Copyright (C) 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 <unistd.h>
+#include <sys/syscall.h>
+#include <errno.h>
+
+/* This must be initialized data because commons can't have aliases.  */
+void * __curbrk = 0;
+
+/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
+   to work around different old braindamage in the old Linux/x86 ELF
+   dynamic linker.  Sigh.  */
+weak_alias (__curbrk, ___brk_addr)
+
+int __brk (void *addr)
+{
+    void *newbrk;
+
+    {
+      register long int res __asm__("a0") = (long int)addr;
+
+      __asm__ volatile ("lrw l3, %1\n\t"
+                        "trap 0     \n\t"
+                        :"+r" (res)
+                        :"i" (__NR_brk)
+                        :"l3");
+      newbrk = (void *) res;
+    }
+    __curbrk = newbrk;
+
+    if (newbrk < addr)
+    {
+        __set_errno (ENOMEM);
+	return -1;
+    }
+
+    return 0;
+}
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_clone.S b/sysdeps/unix/sysv/linux/csky/abiv2_clone.S
new file mode 100644
index 0000000..2fd3605
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_clone.S
@@ -0,0 +1,133 @@
+/* Copyright (C) 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/>.  */
+
+/* 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 <sysdep.h>
+#define _ERRNO_H	1
+#include <bits/errno.h>
+#include <csky_readtp.h>
+
+#define CLONE_VM      8  /* 8 makes btsti easier, 0x00000100 in real */
+#define CLONE_THREAD  16  /* 0x00010000 in real */
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+	     pid_t *ptid, struct user_desc *tls, pid_t *ctid); */
+
+        .text
+ENTRY(__clone)
+	/* Sanity check arguments.  */
+	cmpnei	a0, 0		/* no NULL function pointers */
+	bf	__error_arg
+	cmpnei	a1, 0		/* no NULL function pointers */
+	bf	__error_arg
+
+	subi	a1, 8
+	stw	a0, (a1, 0)	/* insert the args onto the new stack */
+	stw	a3, (a1, 4)	/* insert the args onto the new stack */
+
+#ifdef RESET_PID
+	mov	t0, a2		/* save a2(flags) */
+#endif
+	mov	t1, r7		/* save r7 */
+	mov	t2, r4		/* save r4 (has t2 ?)*/
+
+	mov	a0, a2		/* arg1 = flags */
+	ldw	a2, (sp, 0)	/* arg3 = ptid */
+	ldw	a3, (sp, 8)	/* arg4 = ctid */
+	ldw	r4, (sp, 4)	/* arg5 = tls */
+	lrw	r7, __NR_clone
+	trap	0
+
+	mov	r7, t1		/* restore r7 */
+	mov	r4, t2		/* restore r4 */
+	btsti	a0, 31		/* is a0 less than zero? */
+	bt	do_syscall_error
+	cmpnei	a0, 0
+	bf	1f
+	rts
+PSEUDO_END (__clone)
+
+1:
+#ifdef RESET_PID
+	ldw	a2, (sp, 0)
+	btsti	t0, CLONE_THREAD	/* judge flags */
+	bt	3f
+	csky_read_tp
+	mov	a3, a0
+
+	btsti	t0, CLONE_VM		/* judge flags */
+	bmaski	a0, 0			/* if CLONE_VM not set, pid=tid=-1 */
+	bt	2f
+	mov	t1, r7
+	lrw	r7, __NR_getpid		/* else get pid via getpid syscall */
+	trap	0
+	mov	r7, t1
+2:
+	lrw	t0, PID_OFFSET
+	add	t0, a3
+	stw	a0, (t0)		/* save pid */
+	lrw	t0, TID_OFFSET
+	add	t0, a3
+	stw	a0, (t0)		/* save tid */
+	
+3:
+#endif /* RESET_PID */
+	ldw	a0, (sp, 4)	/* restore args from new sp */
+	ldw	a1, (sp, 0)	/* restore args from new sp */
+	addi	sp, 8
+	jsr	a1
+
+	/* exit */
+#ifdef __PIC__
+        grs     t1, .Lgetpc1
+.Lgetpc1:
+        lrw     t0, .Lgetpc1@GOTPC
+        addu    t1, t1, t0
+        lrw     t0, _exit@GOT
+        ldr.w   t0, (t1, t0 << 0)
+#else
+        lrw     t0, _exit       /* exit */
+#endif /* __PIC__ */
+        jmp     t0
+
+__error_arg:
+	lrw	a0, -EINVAL
+
+do_syscall_error:
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	r15, (sp, 4)
+	grs	gb, .Lgetpc2
+.Lgetpc2:
+	lrw	t0, .Lgetpc2@GOTPC
+	addu	gb, gb, t0
+	lrw	t0, __syscall_error@PLT
+	ldr.w	t0, (gb, t0 << 0)
+	jsr	t0
+	ldw	gb, (sp, 0)
+	ldw	r15, (sp, 4)
+	addi	sp, 8
+#else
+	jmpi	__syscall_error
+#endif /* __PIC__ */
+	rts
+
+libc_hidden_def (__clone)
+weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_getcontext.S b/sysdeps/unix/sysv/linux/csky/abiv2_getcontext.S
new file mode 100644
index 0000000..c85cbac
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_getcontext.S
@@ -0,0 +1,72 @@
+/* Copyright (C) 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 <sysdep.h>
+
+#include "ucontext_i.h"
+
+/* int getcontext (ucontext_t *ucp) */
+
+ENTRY(__getcontext)
+	/* No need to save r2-r7 or a0-a3 */
+	mov	t0, a0
+
+	addi	a0, MCONTEXT_CSKY_R4
+
+	stm	r4-r13, (a0)			/* save r4-r13 */
+	stw	sp, (t0, MCONTEXT_CSKY_SP)	/* save sp */
+	stw	r15, (t0, MCONTEXT_CSKY_LR)	/* save lr */
+	stw	r15, (t0, MCONTEXT_CSKY_PC)	/* Return to PC */
+	addi	a0, t0, MCONTEXT_CSKY_R16
+	stm	r16-r31, (a0)			/* save r16-r31 */
+	movi	a0, 0
+	stw	a0, (t0, MCONTEXT_CSKY_A0)	/* Return zero */
+
+	subi	sp, 8
+	stw	t0, (sp, 0)			/* save t0 after "save sp" */
+
+	/* __sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
+	movi	a0, SIG_BLOCK
+	movi	a1, 0
+	addi	a2, t0, UCONTEXT_SIGMASK
+
+	/* do sigprocmask syscall */
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	grs	gb, .Lgetpc
+.Lgetpc:
+	lrw	a3, .Lgetpc@GOTPC
+	addu	gb, gb, a3
+	lrw	a3, __sigprocmask@PLT
+	ldr.w	a3, (gb, a3 << 0)
+	jsr	a3
+	ldw	gb, (sp, 0)
+	addi	sp, 8
+#else
+	jsri    __sigprocmask
+#endif
+
+	ldw	t0, (sp, 0)
+	addi	sp, 8
+	/* restore r15 for sigprocmask changes*/
+	ldw	r15, (t0, MCONTEXT_CSKY_LR)
+	movi	a0, 0				/* return 0 */
+	jmp	r15
+END(__getcontext)
+
+weak_alias(__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_mmap.S b/sysdeps/unix/sysv/linux/csky/abiv2_mmap.S
new file mode 100644
index 0000000..e759ba2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_mmap.S
@@ -0,0 +1,62 @@
+/* Copyright (C) 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 <sysdep.h>
+
+/* void *mmap(void *addr, size_t len, int prot, int flags,
+              int fildes, off_t off); */
+
+ENTRY (__mmap)
+	subi	sp, 24
+	stm	a0-a3, (sp)	/* store arg1-arg4 */
+	ldw	t0, (sp, 24)
+	stw	t0, (sp, 16)	/* store arg5 */
+	ldw	t0, (sp, 28)
+	stw	t0, (sp, 20)	/* store arg6 */
+
+	mov	t0, r7		/* save r7 */
+	lrw	r7, __NR_mmap
+	mov	a0, sp
+	trap	0
+	addi	sp, sp, 24
+	mov	r7, t0
+	lrw	t0, 0xfffff000
+	cmphs	a0, t0
+	bf	1f
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	r15, (sp, 4)
+	grs	gb, .Lgetpc
+.Lgetpc:
+	lrw	t0, .Lgetpc@GOTPC
+	addu	gb, gb, t0
+	lrw	t0, __syscall_error@PLT
+	ldr.w	t0, (gb, t0 << 0)
+	jsr	t0
+	ldw	gb, (sp, 0)
+	ldw	r15, (sp, 4)
+	addi	sp, 8
+#else
+	jmpi	__syscall_error
+#endif /* __PIC__ */
+1:
+	rts
+PSEUDO_END (__mmap)
+
+weak_alias (__mmap, mmap)
+libc_hidden_builtin_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_setcontext.S b/sysdeps/unix/sysv/linux/csky/abiv2_setcontext.S
new file mode 100644
index 0000000..d6c0d64
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_setcontext.S
@@ -0,0 +1,95 @@
+/* Copyright (C) 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 <sysdep.h>
+
+#include "ucontext_i.h"
+
+/* int setcontext (const ucontext_t *ucp) */
+
+ENTRY(__setcontext)
+	mov	t0, a0
+	subi	sp, 8
+	stw	a0, (sp, 0)
+
+	/* set sigmask */
+	movi	a0, SIG_SETMASK
+	addi	a1, t0, UCONTEXT_SIGMASK
+	movi	a2, 0
+
+	/* do sigprocmask syscall */
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0) 
+	grs	gb, .Lgetpc1
+.Lgetpc1:
+	lrw	a3, .Lgetpc1@GOTPC
+	addu	gb, gb, a3
+	lrw	a3, __sigprocmask@PLT
+	ldr.w	a3, (gb, a3 << 0)
+	jsr	a3
+	ldw	gb, (sp, 0)
+	addi	sp, 8
+#else
+	jsri	__sigprocmask
+#endif /* __PIC__ */
+
+	ldw	t0, (sp, 0)
+	addi	sp, 8
+	/* set r0-r11. Load a0-a3, for makecontext requires */
+	addi	t1, t0, MCONTEXT_CSKY_A0
+	ldm	r0-r11, (t1)
+	ldw	sp, (t0, MCONTEXT_CSKY_SP)	/* load sp */
+	ldw	r15, (t0, MCONTEXT_CSKY_LR)	/* load lr */
+	ldw	t0, (t0, MCONTEXT_CSKY_PC)	/* load start addr */
+	jmp	t0
+END(setcontext)
+weak_alias(__setcontext, setcontext)
+
+ENTRY(__startcontext)
+	mov	a0, r9
+	cmpnei	r9, 0	/* r9 was set in makecontext */
+	bf	1f	/* null, then exit */
+
+	/* call setcontext */
+#ifdef __PIC__  
+	grs	t1, .Lgetpc2
+.Lgetpc2:
+	lrw	t0, .Lgetpc2@GOTPC
+	addu	t1, t1, t0
+	lrw	t0, __setcontext@GOT
+	ldr.w	t0, (t1, t0 << 0)
+#else
+	lrw	t0, __setcontext
+#endif
+	jsr	t0
+
+1:
+	/* call _exit */
+#ifdef __PIC__  
+	grs	t1, .Lgetpc3
+.Lgetpc3:
+	lrw	t0, .Lgetpc3@GOTPC
+	addu	t1, t1, t0
+	lrw	t0, _exit@GOT
+	ldr.w	t0, (t1, t0 << 0)
+#else
+	lrw	t0, _exit
+#endif
+	jsr	t0
+
+END(__startcontext)
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_socket.S b/sysdeps/unix/sysv/linux/csky/abiv2_socket.S
new file mode 100644
index 0000000..f2b8ca8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_socket.S
@@ -0,0 +1,152 @@
+/* Copyright (C) 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 <sysdep-cancel.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+/* The socket-oriented system calls are handled unusally in Linux.
+   They are all gated through the single `socketcall' system call number.
+   `socketcall' takes two arguments: the first is the subcode, specifying
+   which socket function is being called; and the second is a pointer to
+   the arguments to the specific function.
+
+   The .S files for the other calls just #define socket and #include this.  */
+
+#ifndef NARGS
+#ifdef socket
+#error NARGS not defined
+#endif
+#define NARGS 3
+#endif
+
+#ifndef __socket
+# ifndef NO_WEAK_ALIAS
+#  define __socket P(__,socket)
+# else
+#  define __socket socket
+# endif
+#endif
+
+ENTRY (__socket)
+	subi	sp, 32
+	.cfi_def_cfa_offset 32
+#if NARGS >= 1
+	stw a0, (sp, 0)
+#endif
+
+#if NARGS >= 2
+	stw	a1, (sp, 4)
+#endif
+
+#if NARGS >= 3
+	stw	a2, (sp, 8)
+#endif
+
+#if NARGS >= 4
+	stw	a3, (sp, 12)
+#endif
+
+#if NARGS >= 5
+	ldw	t0, (sp, 32)
+	stw	t0, (sp, 16)
+#endif
+
+#if NARGS >= 6
+	ldw	t0, (sp, 36)
+	stw	t0, (sp, 20)
+#endif
+
+#if defined NEED_CANCELLATION && defined CENABLE
+	stw	r15, (sp, 24)
+	.cfi_offset 15, -8
+	stw	gb, (sp, 28)
+	.cfi_offset 28, -4
+	SINGLE_THREAD_P
+	bt	.Lsocket_cancel
+#endif
+
+	mov	t0, r7
+	lrw	r7, __NR_socketcall
+	movi	a0, P(SOCKOP_, socket)
+	mov	a1, sp
+	trap	0
+	cfi_remember_state
+	.cfi_def_cfa_offset 40
+	addi	sp, 32
+	.cfi_def_cfa_offset 0
+	mov	r7, t0
+	PSEUDO_RET
+
+#if defined NEED_CANCELLATION && defined CENABLE
+.Lsocket_cancel:
+	/* GET GB */
+	cfi_restore_state
+	grs	gb, .Lgetpc
+.Lgetpc:
+	lrw	t0, .Lgetpc@GOTPC
+	addu	gb, t0
+
+	CENABLE
+	mov	t1, a0	/* save CENABLE return value */
+	mov	t0, r7
+	lrw	r7, __NR_socketcall
+	movi	a0, P(SOCKOP_, socket)
+	mov	a1, sp
+	trap	0
+	stw	a0, (sp, 0)
+	mov	r7, t0
+	mov	a0, t1
+	CDISABLE
+	ldw	a0, (sp, 0)
+	ldw	r15, (sp, 24)
+	.cfi_restore 15
+	ldw	gb, (sp, 28)
+	.cfi_restore 28
+	addi	sp, 32
+	.cfi_def_cfa_offset 0
+	btsti	a0, 31
+	bf	3f
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	r15, (sp, 4)
+	/* must cal gb here, gb used by SYSCALL_ERROR ,why? FIXME */
+	grs	gb, .Lgetpc2
+.Lgetpc2:
+	lrw	t0, .Lgetpc2@GOTPC
+	addu	gb, gb, t0
+
+	bsr	SYSCALL_ERROR
+	ldw	r15, (sp, 4)
+	ldw	gb, (sp, 0)
+	addi	sp, 8
+#else
+	jmpi	SYSCALL_ERROR
+#endif
+3:
+	rts
+#endif
+
+PSEUDO_END(__socket)
+
+libc_hidden_def (__socket)
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_syscall.S b/sysdeps/unix/sysv/linux/csky/abiv2_syscall.S
new file mode 100644
index 0000000..90218bf
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_syscall.S
@@ -0,0 +1,69 @@
+/* Copyright (C) 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 <sysdep.h>
+
+/* long syscall(long sysnum, long a, long b, long c, long d, long e, long f) */
+
+ENTRY (syscall)
+	subi	sp, 8
+	stw	r4, (sp, 0)
+	stw	r5, (sp, 4)
+
+	mov	t0, r7
+	mov	r7, a0		/* r7 = sysnum */
+
+	mov	a0, a1		/* arg1 = a */
+	mov	a1, a2		/* arg2 = b */
+	mov	a2, a3		/* arg3 = c */
+	ldw	a3, (sp, 8)	/* arg4 = d */
+	ldw	r4, (sp, 12)	/* arg5 = e */
+	ldw	r5, (sp, 16)	/* arg6 = f */
+	trap	0
+
+	mov	r7, t0
+
+	ldw	r4, (sp, 0)
+	ldw	r5, (sp, 4)
+	addi	sp, 8
+
+	lrw	t0, 0xfffff000
+	cmphs	a0, t0
+	bt	do_syscall_error
+	rts
+PSEUDO_END (syscall)
+
+do_syscall_error:
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+        stw     lr, (sp, 4)
+	grs	gb, .Lgetpc
+.Lgetpc:
+	lrw	t0, .Lgetpc@GOTPC
+	addu	gb, gb, t0
+	lrw	t0, __syscall_error@PLT
+	ldr.w	t0, (gb, t0 << 0)
+	jsr	t0
+	ldw	gb, (sp, 0)
+        ldw     lr, (sp, 4)
+	addi	sp, 8
+#else
+	jmpi	__syscall_error
+#endif /* __PIC__ */
+	rts
+
diff --git a/sysdeps/unix/sysv/linux/csky/abiv2_vfork.S b/sysdeps/unix/sysv/linux/csky/abiv2_vfork.S
new file mode 100644
index 0000000..88cdc8a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/abiv2_vfork.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 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 <sysdep.h>
+#define _ERRNO_H	1
+#include <bits/errno.h>
+
+/* Clone the calling process, but without copying the whole address space.
+   The calling process is suspended until the new process exits or is
+   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
+   and the process ID of the new process to the old process.  */
+
+ENTRY (__vfork)
+#ifdef SAVE_PID
+	SAVE_PID
+#endif
+	mov	t0, r7
+	lrw	r7, __NR_vfork
+	trap	0
+	mov	r7, t0
+#ifdef RESTORE_PID
+	RESTORE_PID
+#endif
+	PSEUDO_RET
+	rts
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork)
diff --git a/sysdeps/unix/sysv/linux/csky/alphasort64.c b/sysdeps/unix/sysv/linux/csky/alphasort64.c
new file mode 100644
index 0000000..0b5ae47
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/alphasort64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/alphasort64.c>
diff --git a/sysdeps/unix/sysv/linux/csky/brk.c b/sysdeps/unix/sysv/linux/csky/brk.c
new file mode 100644
index 0000000..00d42c2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/brk.c
@@ -0,0 +1,61 @@
+/* brk system call for Linux/C-SKY.
+   Copyright (C) 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/>.  */
+
+#ifdef __CSKYABIV2__
+# include "abiv2_brk.c"
+#else
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <errno.h>
+
+/* This must be initialized data because commons can't have aliases.  */
+void * __curbrk = 0;
+
+/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
+   to work around different old braindamage in the old Linux/x86 ELF
+   dynamic linker.  Sigh.  */
+weak_alias (__curbrk, ___brk_addr)
+
+int __brk (void *addr)
+{
+    void *newbrk;
+
+    {
+      register long int res __asm__("r2") = (long int)addr;
+
+      __asm__ volatile ("lrw  r1, %1\n\t"
+                        "trap 0\n\t"
+                        :"+r" (res)
+                        :"i" (__NR_brk) :"r1");
+      newbrk = (void *) res;
+    }
+    __curbrk = newbrk;
+
+    if (newbrk < addr)
+    {
+        __set_errno (ENOMEM);
+	return -1;
+    }
+
+    return 0;
+}
+
+weak_alias (__brk, brk)
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/csky/clone.S b/sysdeps/unix/sysv/linux/csky/clone.S
new file mode 100644
index 0000000..67ac7d1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/clone.S
@@ -0,0 +1,125 @@
+/* Copyright (C) 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/>.  */
+
+/* clone() is even more special than fork() as it mucks with stacks
+   and invokes a function in the right context after its all over.  */
+
+#ifdef	__CSKYABIV2__
+# include "abiv2_clone.S"
+#else
+
+# include <sysdep.h>
+# define _ERRNO_H	1
+# include <bits/errno.h>
+# include <csky_readtp.h>
+
+# define CLONE_VM      8  /* 11 makes btsti easier, 0x00000100 in real */
+# define CLONE_THREAD  16  /* 0x00010000 in real */
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+	     pid_t *ptid, struct user_desc *tls, pid_t *ctid); */
+
+        .text
+ENTRY(__clone)
+	/* Sanity check arguments. */
+	cmpnei	r2, 0
+	bf	__error_arg	/* no NULL function pointers */
+	cmpnei	r3, 0
+	bf	__error_arg	/* no NULL function pointers */
+
+	subi	r3, 8
+	stw	r2, (r3, 0)	/* insert the args onto the new stack */
+	stw	r5, (r3, 4)	/* insert the args onto the new stack */
+
+	ldw	r5, (sp, 0)	/* arg4 = ctid */
+# ifdef RESET_PID
+	subi	r3, 8
+	stw	r4, (r3, 0x0)	/* save r4(flags) */
+# endif
+
+	mov	r2, r4		/* arg1 = flags */
+	mov	r4, r6		/* arg3 = ptid */
+	mov	r6, r7		/* arg5 = tls */
+	lrw	r1, __NR_clone	/* do syscall */
+	trap	0
+
+	btsti	r2, 31		/* is r2 less than zero? */
+	bt	do_syscall_error
+	cmpnei	r2, 0
+	bf	1f
+	rts
+PSEUDO_END (__clone)
+
+1:
+# ifdef RESET_PID
+	ld.w    r4, (sp, 0x0)
+	btsti	r4, CLONE_THREAD	/* judge flags */
+	bt	3f
+	csky_read_tp
+	mov	r6, r2
+
+	btsti	r4, CLONE_VM		/* judge flags */
+	bmaski	r2, 0			/* if CLONE_VM not set, pid=tid=-1 */
+	bt	2f
+	lrw	r1, __NR_getpid		/* else get pid via getpid syscall */
+	trap	0
+2:
+	lrw	r7, PID_OFFSET
+	add	r7, r6
+	stw	r2, (r7)	/* save pid */
+	lrw	r7, TID_OFFSET
+	add	r7, r6
+	stw	r2, (r7)	/* save tid */
+3:
+	addi	sp, 8
+# endif /* RESET_PID */
+	ldw	r2, (sp, 4)	/* restore args from new sp */
+	ldw	r3, (sp, 0)	/* restore args from new sp */
+	addi	sp, 8
+
+	jsr	r3
+	lrw	r1, __NR_exit
+	trap	0
+
+__error_arg:
+	lrw	r2, -EINVAL
+
+do_syscall_error:
+# ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	r15, (sp, 4)
+	bsr	.Lgetpc
+.Lgetpc:
+	lrw	gb, .Lgetpc@GOTPC
+	addu	gb, r15
+	lrw	r7, __syscall_error@PLT
+	addu	r7, gb
+	ldw	r7, (r7)
+	jsr	r7
+	ldw	gb, (sp, 0)
+	ldw	r15, (sp, 4)
+	addi	sp, 8
+# else
+	jmpi	 __syscall_error
+# endif /* __PIC__ */
+	rts
+
+libc_hidden_def (__clone)
+weak_alias (__clone, clone)
+
+#endif	/* __CSKYABIV2__*/
diff --git a/sysdeps/unix/sysv/linux/csky/ftruncate64.c b/sysdeps/unix/sysv/linux/csky/ftruncate64.c
new file mode 100644
index 0000000..47c38e6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/ftruncate64.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 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 <sys/types.h>
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Truncate the file FD refers to to LENGTH bytes.  */
+int
+__ftruncate64 (int fd, off64_t length)
+{
+  unsigned int low = length & 0xffffffff;
+  unsigned int high = length >> 32;
+#ifdef __CSKYABIV2__
+  int result = INLINE_SYSCALL (ftruncate64, 3, fd,
+			       __LONG_LONG_PAIR (high, low));
+#else
+  int result = INLINE_SYSCALL (ftruncate64, 4, fd, 0,
+			       __LONG_LONG_PAIR (high, low));
+#endif
+  return result;
+}
+weak_alias (__ftruncate64, ftruncate64)
diff --git a/sysdeps/unix/sysv/linux/csky/fxstat.c b/sysdeps/unix/sysv/linux/csky/fxstat.c
new file mode 100644
index 0000000..4f219f0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/fxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/sysdeps/unix/sysv/linux/csky/fxstatat.c b/sysdeps/unix/sysv/linux/csky/fxstatat.c
new file mode 100644
index 0000000..0f8b313
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/fxstatat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/sysdeps/unix/sysv/linux/csky/getcontext.S b/sysdeps/unix/sysv/linux/csky/getcontext.S
new file mode 100644
index 0000000..447c15b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/getcontext.S
@@ -0,0 +1,108 @@
+/* Copyright (C) 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/>.  */
+
+#ifdef __CSKYABIV2__
+#include "abiv2_getcontext.S"
+#else
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+/* int getcontext (ucontext_t *ucp) */
+
+ENTRY(__getcontext)
+	/* No need to save r2-r7 or a0-a3 */
+	mov	r7, r2
+
+	/* return zero */
+	lrw	r2, MCONTEXT_CSKY_A0
+	add	r2, r7
+	movi	r1, 0
+	stw	r1, (r2)
+
+	lrw	r2, MCONTEXT_CSKY_R8
+	add	r2, r7
+	stw	r8, (r2, 0)			/* save r8 */
+	stw	r9, (r2, 4)			/* save r9 */
+	stw	r10, (r2, 8)			/* save r10 */
+	stw	r11, (r2, 12)			/* save r11 */
+	stw	r12, (r2, 16)			/* save r12 */
+	stw	r13, (r2, 20)			/* save r13 */
+	stw	r14, (r2, 24)			/* save r14 */
+	stw	r15, (r2, 28)			/* save lr */
+
+
+	lrw	r2, MCONTEXT_CSKY_SP
+	add	r2, r7
+	stw	sp, (r2)			/* save sp */
+
+	lrw	r2, MCONTEXT_CSKY_LR
+	add	r2, r7
+	stw	r15, (r2)			/* Return to LR */
+
+	lrw	r2, MCONTEXT_CSKY_PC
+	add	r2, r7
+	stw	r15, (r2)			/* Return to LR */
+
+	lrw	r2, MCONTEXT_CSKY_A0
+	add	r2, r7
+	movi	r3, 0
+	stw	r3, (r2)			/* Return zero */
+
+	/* __sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
+	lrw	r2, SIG_BLOCK
+	movi	r3, 0
+	lrw	r4, UCONTEXT_SIGMASK
+	add	r4, r7
+
+	subi	sp, 8
+	stw	r7, (sp, 0)
+
+	/* do sigprocmask syscall */
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	lr, (sp, 4)
+	bsr	.Lgetpc
+.Lgetpc:
+	lrw	gb, .Lgetpc@GOTPC
+	addu	gb, r15
+	lrw	r7, __sigprocmask@PLT
+	addu	r7, gb
+	ldw	r7, (r7)
+	jsr	r7
+	ldw	gb, (sp, 0)
+	ldw	lr, (sp, 4)
+	addi	sp, 8
+#else
+        jsri	__sigprocmask
+#endif
+
+	ldw	r7, (sp, 0)
+	addi	sp, 8
+	lrw	r2, MCONTEXT_CSKY_LR
+	add	r2, r7
+	/* restore r15 for sigprocmask changes */
+	ldw	r15, (r2)
+	movi	r2, 0				/* return 0 */
+	jmp	r15
+END(__getcontext)
+
+weak_alias(__getcontext, getcontext)
+
+#endif	/* __CSKYABIV2__*/
diff --git a/sysdeps/unix/sysv/linux/csky/getdents64.c b/sysdeps/unix/sysv/linux/csky/getdents64.c
new file mode 100644
index 0000000..0c75fb5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/getdents64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getdents64.c>
diff --git a/sysdeps/unix/sysv/linux/csky/libc-read_tp.S b/sysdeps/unix/sysv/linux/csky/libc-read_tp.S
new file mode 100644
index 0000000..ca9d2b8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/libc-read_tp.S
@@ -0,0 +1 @@
+#include <read_tp.S>
diff --git a/sysdeps/unix/sysv/linux/csky/lockf64.c b/sysdeps/unix/sysv/linux/csky/lockf64.c
new file mode 100644
index 0000000..a88f5a7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/lockf64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
diff --git a/sysdeps/unix/sysv/linux/csky/lxstat.c b/sysdeps/unix/sysv/linux/csky/lxstat.c
new file mode 100644
index 0000000..2371cd9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/lxstat.c
@@ -0,0 +1,2 @@
+#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
+
diff --git a/sysdeps/unix/sysv/linux/csky/mmap.S b/sysdeps/unix/sysv/linux/csky/mmap.S
new file mode 100644
index 0000000..0d27ba5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/mmap.S
@@ -0,0 +1,65 @@
+/* Copyright (C) 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/>.  */
+
+#ifdef __CSKYABIV2__
+# include "abiv2_mmap.S"
+#else
+
+#include <sysdep.h>
+
+/*void *mmap(void *addr, size_t len, int prot, int flags,
+             int fildes, off_t off);  */
+ENTRY (__mmap)
+	subi	sp, 24
+	stw	r2, (sp, 0)
+	stw	r3, (sp, 4)
+	stw	r4, (sp, 8)
+	stw	r5, (sp, 12)
+	stw	r6, (sp, 16)
+	stw	r7, (sp, 20)
+	mov	r2, sp
+	lrw	r1, __NR_mmap
+	trap	0
+	addi	sp, 24
+	lrw	r3, 0xfffff000
+	cmphs	r2, r3
+	bf	1f
+#ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	r15, (sp, 4)
+	bsr	.Lgetpc
+.Lgetpc:
+	lrw	gb, .Lgetpc@GOTPC
+	addu	gb, r15
+	lrw	r7, __syscall_error@PLT
+	addu	r7, gb
+	ldw	r7, (r7)
+	jsr	r7
+	ldw	gb, (sp, 0)
+	ldw	r15, (sp, 4)
+	addi	sp, 8
+#else
+	jmpi	__syscall_error
+#endif /* __PIC__ */
+1:
+	rts
+PSEUDO_END (__mmap)
+
+weak_alias (__mmap, mmap)
+libc_hidden_builtin_def (__mmap)
+#endif	/* __CSKYABVI2__*/
diff --git a/sysdeps/unix/sysv/linux/csky/pt-vfork.S b/sysdeps/unix/sysv/linux/csky/pt-vfork.S
new file mode 100644
index 0000000..9bbd34c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/pt-vfork.S
@@ -0,0 +1,50 @@
+/* Copyright (C) 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 <sysdep.h>
+#define _ERRNO_H	1
+#include <bits/errno.h>
+
+/* Clone the calling process, but without copying the whole address space.
+   The calling process is suspended until the new process exits or is
+   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
+   and the process ID of the new process to the old process.  */
+
+ENTRY (vfork_compat)
+#ifdef SAVE_PID
+	SAVE_PID
+#endif
+
+#ifdef __CSKYABIV2__
+	mov	t0, r7
+	lrw	r7, __NR_vfork
+	trap	0
+	mov	r7, t0
+#else
+	lrw     r1, __NR_vfork
+	trap    0
+#endif
+
+#ifdef RESTORE_PID
+	RESTORE_PID
+#endif
+	PSEUDO_RET
+	rts
+
+PSEUDO_END (vfork_compat)
+
+strong_alias (vfork_compat, vfork_compat2)
diff --git a/sysdeps/unix/sysv/linux/csky/read_tp.S b/sysdeps/unix/sysv/linux/csky/read_tp.S
new file mode 100644
index 0000000..99c6d1a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/read_tp.S
@@ -0,0 +1,47 @@
+/* Copyright (C) 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 <features.h>
+#include <sysdep.h>
+
+/* This function is exported from libc for use by user code.  libpthread, librt,
+   and the dynamic linker get their own private copies, for
+   performance (and in the case of ld.so, out of necessity); those are
+   all hidden.  */
+
+/* 
+ * __read_tp
+ * clobbe r0, others had to be saved 
+ *
+ */
+#if IS_IN (libc)
+	.global __read_tp
+#else
+	.hidden __read_tp
+#endif
+#ifdef __CSKYABIV2__
+ENTRY (__read_tp)
+	mov	r0, r31 
+	rts
+END (__read_tp)
+#else
+ENTRY (__read_tp)
+	trap	3
+	rts
+END (__read_tp)
+#endif
+
diff --git a/sysdeps/unix/sysv/linux/csky/readahead.c b/sysdeps/unix/sysv/linux/csky/readahead.c
new file mode 100644
index 0000000..47c44c3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/readahead.c
@@ -0,0 +1,44 @@
+/* Provide kernel hint to read ahead.
+   Copyright (C) 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 <fcntl.h>
+#include <sys/types.h>
+#include <endian.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+ssize_t
+__readahead (int fd, off64_t offset, size_t count)
+{
+#ifdef __CSKYABVI2__
+  return INLINE_SYSCALL (readahead, 4, fd,
+			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
+					   (off_t) (offset & 0xffffffff)),
+			 count);
+#else
+  return INLINE_SYSCALL (readahead, 5, fd, 0,
+			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
+					   (off_t) (offset & 0xffffffff)),
+			 count);
+
+#endif
+}
+
+weak_alias (__readahead, readahead)
diff --git a/sysdeps/unix/sysv/linux/csky/readdir64.c b/sysdeps/unix/sysv/linux/csky/readdir64.c
new file mode 100644
index 0000000..2ea26dd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/readdir64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/readdir64.c>
diff --git a/sysdeps/unix/sysv/linux/csky/readdir64_r.c b/sysdeps/unix/sysv/linux/csky/readdir64_r.c
new file mode 100644
index 0000000..9f54f89
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/readdir64_r.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/readdir64_r.c>
diff --git a/sysdeps/unix/sysv/linux/csky/scandir64.c b/sysdeps/unix/sysv/linux/csky/scandir64.c
new file mode 100644
index 0000000..506fd88
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/scandir64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/scandir64.c>
diff --git a/sysdeps/unix/sysv/linux/csky/socket.S b/sysdeps/unix/sysv/linux/csky/socket.S
new file mode 100644
index 0000000..3ceb232
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/socket.S
@@ -0,0 +1,171 @@
+/* Copyright (C) 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/>.  */
+
+#ifdef __CSKYABIV2__
+#include "abiv2_socket.S"
+#else
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+/* The socket-oriented system calls are handled unusally in Linux.
+   They are all gated through the single `socketcall' system call number.
+   `socketcall' takes two arguments: the first is the subcode, specifying
+   which socket function is being called; and the second is a pointer to
+   the arguments to the specific function.
+
+   The .S files for the other calls just #define socket and #include this.  */
+
+#ifndef NARGS
+#ifdef socket
+#error NARGS not defined
+#endif
+#define NARGS 3
+#endif
+
+#ifndef __socket
+# ifndef NO_WEAK_ALIAS
+#  define __socket P(__,socket)
+# else
+#  define __socket socket
+# endif
+#endif
+
+ENTRY (__socket)
+	subi	sp, 32
+	subi	sp, 8
+	.cfi_def_cfa_offset 40
+#if NARGS >= 1
+	stw	r2, (sp, 0)
+	.cfi_offset 2, -40
+#endif
+
+#if NARGS >= 2
+	stw	r3, (sp, 4)
+	.cfi_offset 3, -36
+#endif
+
+#if NARGS >= 3
+	stw	r4, (sp, 8)
+	.cfi_offset 4, -32
+#endif
+
+#if NARGS >= 4
+	stw	r5, (sp, 12)
+	.cfi_offset 5, -28
+#endif
+
+#if NARGS >= 5
+	stw	r6, (sp, 16)
+	.cfi_offset 6, -24
+#endif
+
+#if NARGS >= 6
+	stw	r7, (sp, 20)
+	.cfi_offset 7, -20
+#endif
+
+#if defined NEED_CANCELLATION && defined CENABLE
+	stw	r15, (sp, 24)
+	.cfi_offset 15, -16
+	st.w	r14, (sp, 28)
+	.cfi_offset 14, -12
+	st.w	r9, (sp, 32) 
+	.cfi_offset 9, -8
+	SINGLE_THREAD_P
+	bt	.Lsocket_cancel
+#endif
+
+	lrw	r1, __NR_socketcall
+	movi	r2, P(SOCKOP_, socket)
+	mov	r3, sp
+	trap	0
+	cfi_remember_state
+	.cfi_def_cfa_offset 40
+	addi	sp, 32
+	addi	sp, 8
+	.cfi_def_cfa_offset 0
+	mov     r1, r15
+	PSEUDO_RET
+
+#if defined NEED_CANCELLATION && defined CENABLE
+.Lsocket_cancel:
+	cfi_restore_state
+	/* GET GB */
+	bsr	1f
+1:
+	lrw	r14, 1b@GOTPC
+	add	r14, lr
+
+	CENABLE  
+	mov	r4, r2	/* save CENABLE return value */
+	lrw	r1, __NR_socketcall
+	movi	r2, P(SOCKOP_, socket)
+	mov	r3, sp
+	trap	0
+	mov	r9, r2 	/* (sp,0) save r9  */
+	mov	r2, r4
+	CDISABLE
+	mov	r2, r9
+	ldw	r15, (sp, 24)
+	.cfi_restore 15
+	ldw	r14, (sp, 28)
+	.cfi_restore 14
+	ldw	r9, (sp, 32)
+	.cfi_restore 9
+	addi	sp, 32
+	addi	sp, 8
+	.cfi_def_cfa_offset 0
+	btsti	r2, 31
+	bf	3f
+#ifdef __PIC__
+	subi	sp, 8
+	.cfi_def_cfa_offset 8
+	stw	gb, (sp, 0)
+	.cfi_offset 14, -8
+	stw	r15, (sp, 4)
+	.cfi_offset 15, -4
+	bsr     .Lgetpc
+.Lgetpc:
+	lrw     gb, .Lgetpc@GOTPC
+	addu    gb, r15
+	lrw     r7, SYSCALL_ERROR@GOTOFF
+	addu    r7, gb
+	jsr	r7
+	ldw	gb, (sp, 0)
+	ldw	r15, (sp, 4)
+	addi	sp, 8
+	.cfi_def_cfa_offset 0
+#else
+	jmpi	SYSCALL_ERROR
+#endif
+
+3:
+	rts
+#endif
+
+PSEUDO_END (__socket)
+
+libc_hidden_def (__socket)
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
+
+#endif	/* __CSKYABIV2__*/
diff --git a/sysdeps/unix/sysv/linux/csky/syscall.S b/sysdeps/unix/sysv/linux/csky/syscall.S
new file mode 100644
index 0000000..9b700a3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/syscall.S
@@ -0,0 +1,61 @@
+/* Copyright (C) 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/>.  */
+
+#ifdef __CSKYABIV2__
+# include "abiv2_syscall.S"
+#else
+
+# include <sysdep.h>
+
+ENTRY (syscall)
+	mov	r1, r2		/* syscall num */
+
+	mov	r2, r3		/* arg1 */
+	mov	r3, r4		/* arg2 */
+	mov	r4, r5		/* arg3 */
+	mov	r5, r6		/* arg4*/
+	mov	r6, r7		/* arg5*/
+	ld	r7, (sp, 0)	/* arg6 */
+	trap	0
+	lrw	r3, 0xfffff000
+	cmphs	r2, r3
+	bt	do_syscall_error
+	rts
+PSEUDO_END (syscall)
+
+do_syscall_error:
+# ifdef __PIC__
+	subi	sp, 8
+	stw	gb, (sp, 0)
+	stw	r15, (sp, 4)
+	bsr	.Lgetpc
+.Lgetpc:
+	lrw	gb, .Lgetpc@GOTPC
+	addu	gb, r15
+	lrw	r7, __syscall_error@PLT
+	addu	r7, gb
+	ldw	r7, (r7)
+	jsr	r7
+	ldw	gb, (sp, 0)
+	ldw	r15, (sp, 4)
+	addi	sp, 8
+# else
+	jmpi	__syscall_error
+# endif /* __PIC__ */
+	rts
+
+#endif /* __CSKYABVI2__ */
diff --git a/sysdeps/unix/sysv/linux/csky/syscalls.list b/sysdeps/unix/sysv/linux/csky/syscalls.list
new file mode 100644
index 0000000..53cff69
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/syscalls.list
@@ -0,0 +1,7 @@
+# File name	Caller	Syscall name	Args	Strong name	Weak names
+
+chown		-	chown32		i:sii	__chown		chown
+cacheflush	-	cacheflush	i:pii	_flush_cache	cacheflush
+
+prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
+fanotify_mark	EXTRA	fanotify_mark	i:iiiiis	fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/csky/versionsort64.c b/sysdeps/unix/sysv/linux/csky/versionsort64.c
new file mode 100644
index 0000000..144b691
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/versionsort64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/versionsort64.c>
diff --git a/sysdeps/unix/sysv/linux/csky/vfork.S b/sysdeps/unix/sysv/linux/csky/vfork.S
new file mode 100644
index 0000000..913ca00
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/vfork.S
@@ -0,0 +1,49 @@
+/* Copyright (C) 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/>.  */
+
+#ifdef __CSKYABIV2__
+# include "abiv2_vfork.S"
+#else
+
+# include <sysdep.h>
+# define _ERRNO_H	1
+# include <bits/errno.h>
+
+/* Clone the calling process, but without copying the whole address space.
+   The calling process is suspended until the new process exits or is
+   replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+   and the process ID of the new process to the old process.  */
+
+ENTRY (__vfork)
+# ifdef SAVE_PID
+	SAVE_PID
+# endif
+	lrw	r1, __NR_vfork
+	trap	0
+# ifdef RESTORE_PID
+	RESTORE_PID
+# endif
+	PSEUDO_RET
+	rts
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
+strong_alias (__vfork, __libc_vfork)
+
+#endif	/* __CSKYABIV2__*/
diff --git a/sysdeps/unix/sysv/linux/csky/xstat.c b/sysdeps/unix/sysv/linux/csky/xstat.c
new file mode 100644
index 0000000..e9869f5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/csky/xstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/xstat.c>
-- 
2.7.4



More information about the Libc-help mailing list