mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
Add C-SKY port
This patch add two abi combinations support for C-SKY ABIV2: soft-float little endian, hard float little endian. C-SKY ABI manual and architecture user guide are available from: https://github.com/c-sky/csky-doc * config.h.in (CSKYABI, CSKY_HARD_FLOAT): New Define. * scripts/build-many-glibcs.py: Add C-SKY targets. * sysdeps/csky/Implies: New file. * sysdeps/csky/Makefile: Likewise. * sysdeps/csky/abiv2/__longjmp.S: Likewise. * sysdeps/csky/abiv2/csky-mcount.S: Likewise. * sysdeps/csky/abiv2/dl-trampoline.S: Likewise. * sysdeps/csky/abiv2/memcmp.S: Likewise. * sysdeps/csky/abiv2/memcpy.S: Likewise. * sysdeps/csky/abiv2/memmove.S: Likewise. * sysdeps/csky/abiv2/memset.S: Likewise. * sysdeps/csky/abiv2/setjmp.S: Likewise. * sysdeps/csky/abiv2/start.S: Likewise. * sysdeps/csky/abiv2/strcmp.S: Likewise. * sysdeps/csky/abiv2/strcpy.S: Likewise. * sysdeps/csky/abiv2/strlen.S: Likewise. * sysdeps/csky/abiv2/tls-macros.h: Likewise. * sysdeps/csky/abort-instr.h: Likewise. * sysdeps/csky/atomic-machine.h: Likewise. * sysdeps/csky/bits/endian.h: Likewise. * sysdeps/csky/bits/fenv.h: Likewise. * sysdeps/csky/bits/link.h: Likewise. * sysdeps/csky/bits/setjmp.h: Likewise. * sysdeps/csky/bsd-_setjmp.S: Likewise. * sysdeps/csky/bsd-setjmp.S: Likewise. * sysdeps/csky/configure: Likewise. * sysdeps/csky/configure.ac: Likewise. * sysdeps/csky/dl-machine.h: Likewise. * sysdeps/csky/dl-procinfo.c: Likewise. * sysdeps/csky/dl-procinfo.h: Likewise. * sysdeps/csky/dl-sysdep.h: Likewise. * sysdeps/csky/dl-tls.h: Likewise. * sysdeps/csky/fpu/fclrexcpt.c: Likewise. * sysdeps/csky/fpu/fedisblxcpt.c: Likewise. * sysdeps/csky/fpu/feenablxcpt.c: Likewise. * sysdeps/csky/fpu/fegetenv.c: Likewise. * sysdeps/csky/fpu/fegetexcept.c: Likewise. * sysdeps/csky/fpu/fegetmode.c: Likewise. * sysdeps/csky/fpu/fegetround.c: Likewise. * sysdeps/csky/fpu/feholdexcpt.c: Likewise. * sysdeps/csky/fpu/fenv_libc.h: Likewise. * sysdeps/csky/fpu/fenv_private.h: Likewise. * sysdeps/csky/fpu/fesetenv.c: Likewise. * sysdeps/csky/fpu/fesetexcept.c: Likewise. * sysdeps/csky/fpu/fesetmode.c: Likewise. * sysdeps/csky/fpu/fesetround.c: Likewise. * sysdeps/csky/fpu/feupdateenv.c: Likewise. * sysdeps/csky/fpu/fgetexcptflg.c: Likewise. * sysdeps/csky/fpu/fix-fp-int-convert-overflow.h: Likewise. * sysdeps/csky/fpu/fraiseexcpt.c: Likewise. * sysdeps/csky/fpu/fsetexcptflg.c: Likewise. * sysdeps/csky/fpu/ftestexcept.c: Likewise. * sysdeps/csky/fpu/libm-test-ulps: Likewise. * sysdeps/csky/fpu/libm-test-ulps-name: Likewise. * sysdeps/csky/fpu_control.h: Likewise. * sysdeps/csky/gccframe.h: Likewise. * sysdeps/csky/jmpbuf-unwind.h: Likewise. * sysdeps/csky/ldsodefs.h: Likewise. * sysdeps/csky/libc-tls.c: Likewise. * sysdeps/csky/linkmap.h: Likewise. * sysdeps/csky/machine-gmon.h: Likewise. * sysdeps/csky/memusage.h: Likewise. * sysdeps/csky/nofpu/Implies: Likewise. * sysdeps/csky/nofpu/libm-test-ulps: Likewise. * sysdeps/csky/nofpu/libm-test-ulps-name: Likewise. * sysdeps/csky/nptl/Makefile: Likewise. * sysdeps/csky/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/csky/nptl/bits/semaphore.h: Likewise. * sysdeps/csky/nptl/pthread-offsets.h: Likewise. * sysdeps/csky/nptl/pthreaddef.h: Likewise. * sysdeps/csky/nptl/tcb-offsets.sym: Likewise. * sysdeps/csky/nptl/tls.h: Likewise. * sysdeps/csky/preconfigure: Likewise. * sysdeps/csky/sfp-machine.h: Likewise. * sysdeps/csky/sotruss-lib.c: Likewise. * sysdeps/csky/stackinfo.h: Likewise. * sysdeps/csky/sysdep.h: Likewise. * sysdeps/csky/tininess.h: Likewise. * sysdeps/csky/tst-audit.h: Likewise. * sysdeps/unix/sysv/linux/csky/Implies: Likewise. * sysdeps/unix/sysv/linux/csky/Makefile: Likewise. * sysdeps/unix/sysv/linux/csky/Versions: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/____longjmp_chk.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/clone.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/getcontext.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/setcontext.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/swapcontext.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/syscall.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S: Likewise. * sysdeps/unix/sysv/linux/csky/abiv2/ucontext_i.sym: Likewise. * sysdeps/unix/sysv/linux/csky/bits/procfs.h: Likewise. * sysdeps/unix/sysv/linux/csky/bits/shmlba.h: Likewise. * sysdeps/unix/sysv/linux/csky/c++-types.data: Likewise. * sysdeps/unix/sysv/linux/csky/configure: Likewise. * sysdeps/unix/sysv/linux/csky/configure.ac: Likewise. * sysdeps/unix/sysv/linux/csky/ipc_priv.h: Likewise. * sysdeps/unix/sysv/linux/csky/jmp_buf-macros.h: Likewise. * sysdeps/unix/sysv/linux/csky/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/csky/ld.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/ldconfig.h: Likewise. * sysdeps/unix/sysv/linux/csky/libBrokenLocale.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libanl.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libcrypt.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libdl.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libpthread.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libresolv.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/librt.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libthread_db.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/libutil.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/localplt.data: Likewise. * sysdeps/unix/sysv/linux/csky/makecontext.c: Likewise. * sysdeps/unix/sysv/linux/csky/profil-counter.h: Likewise. * sysdeps/unix/sysv/linux/csky/pt-vfork.S: Likewise. * sysdeps/unix/sysv/linux/csky/register-dump.h: Likewise. * sysdeps/unix/sysv/linux/csky/shlib-versions: Likewise. * sysdeps/unix/sysv/linux/csky/sigcontextinfo.h: Likewise. * sysdeps/unix/sysv/linux/csky/sys/cachectl.h: Likewise. * sysdeps/unix/sysv/linux/csky/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/csky/sys/user.h: Likewise. * sysdeps/unix/sysv/linux/csky/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/csky/sysdep.h: Likewise.
This commit is contained in:
parent
ac253355ba
commit
5f72b00591
126
ChangeLog
126
ChangeLog
@ -1,3 +1,129 @@
|
||||
2018-12-21 Mao Han <han_mao@c-sky.com>
|
||||
|
||||
* config.h.in (CSKYABI, CSKY_HARD_FLOAT): New Define.
|
||||
* scripts/build-many-glibcs.py: Add C-SKY targets.
|
||||
* sysdeps/csky/Implies: New file.
|
||||
* sysdeps/csky/Makefile: Likewise.
|
||||
* sysdeps/csky/abiv2/__longjmp.S: Likewise.
|
||||
* sysdeps/csky/abiv2/csky-mcount.S: Likewise.
|
||||
* sysdeps/csky/abiv2/dl-trampoline.S: Likewise.
|
||||
* sysdeps/csky/abiv2/memcmp.S: Likewise.
|
||||
* sysdeps/csky/abiv2/memcpy.S: Likewise.
|
||||
* sysdeps/csky/abiv2/memmove.S: Likewise.
|
||||
* sysdeps/csky/abiv2/memset.S: Likewise.
|
||||
* sysdeps/csky/abiv2/setjmp.S: Likewise.
|
||||
* sysdeps/csky/abiv2/start.S: Likewise.
|
||||
* sysdeps/csky/abiv2/strcmp.S: Likewise.
|
||||
* sysdeps/csky/abiv2/strcpy.S: Likewise.
|
||||
* sysdeps/csky/abiv2/strlen.S: Likewise.
|
||||
* sysdeps/csky/abiv2/tls-macros.h: Likewise.
|
||||
* sysdeps/csky/abort-instr.h: Likewise.
|
||||
* sysdeps/csky/atomic-machine.h: Likewise.
|
||||
* sysdeps/csky/bits/endian.h: Likewise.
|
||||
* sysdeps/csky/bits/fenv.h: Likewise.
|
||||
* sysdeps/csky/bits/link.h: Likewise.
|
||||
* sysdeps/csky/bits/setjmp.h: Likewise.
|
||||
* sysdeps/csky/bsd-_setjmp.S: Likewise.
|
||||
* sysdeps/csky/bsd-setjmp.S: Likewise.
|
||||
* sysdeps/csky/configure: Likewise.
|
||||
* sysdeps/csky/configure.ac: Likewise.
|
||||
* sysdeps/csky/dl-machine.h: Likewise.
|
||||
* sysdeps/csky/dl-procinfo.c: Likewise.
|
||||
* sysdeps/csky/dl-procinfo.h: Likewise.
|
||||
* sysdeps/csky/dl-sysdep.h: Likewise.
|
||||
* sysdeps/csky/dl-tls.h: Likewise.
|
||||
* sysdeps/csky/fpu/fclrexcpt.c: Likewise.
|
||||
* sysdeps/csky/fpu/fedisblxcpt.c: Likewise.
|
||||
* sysdeps/csky/fpu/feenablxcpt.c: Likewise.
|
||||
* sysdeps/csky/fpu/fegetenv.c: Likewise.
|
||||
* sysdeps/csky/fpu/fegetexcept.c: Likewise.
|
||||
* sysdeps/csky/fpu/fegetmode.c: Likewise.
|
||||
* sysdeps/csky/fpu/fegetround.c: Likewise.
|
||||
* sysdeps/csky/fpu/feholdexcpt.c: Likewise.
|
||||
* sysdeps/csky/fpu/fenv_libc.h: Likewise.
|
||||
* sysdeps/csky/fpu/fenv_private.h: Likewise.
|
||||
* sysdeps/csky/fpu/fesetenv.c: Likewise.
|
||||
* sysdeps/csky/fpu/fesetexcept.c: Likewise.
|
||||
* sysdeps/csky/fpu/fesetmode.c: Likewise.
|
||||
* sysdeps/csky/fpu/fesetround.c: Likewise.
|
||||
* sysdeps/csky/fpu/feupdateenv.c: Likewise.
|
||||
* sysdeps/csky/fpu/fgetexcptflg.c: Likewise.
|
||||
* sysdeps/csky/fpu/fix-fp-int-convert-overflow.h: Likewise.
|
||||
* sysdeps/csky/fpu/fraiseexcpt.c: Likewise.
|
||||
* sysdeps/csky/fpu/fsetexcptflg.c: Likewise.
|
||||
* sysdeps/csky/fpu/ftestexcept.c: Likewise.
|
||||
* sysdeps/csky/fpu/libm-test-ulps: Likewise.
|
||||
* sysdeps/csky/fpu/libm-test-ulps-name: Likewise.
|
||||
* sysdeps/csky/fpu_control.h: Likewise.
|
||||
* sysdeps/csky/gccframe.h: Likewise.
|
||||
* sysdeps/csky/jmpbuf-unwind.h: Likewise.
|
||||
* sysdeps/csky/ldsodefs.h: Likewise.
|
||||
* sysdeps/csky/libc-tls.c: Likewise.
|
||||
* sysdeps/csky/linkmap.h: Likewise.
|
||||
* sysdeps/csky/machine-gmon.h: Likewise.
|
||||
* sysdeps/csky/memusage.h: Likewise.
|
||||
* sysdeps/csky/nofpu/Implies: Likewise.
|
||||
* sysdeps/csky/nofpu/libm-test-ulps: Likewise.
|
||||
* sysdeps/csky/nofpu/libm-test-ulps-name: Likewise.
|
||||
* sysdeps/csky/nptl/Makefile: Likewise.
|
||||
* sysdeps/csky/nptl/bits/pthreadtypes-arch.h: Likewise.
|
||||
* sysdeps/csky/nptl/bits/semaphore.h: Likewise.
|
||||
* sysdeps/csky/nptl/pthread-offsets.h: Likewise.
|
||||
* sysdeps/csky/nptl/pthreaddef.h: Likewise.
|
||||
* sysdeps/csky/nptl/tcb-offsets.sym: Likewise.
|
||||
* sysdeps/csky/nptl/tls.h: Likewise.
|
||||
* sysdeps/csky/preconfigure: Likewise.
|
||||
* sysdeps/csky/sfp-machine.h: Likewise.
|
||||
* sysdeps/csky/sotruss-lib.c: Likewise.
|
||||
* sysdeps/csky/stackinfo.h: Likewise.
|
||||
* sysdeps/csky/sysdep.h: Likewise.
|
||||
* sysdeps/csky/tininess.h: Likewise.
|
||||
* sysdeps/csky/tst-audit.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/Implies: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/Makefile: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/Versions: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/____longjmp_chk.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/clone.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/getcontext.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/setcontext.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/swapcontext.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/syscall.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/abiv2/ucontext_i.sym: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/bits/procfs.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/bits/shmlba.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/c++-types.data: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/configure: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/configure.ac: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/ipc_priv.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/jmp_buf-macros.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/kernel-features.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/ld.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/ldconfig.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libBrokenLocale.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libanl.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libc.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libcrypt.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libdl.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libm.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libpthread.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libresolv.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/librt.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libthread_db.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/libutil.abilist: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/localplt.data: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/makecontext.c: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/profil-counter.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/pt-vfork.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/register-dump.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/shlib-versions: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/sigcontextinfo.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/sys/cachectl.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/sys/ucontext.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/sys/user.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/syscalls.list: Likewise.
|
||||
* sysdeps/unix/sysv/linux/csky/sysdep.h: Likewise.
|
||||
|
||||
2018-12-18 Albert ARIBAUD <albert.aribaud@3adev.fr>
|
||||
|
||||
* include/time.h (__difftime64): Add.
|
||||
|
6
NEWS
6
NEWS
@ -46,6 +46,12 @@ Major new features:
|
||||
incosistent mutex state after fork call in multithread environment.
|
||||
In both popen and system there is no direct access to user-defined mutexes.
|
||||
|
||||
* Support for the C-SKY ABIV2 running on Linux has been added. This port
|
||||
requires at least binutils-2.32, gcc-9.0, and linux-4.20. Two ABIs are
|
||||
supported:
|
||||
- C-SKY ABIV2 soft-float little-endian
|
||||
- C-SKY ABIV2 hard-float little-endian
|
||||
|
||||
Deprecated and removed features, and other changes affecting compatibility:
|
||||
|
||||
* The glibc.tune tunable namespace has been renamed to glibc.cpu and the
|
||||
|
1
README
1
README
@ -25,6 +25,7 @@ The GNU C Library supports these configurations for using Linux kernels:
|
||||
aarch64*-*-linux-gnu
|
||||
alpha*-*-linux-gnu
|
||||
arm-*-linux-gnueabi
|
||||
csky-*-linux-gnuabiv2
|
||||
hppa-*-linux-gnu
|
||||
i[4567]86-*-linux-gnu
|
||||
x86_64-*-linux-gnu Can build either x86_64 or x32
|
||||
|
@ -106,6 +106,12 @@
|
||||
/* AArch64 big endian ABI */
|
||||
#undef HAVE_AARCH64_BE
|
||||
|
||||
/* C-SKY ABI version. */
|
||||
#undef CSKYABI
|
||||
|
||||
/* C-SKY floating-point ABI. */
|
||||
#undef CSKY_HARD_FLOAT
|
||||
|
||||
/* RISC-V integer ABI for ld.so. */
|
||||
#undef RISCV_ABI_XLEN
|
||||
|
||||
|
@ -181,6 +181,13 @@ class Context(object):
|
||||
variant='be8',
|
||||
gcc_cfg=['--with-float=hard', '--with-arch=armv7-a',
|
||||
'--with-fpu=vfpv3'])
|
||||
self.add_config(arch='csky',
|
||||
os_name='linux-gnuabiv2',
|
||||
variant='soft',
|
||||
gcc_cfg=['--disable-multilib'])
|
||||
self.add_config(arch='csky',
|
||||
os_name='linux-gnuabiv2',
|
||||
gcc_cfg=['--with-float=hard', '--disable-multilib'])
|
||||
self.add_config(arch='hppa',
|
||||
os_name='linux-gnu')
|
||||
self.add_config(arch='i686',
|
||||
@ -1260,6 +1267,7 @@ class Config(object):
|
||||
arch_map = {'aarch64': 'arm64',
|
||||
'alpha': 'alpha',
|
||||
'arm': 'arm',
|
||||
'csky': 'csky',
|
||||
'hppa': 'parisc',
|
||||
'i486': 'x86',
|
||||
'i586': 'x86',
|
||||
|
5
sysdeps/csky/Implies
Normal file
5
sysdeps/csky/Implies
Normal file
@ -0,0 +1,5 @@
|
||||
init_array
|
||||
wordsize-32
|
||||
# C-SKY uses IEEE 754 floating point.
|
||||
ieee754/flt-32
|
||||
ieee754/dbl-64
|
9
sysdeps/csky/Makefile
Normal file
9
sysdeps/csky/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
ifeq ($(subdir),csu)
|
||||
gen-as-const-headers += tcb-offsets.sym
|
||||
endif
|
||||
|
||||
ASFLAGS-.os += $(pic-ccflag)
|
||||
|
||||
ifeq ($(subdir),gmon)
|
||||
sysdep_routines += csky-mcount
|
||||
endif
|
61
sysdeps/csky/abiv2/__longjmp.S
Normal file
61
sysdeps/csky/abiv2/__longjmp.S
Normal file
@ -0,0 +1,61 @@
|
||||
/* longjmp for C-SKY ABIV2.
|
||||
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>
|
||||
|
||||
ENTRY (__longjmp)
|
||||
mov a2, a0
|
||||
mov a0, a1 /* Get the return value in place. */
|
||||
cmpnei a0, 0
|
||||
bt have_return
|
||||
movi a0, 1 /* Can't let setjmp() return zero! */
|
||||
have_return:
|
||||
#ifdef CHECK_SP
|
||||
ldw r10, (a2, 0) /* Jmpbuf's sp. */
|
||||
# ifdef PTR_MANGLE
|
||||
PTR_DEMANGLE (r10, r10, a3)
|
||||
# endif
|
||||
CHECK_SP (r10)
|
||||
#endif
|
||||
ldw sp, (a2, 0)
|
||||
ldw lr, (a2, 4)
|
||||
ldw r4, (a2, 8)
|
||||
ldw r5, (a2, 12)
|
||||
ldw r6, (a2, 16)
|
||||
ldw r7, (a2, 20)
|
||||
ldw r8, (a2, 24)
|
||||
ldw r9, (a2, 28)
|
||||
ldw r10, (a2, 32)
|
||||
ldw r11, (a2, 36)
|
||||
ldw r16, (a2, 40)
|
||||
ldw r17, (a2, 44)
|
||||
ldw r26, (a2, 48)
|
||||
ldw r27, (a2, 52)
|
||||
ldw r28, (a2, 56)
|
||||
ldw r29, (a2, 60)
|
||||
ldw r30, (a2, 64)
|
||||
ldw r31, (a2, 68)
|
||||
addi a2, 72
|
||||
|
||||
#ifdef PTR_MANGLE
|
||||
PTR_DEMANGLE (sp, sp, a3)
|
||||
PTR_DEMANGLE2 (lr, lr, a3)
|
||||
#endif
|
||||
jmp lr
|
||||
|
||||
END (__longjmp)
|
67
sysdeps/csky/abiv2/csky-mcount.S
Normal file
67
sysdeps/csky/abiv2/csky-mcount.S
Normal file
@ -0,0 +1,67 @@
|
||||
/* Implementation of profiling support. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
/* Use an assembly stub with a special ABI. The calling lr has been
|
||||
pushed to the stack (which will be misaligned). We should preserve
|
||||
all registers except ip and pop a word off the stack.
|
||||
|
||||
NOTE: This assumes mcount_internal does not clobber any non-core
|
||||
(coprocessor) registers. Currently this is true, but may require
|
||||
additional attention in the future.
|
||||
|
||||
The calling sequence looks something like:
|
||||
func:
|
||||
push lr
|
||||
jbsr _mount
|
||||
<function body>
|
||||
*/
|
||||
|
||||
/* Don't call mcount when calling mcount... */
|
||||
#undef PROF
|
||||
|
||||
ENTRY (_mcount)
|
||||
subi sp, 20
|
||||
stw a0, (sp, 0)
|
||||
stw a1, (sp, 4)
|
||||
stw a2, (sp, 8)
|
||||
stw a3, (sp, 12)
|
||||
stw lr, (sp, 16)
|
||||
mov a1, lr
|
||||
ldw a0, (sp, 20)
|
||||
#ifdef __PIC__
|
||||
grs t1, .Lgetpc
|
||||
.Lgetpc:
|
||||
lrw t0, .Lgetpc@GOTPC
|
||||
addu t1, t0
|
||||
lrw t0, __mcount_internal@PLT
|
||||
ldr.w t0, (t1, t0 << 0)
|
||||
jsr t0
|
||||
#else
|
||||
jsri __mcount_internal
|
||||
#endif /* !__PIC__ */
|
||||
ldw a0, (sp, 0)
|
||||
ldw a1, (sp, 4)
|
||||
ldw a2, (sp, 8)
|
||||
ldw a3, (sp, 12)
|
||||
ldw t1, (sp, 16)
|
||||
ldw lr, (sp, 20)
|
||||
addi sp, 24
|
||||
jmp t1
|
||||
END (_mcount)
|
50
sysdeps/csky/abiv2/dl-trampoline.S
Normal file
50
sysdeps/csky/abiv2/dl-trampoline.S
Normal file
@ -0,0 +1,50 @@
|
||||
/* PLT trampolines. C-SKY ABIV2 version.
|
||||
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/>. */
|
||||
|
||||
/* This function is not called directly. It is jumped when attempting to
|
||||
use a symbol that has not yet been resolved.
|
||||
|
||||
.plt*:
|
||||
subi r0, 32
|
||||
stw r2, (r0, 0)
|
||||
stw r3, (r0, 4)
|
||||
lrw r3, #offset
|
||||
ldw r2, (gb, 8)
|
||||
jmp r2
|
||||
*/
|
||||
|
||||
#include <sysdep.h>
|
||||
|
||||
.globl _dl_runtime_resolve;
|
||||
.type _dl_runtime_resolve,@function;
|
||||
.align 4;
|
||||
_dl_runtime_resolve:
|
||||
subi sp, 20
|
||||
stm a0-a3, (sp)
|
||||
stw lr, (sp, 16)
|
||||
/* a0 = id, a1 = offset(do it in plt*). */
|
||||
ldw a0, (gb, 4)
|
||||
movi a1, 12
|
||||
mult a1, t1
|
||||
bsr _dl_fixup
|
||||
mov t0, a0
|
||||
ldw lr, (sp, 16)
|
||||
ldm a0-a3, (sp)
|
||||
addi sp, 20
|
||||
jmp t0
|
||||
.size _dl_runtime_resolve,.-_dl_runtime_resolve
|
142
sysdeps/csky/abiv2/memcmp.S
Normal file
142
sysdeps/csky/abiv2/memcmp.S
Normal file
@ -0,0 +1,142 @@
|
||||
/* The assembly function for memory compare. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
ENTRY (memcmp)
|
||||
/* Test if len less than 4 bytes. */
|
||||
mov r3, r0
|
||||
movi r0, 0
|
||||
mov r12, r4
|
||||
cmplti r2, 4
|
||||
jbt .L_compare_by_byte
|
||||
|
||||
andi r13, r0, 3
|
||||
movi r19, 4
|
||||
/* Test if s1 is not 4 bytes aligned. */
|
||||
bnez r13, .L_s1_not_aligned
|
||||
|
||||
LABLE_ALIGN
|
||||
.L_s1_aligned:
|
||||
/* If dest is aligned, then copy. */
|
||||
zext r18, r2, 31, 4
|
||||
/* Test if len less than 16 bytes. */
|
||||
bez r18, .L_compare_by_word
|
||||
|
||||
.L_compare_by_4word:
|
||||
/* If aligned, load word each time. */
|
||||
ldw r20, (r3, 0)
|
||||
ldw r21, (r1, 0)
|
||||
/* If s1[i] != s2[i], goto .L_byte_check. */
|
||||
cmpne r20, r21
|
||||
bt .L_byte_check
|
||||
|
||||
ldw r20, (r3, 4)
|
||||
ldw r21, (r1, 4)
|
||||
cmpne r20, r21
|
||||
bt .L_byte_check
|
||||
|
||||
ldw r20, (r3, 8)
|
||||
ldw r21, (r1, 8)
|
||||
cmpne r20, r21
|
||||
bt .L_byte_check
|
||||
|
||||
ldw r20, (r3, 12)
|
||||
ldw r21, (r1, 12)
|
||||
cmpne r20, r21
|
||||
bt .L_byte_check
|
||||
|
||||
PRE_BNEZAD (r18)
|
||||
addi a3, 16
|
||||
addi a1, 16
|
||||
|
||||
BNEZAD (r18, .L_compare_by_4word)
|
||||
|
||||
.L_compare_by_word:
|
||||
zext r18, r2, 3, 2
|
||||
bez r18, .L_compare_by_byte
|
||||
.L_compare_by_word_loop:
|
||||
ldw r20, (r3, 0)
|
||||
ldw r21, (r1, 0)
|
||||
addi r3, 4
|
||||
PRE_BNEZAD (r18)
|
||||
cmpne r20, r21
|
||||
addi r1, 4
|
||||
bt .L_byte_check
|
||||
BNEZAD (r18, .L_compare_by_word_loop)
|
||||
|
||||
.L_compare_by_byte:
|
||||
zext r18, r2, 1, 0
|
||||
bez r18, .L_return
|
||||
.L_compare_by_byte_loop:
|
||||
ldb r0, (r3, 0)
|
||||
ldb r4, (r1, 0)
|
||||
addi r3, 1
|
||||
subu r0, r4
|
||||
PRE_BNEZAD (r18)
|
||||
addi r1, 1
|
||||
bnez r0, .L_return
|
||||
BNEZAD (r18, .L_compare_by_byte_loop)
|
||||
|
||||
.L_return:
|
||||
mov r4, r12
|
||||
rts
|
||||
|
||||
/* s1[i] != s2[i] in word, so we check byte 3. */
|
||||
.L_byte_check:
|
||||
xtrb3 r0, r20
|
||||
xtrb3 r2, r21
|
||||
subu r0, r2
|
||||
bnez r0, .L_return
|
||||
|
||||
/* check byte 2 */
|
||||
xtrb2 r0, r20
|
||||
xtrb2 r2, r21
|
||||
subu r0, r2
|
||||
bnez r0, .L_return
|
||||
|
||||
/* check byte 1 */
|
||||
xtrb1 r0, r20
|
||||
xtrb1 r2, r21
|
||||
subu r0, r2
|
||||
bnez r0, .L_return
|
||||
|
||||
/* check byte 0 */
|
||||
xtrb0 r0, r20
|
||||
xtrb0 r2, r21
|
||||
subu r0, r2
|
||||
br .L_return
|
||||
|
||||
/* Compare when s1 is not aligned. */
|
||||
.L_s1_not_aligned:
|
||||
sub r13, r19, r13
|
||||
sub r2, r13
|
||||
.L_s1_not_aligned_loop:
|
||||
ldb r0, (r3, 0)
|
||||
ldb r4, (r1, 0)
|
||||
addi r3, 1
|
||||
subu r0, r4
|
||||
PRE_BNEZAD (r13)
|
||||
addi r1, 1
|
||||
bnez r0, .L_return
|
||||
BNEZAD (r13, .L_s1_not_aligned_loop)
|
||||
br .L_s1_aligned
|
||||
END (memcmp)
|
||||
weak_alias (memcmp, bcmp)
|
||||
libc_hidden_def (memcmp)
|
||||
.weak memcmp
|
238
sysdeps/csky/abiv2/memcpy.S
Normal file
238
sysdeps/csky/abiv2/memcpy.S
Normal file
@ -0,0 +1,238 @@
|
||||
/* The assembly function for memcpy. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
ENTRY (memcpy)
|
||||
/* Test if len less than 4 bytes. */
|
||||
mov r12, r0
|
||||
cmplti r2, 4
|
||||
bt .L_copy_by_byte
|
||||
|
||||
andi r13, r0, 3
|
||||
movi r19, 4
|
||||
/* Test if dest is not 4 bytes aligned. */
|
||||
bnez r13, .L_dest_not_aligned
|
||||
.L_dest_aligned:
|
||||
/* If dest is aligned, then copy. */
|
||||
zext r18, r2, 31, 4
|
||||
/* Test if len less than 16 bytes. */
|
||||
bez r18, .L_len_less_16bytes
|
||||
movi r19, 0
|
||||
|
||||
LABLE_ALIGN
|
||||
.L_len_larger_16bytes:
|
||||
#if defined (__CSKY_VDSPV2__)
|
||||
vldx.8 vr0, (r1), r19
|
||||
PRE_BNEZAD (r18)
|
||||
addi r1, 16
|
||||
vstx.8 vr0, (r0), r19
|
||||
addi r0, 16
|
||||
#elif defined (__csky_fpuv2__) && defined(__CK810__)
|
||||
fldd fr4, (r1, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
fstd fr4, (r0, 0)
|
||||
fldd fr4, (r1, 8)
|
||||
addi r1, 16
|
||||
fstd fr4, (r0, 8)
|
||||
addi r0, 16
|
||||
#elif defined (__CK860__)
|
||||
ldw r3, (r1, 0)
|
||||
stw r3, (r0, 0)
|
||||
ldw r3, (r1, 4)
|
||||
stw r3, (r0, 4)
|
||||
ldw r3, (r1, 8)
|
||||
stw r3, (r0, 8)
|
||||
ldw r3, (r1, 12)
|
||||
addi r1, 16
|
||||
stw r3, (r0, 12)
|
||||
addi r0, 16
|
||||
#else
|
||||
ldw r20, (r1, 0)
|
||||
ldw r21, (r1, 4)
|
||||
ldw r22, (r1, 8)
|
||||
ldw r23, (r1, 12)
|
||||
stw r20, (r0, 0)
|
||||
stw r21, (r0, 4)
|
||||
stw r22, (r0, 8)
|
||||
stw r23, (r0, 12)
|
||||
PRE_BNEZAD (r18)
|
||||
addi r1, 16
|
||||
addi r0, 16
|
||||
#endif
|
||||
BNEZAD (r18, .L_len_larger_16bytes)
|
||||
|
||||
.L_len_less_16bytes:
|
||||
zext r18, r2, 3, 2
|
||||
bez r18, .L_copy_by_byte
|
||||
.L_len_less_16bytes_loop:
|
||||
ldw r3, (r1, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
addi r1, 4
|
||||
stw r3, (r0, 0)
|
||||
addi r0, 4
|
||||
BNEZAD (r18, .L_len_less_16bytes_loop)
|
||||
|
||||
/* Test if len less than 4 bytes. */
|
||||
.L_copy_by_byte:
|
||||
zext r18, r2, 1, 0
|
||||
bez r18, .L_return
|
||||
.L_copy_by_byte_loop:
|
||||
ldb r3, (r1, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
addi r1, 1
|
||||
stb r3, (r0, 0)
|
||||
addi r0, 1
|
||||
BNEZAD (r18, .L_copy_by_byte_loop)
|
||||
|
||||
.L_return:
|
||||
mov r0, r12
|
||||
rts
|
||||
|
||||
/* If dest is not aligned, just copying some bytes makes the dest
|
||||
align. */
|
||||
|
||||
.L_dest_not_aligned:
|
||||
sub r13, r19, r13
|
||||
mov r19, r13
|
||||
.L_dest_not_aligned_loop:
|
||||
/* Makes the dest align. */
|
||||
ldb r3, (r1, 0)
|
||||
PRE_BNEZAD (r13)
|
||||
addi r1, 1
|
||||
stb r3, (r0, 0)
|
||||
addi r0, 1
|
||||
BNEZAD (r13, .L_dest_not_aligned_loop)
|
||||
sub r2, r19
|
||||
cmplti r2, 4
|
||||
bt .L_copy_by_byte
|
||||
/* Check whether the src is aligned. */
|
||||
br .L_dest_aligned
|
||||
END (memcpy)
|
||||
|
||||
libc_hidden_builtin_def (memcpy)
|
||||
.weak memcpy
|
||||
|
||||
|
||||
ENTRY (memmove)
|
||||
subu r3, r0, r1
|
||||
cmphs r3, r2
|
||||
bt memcpy
|
||||
|
||||
mov r12, r0
|
||||
addu r0, r0, r2
|
||||
addu r1, r1, r2
|
||||
|
||||
/* Test if len less than 4 bytes. */
|
||||
cmplti r2, 4
|
||||
bt .L_copy_by_byte_m
|
||||
|
||||
andi r13, r0, 3
|
||||
/* Test if dest is not 4 bytes aligned. */
|
||||
bnez r13, .L_dest_not_aligned_m
|
||||
.L_dest_aligned_m:
|
||||
/* If dest is aligned, then copy. */
|
||||
zext r18, r2, 31, 4
|
||||
/* Test if len less than 16 bytes. */
|
||||
bez r18, .L_len_less_16bytes_m
|
||||
movi r19, 0
|
||||
|
||||
/* len > 16 bytes */
|
||||
LABLE_ALIGN
|
||||
.L_len_larger_16bytes_m:
|
||||
subi r1, 16
|
||||
subi r0, 16
|
||||
#if defined (__CSKY_VDSPV2__)
|
||||
vldx.8 vr0, (r1), r19
|
||||
PRE_BNEZAD (r18)
|
||||
vstx.8 vr0, (r0), r19
|
||||
#elif defined (__csky_fpuv2__) && defined(__CK810__)
|
||||
fldd fr4, (r1, 8)
|
||||
PRE_BNEZAD (r18)
|
||||
fstd fr4, (r0, 8)
|
||||
fldd fr4, (r1, 0)
|
||||
fstd fr4, (r0, 0)
|
||||
#elif defined (__CK860__)
|
||||
ldw r3, (r1, 12)
|
||||
stw r3, (r0, 12)
|
||||
ldw r3, (r1, 8)
|
||||
stw r3, (r0, 8)
|
||||
ldw r3, (r1, 4)
|
||||
stw r3, (r0, 4)
|
||||
ldw r3, (r1, 0)
|
||||
stw r3, (r0, 0)
|
||||
#else
|
||||
ldw r20, (r1, 0)
|
||||
ldw r21, (r1, 4)
|
||||
ldw r22, (r1, 8)
|
||||
ldw r23, (r1, 12)
|
||||
stw r20, (r0, 0)
|
||||
stw r21, (r0, 4)
|
||||
stw r22, (r0, 8)
|
||||
stw r23, (r0, 12)
|
||||
PRE_BNEZAD (r18)
|
||||
#endif
|
||||
BNEZAD (r18, .L_len_larger_16bytes_m)
|
||||
|
||||
.L_len_less_16bytes_m:
|
||||
zext r18, r2, 3, 2
|
||||
bez r18, .L_copy_by_byte_m
|
||||
.L_len_less_16bytes_loop_m:
|
||||
subi r1, 4
|
||||
subi r0, 4
|
||||
ldw r3, (r1, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
stw r3, (r0, 0)
|
||||
BNEZAD (r18, .L_len_less_16bytes_loop_m)
|
||||
|
||||
/* Test if len less than 4 bytes. */
|
||||
.L_copy_by_byte_m:
|
||||
zext r18, r2, 1, 0
|
||||
bez r18, .L_return_m
|
||||
.L_copy_by_byte_loop_m:
|
||||
subi r1, 1
|
||||
subi r0, 1
|
||||
ldb r3, (r1, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
stb r3, (r0, 0)
|
||||
BNEZAD (r18, .L_copy_by_byte_loop_m)
|
||||
|
||||
.L_return_m:
|
||||
mov r0, r12
|
||||
rts
|
||||
|
||||
/* If dest is not aligned, just copying some bytes makes the dest
|
||||
align. */
|
||||
.L_dest_not_aligned_m:
|
||||
sub r2, r13
|
||||
.L_dest_not_aligned_loop_m:
|
||||
subi r1, 1
|
||||
subi r0, 1
|
||||
/* Makes the dest align. */
|
||||
ldb r3, (r1, 0)
|
||||
PRE_BNEZAD (r13)
|
||||
stb r3, (r0, 0)
|
||||
BNEZAD (r13, .L_dest_not_aligned_loop_m)
|
||||
cmplti r2, 4
|
||||
bt .L_copy_by_byte_m
|
||||
/* Check whether the src is aligned. */
|
||||
br .L_dest_aligned_m
|
||||
END (memmove)
|
||||
|
||||
libc_hidden_builtin_def (memmove)
|
||||
.weak memmove
|
1
sysdeps/csky/abiv2/memmove.S
Normal file
1
sysdeps/csky/abiv2/memmove.S
Normal file
@ -0,0 +1 @@
|
||||
/* memmove is in memcpy.S. */
|
98
sysdeps/csky/abiv2/memset.S
Normal file
98
sysdeps/csky/abiv2/memset.S
Normal file
@ -0,0 +1,98 @@
|
||||
/* The assembly function for memset. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
ENTRY (memset)
|
||||
/* Test if len less than 4 bytes. */
|
||||
mov r12, r0
|
||||
cmplti r2, 8
|
||||
bt .L_set_by_byte
|
||||
|
||||
andi r13, r0, 3
|
||||
movi r19, 4
|
||||
/* Test if dest is not 4 bytes aligned. */
|
||||
bnez r13, .L_dest_not_aligned
|
||||
/* Hardware can handle unaligned access directly. */
|
||||
.L_dest_aligned:
|
||||
zextb r1, r1
|
||||
mov r3, r1
|
||||
lsli r1, 8
|
||||
or r1, r3
|
||||
lsli r3, r1, 16
|
||||
or r3, r1
|
||||
|
||||
/* If dest is aligned, then copy. */
|
||||
zext r18, r2, 31, 4
|
||||
/* Test if len less than 16 bytes. */
|
||||
bez r18, .L_len_less_16bytes
|
||||
|
||||
LABLE_ALIGN
|
||||
.L_len_larger_16bytes:
|
||||
stw r3, (r0, 0)
|
||||
stw r3, (r0, 4)
|
||||
stw r3, (r0, 8)
|
||||
stw r3, (r0, 12)
|
||||
PRE_BNEZAD (r18)
|
||||
addi r0, 16
|
||||
BNEZAD (r18, .L_len_larger_16bytes)
|
||||
|
||||
.L_len_less_16bytes:
|
||||
zext r18, r2, 3, 2
|
||||
andi r2, 3
|
||||
bez r18, .L_set_by_byte
|
||||
.L_len_less_16bytes_loop:
|
||||
stw r3, (r0, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
addi r0, 4
|
||||
BNEZAD (r18, .L_len_less_16bytes_loop)
|
||||
|
||||
/* Test if len less than 4 bytes. */
|
||||
.L_set_by_byte:
|
||||
zext r18, r2, 2, 0
|
||||
bez r18, .L_return
|
||||
.L_set_by_byte_loop:
|
||||
stb r1, (r0, 0)
|
||||
PRE_BNEZAD (r18)
|
||||
addi r0, 1
|
||||
BNEZAD (r18, .L_set_by_byte_loop)
|
||||
|
||||
.L_return:
|
||||
mov r0, r12
|
||||
rts
|
||||
|
||||
/* If dest is not aligned, just set some bytes makes the dest
|
||||
align. */
|
||||
|
||||
.L_dest_not_aligned:
|
||||
sub r13, r19, r13
|
||||
sub r2, r13
|
||||
.L_dest_not_aligned_loop:
|
||||
/* Makes the dest align. */
|
||||
stb r1, (r0, 0)
|
||||
PRE_BNEZAD (r13)
|
||||
addi r0, 1
|
||||
BNEZAD (r13, .L_dest_not_aligned_loop)
|
||||
cmplti r2, 8
|
||||
bt .L_set_by_byte
|
||||
/* Check whether the src is aligned. */
|
||||
br .L_dest_aligned
|
||||
END (memset)
|
||||
|
||||
libc_hidden_builtin_def (memset)
|
||||
.weak memset
|
77
sysdeps/csky/abiv2/setjmp.S
Normal file
77
sysdeps/csky/abiv2/setjmp.S
Normal file
@ -0,0 +1,77 @@
|
||||
/* setjmp for C-SKY ABIV2.
|
||||
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>
|
||||
|
||||
ENTRY (setjmp)
|
||||
movi a1, 1
|
||||
br __sigsetjmp
|
||||
END (setjmp)
|
||||
|
||||
ENTRY (_setjmp)
|
||||
movi a1, 0
|
||||
br __sigsetjmp
|
||||
END (_setjmp)
|
||||
|
||||
libc_hidden_def (_setjmp)
|
||||
|
||||
ENTRY (__sigsetjmp)
|
||||
mov a2, a0
|
||||
/* Save registers. */
|
||||
|
||||
#ifdef PTR_MANGLE
|
||||
PTR_MANGLE (t0, sp, a3)
|
||||
stw t0, (a2, 0)
|
||||
PTR_MANGLE2 (t0, lr, a3)
|
||||
stw t0, (a2, 4)
|
||||
#else
|
||||
stw sp, (a2, 0)
|
||||
stw lr, (a2, 4)
|
||||
#endif
|
||||
stw r4, (a2, 8)
|
||||
stw r5, (a2, 12)
|
||||
stw r6, (a2, 16)
|
||||
stw r7, (a2, 20)
|
||||
stw r8, (a2, 24)
|
||||
stw r9, (a2, 28)
|
||||
stw r10, (a2, 32)
|
||||
stw r11, (a2, 36)
|
||||
stw r16, (a2, 40)
|
||||
stw r17, (a2, 44)
|
||||
stw r26, (a2, 48)
|
||||
stw r27, (a2, 52)
|
||||
stw r28, (a2, 56)
|
||||
stw r29, (a2, 60)
|
||||
stw r30, (a2, 64)
|
||||
stw r31, (a2, 68)
|
||||
addi a2, 72
|
||||
|
||||
#ifdef __PIC__
|
||||
grs t1, .Lgetpc
|
||||
.Lgetpc:
|
||||
lrw t0, .Lgetpc@GOTPC
|
||||
addu t1, t0
|
||||
lrw a2, __sigjmp_save@PLT
|
||||
ldr.w a2, (t1, a2 << 0)
|
||||
jmp a2
|
||||
#else
|
||||
jmpi __sigjmp_save
|
||||
#endif /* !__PIC__ */
|
||||
END (__sigsetjmp)
|
||||
|
||||
hidden_def (__sigsetjmp)
|
108
sysdeps/csky/abiv2/start.S
Normal file
108
sysdeps/csky/abiv2/start.S
Normal file
@ -0,0 +1,108 @@
|
||||
/* Startup code compliant to the ELF C-SKY ABIV2.
|
||||
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.
|
||||
|
||||
In addition to the permissions in the GNU Lesser General Public
|
||||
License, the Free Software Foundation gives you unlimited
|
||||
permission to link the compiled version of this file with other
|
||||
programs, and to distribute those programs without any restriction
|
||||
coming from the use of this file. (The GNU Lesser General Public
|
||||
License restrictions do apply in other respects; for example, they
|
||||
cover modification of the file, and distribution when not linked
|
||||
into another program.)
|
||||
|
||||
Note that people who make modified versions of this file are not
|
||||
obligated to grant this special exception for their modified
|
||||
versions; it is their choice whether to do so. The GNU Lesser
|
||||
General Public License gives permission to release a modified
|
||||
version without this exception; this exception also makes it
|
||||
possible to release a modified version which carries forward this
|
||||
exception.
|
||||
|
||||
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/>. */
|
||||
|
||||
/* We need to call:
|
||||
__libc_start_main (int (*main) (int, char **, char **), int argc,
|
||||
char **argv, void (*init) (void), void (*fini) (void),
|
||||
void (*rtld_fini) (void), void *stack_end)
|
||||
*/
|
||||
|
||||
#include <sysdep.h>
|
||||
|
||||
.text
|
||||
.globl _start;
|
||||
.type _start,@function;
|
||||
.align 4;
|
||||
_start:
|
||||
subi sp, 8
|
||||
/* Clear the link register since this is the outermost frame. */
|
||||
movi lr, 0
|
||||
/* Pop argc off the stack and save a pointer to argv. */
|
||||
ldw a1, (sp, 8) /* Init argc for __libc_start_main. */
|
||||
addi a2, sp, 12 /* Init argv for __libc_start_main. */
|
||||
|
||||
/* Push stack limit. */
|
||||
stw a2, (sp, 8)
|
||||
/* Push rtld_fini. */
|
||||
stw a0, (sp, 4)
|
||||
|
||||
#ifdef SHARED
|
||||
grs t0, .Lgetpc
|
||||
.Lgetpc:
|
||||
lrw gb, .Lgetpc@GOTPC
|
||||
addu gb, t0
|
||||
lrw a3, __libc_csu_fini@GOT
|
||||
ldr.w a3, (gb, a3 << 0)
|
||||
stw a3, (sp, 0)
|
||||
|
||||
lrw a3, __libc_csu_init@GOT
|
||||
addu a3, gb
|
||||
ldw a3, (a3, 0)
|
||||
|
||||
lrw t0, main@GOT
|
||||
addu t0, gb
|
||||
ldw a0, (t0, 0)
|
||||
lrw t1, __libc_start_main@PLT
|
||||
ldr.w t1, (gb, t1 << 0)
|
||||
jsr t1
|
||||
|
||||
lrw t1, abort@PLT
|
||||
ldr.w t1, (gb, t1 << 0)
|
||||
jsr t1
|
||||
#else
|
||||
/* Fetch address of __libc_csu_fini. */
|
||||
lrw a0, __libc_csu_fini
|
||||
/* Push __libc_csu_fini */
|
||||
stw a0, (sp, 0)
|
||||
|
||||
/* Set up the other arguments in registers. */
|
||||
lrw a0, main
|
||||
lrw a3, __libc_csu_init
|
||||
/* Let the libc call main and exit with its return code. */
|
||||
jsri __libc_start_main
|
||||
|
||||
/* Should never get here. */
|
||||
jsri abort
|
||||
#endif /* !SHARED */
|
||||
.size _start,.-_start
|
||||
|
||||
|
||||
/* Define a symbol for the first piece of initialized data. */
|
||||
.data
|
||||
.globl __data_start
|
||||
__data_start:
|
||||
.long 0
|
||||
.weak data_start
|
||||
data_start = __data_start
|
156
sysdeps/csky/abiv2/strcmp.S
Normal file
156
sysdeps/csky/abiv2/strcmp.S
Normal file
@ -0,0 +1,156 @@
|
||||
/* The assembly function for string compare. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
ENTRY (strcmp)
|
||||
mov a3, a0
|
||||
/* Check if the s1 addr is aligned. */
|
||||
xor a2, a3, a1
|
||||
andi a2, 0x3
|
||||
bnez a2, 7f
|
||||
andi t1, a0, 0x3
|
||||
bnez t1, 5f
|
||||
|
||||
1:
|
||||
/* If aligned, load word each time. */
|
||||
ldw t0, (a3, 0)
|
||||
ldw t1, (a1, 0)
|
||||
/* If s1[i] != s2[i], goto 2f. */
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
/* If s1[i] == s2[i], check if s1 or s2 is at the end. */
|
||||
tstnbz t0
|
||||
/* If at the end, goto 3f (finish comparing). */
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 4)
|
||||
ldw t1, (a1, 4)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 8)
|
||||
ldw t1, (a1, 8)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 12)
|
||||
ldw t1, (a1, 12)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 16)
|
||||
ldw t1, (a1, 16)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 20)
|
||||
ldw t1, (a1, 20)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 24)
|
||||
ldw t1, (a1, 24)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
ldw t0, (a3, 28)
|
||||
ldw t1, (a1, 28)
|
||||
cmpne t0, t1
|
||||
bt 2f
|
||||
tstnbz t0
|
||||
bf 3f
|
||||
|
||||
addi a3, 32
|
||||
addi a1, 32
|
||||
|
||||
br 1b
|
||||
|
||||
/* s1[i] != s2[i] in word, so we check byte 3. */
|
||||
2:
|
||||
xtrb3 a0, t0
|
||||
xtrb3 a2, t1
|
||||
subu a0, a2
|
||||
bez a2, 4f
|
||||
bnez a0, 4f
|
||||
|
||||
/* Check byte 2. */
|
||||
xtrb2 a0, t0
|
||||
xtrb2 a2, t1
|
||||
subu a0, a2
|
||||
bez a2, 4f
|
||||
bnez a0, 4f
|
||||
|
||||
/* Check byte 1. */
|
||||
xtrb1 a0, t0
|
||||
xtrb1 a2, t1
|
||||
subu a0, a2
|
||||
bez a2, 4f
|
||||
bnez a0, 4f
|
||||
|
||||
/* Check byte 0. */
|
||||
xtrb0 a0, t0
|
||||
xtrb0 a2, t1
|
||||
subu a0, a2
|
||||
|
||||
jmp lr
|
||||
3:
|
||||
movi a0, 0
|
||||
4:
|
||||
jmp lr
|
||||
|
||||
/* Compare when s1 or s2 is not aligned. */
|
||||
5:
|
||||
subi t1, 4
|
||||
6:
|
||||
ldb a0, (a3, 0)
|
||||
ldb a2, (a1, 0)
|
||||
subu a0, a2
|
||||
bnez a0, 4b
|
||||
addi t1, 1
|
||||
bez a2, 4b
|
||||
addi a1, 1
|
||||
addi a3, 1
|
||||
bez t1, 1b
|
||||
br 6b
|
||||
|
||||
7:
|
||||
ldb a0, (a3, 0)
|
||||
addi a3, 1
|
||||
ldb a2, (a1, 0)
|
||||
addi a1, 1
|
||||
subu a0, a2
|
||||
bnez a0, 4b
|
||||
bnez a2, 7b
|
||||
jmp r15
|
||||
END (strcmp)
|
||||
|
||||
libc_hidden_def (strcmp)
|
||||
.weak strcmp
|
127
sysdeps/csky/abiv2/strcpy.S
Normal file
127
sysdeps/csky/abiv2/strcpy.S
Normal file
@ -0,0 +1,127 @@
|
||||
/* The assembly function for string copy. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
ENTRY (strcpy)
|
||||
mov a3, a0
|
||||
/* Check if the src addr is aligned. */
|
||||
andi t0, a1, 3
|
||||
bnez t0, 11f
|
||||
1:
|
||||
/* Check if all the bytes in the word are not zero. */
|
||||
ldw a2, (a1)
|
||||
tstnbz a2
|
||||
bf 9f
|
||||
stw a2, (a3)
|
||||
|
||||
ldw a2, (a1, 4)
|
||||
tstnbz a2
|
||||
bf 2f
|
||||
stw a2, (a3, 4)
|
||||
|
||||
ldw a2, (a1, 8)
|
||||
tstnbz a2
|
||||
bf 3f
|
||||
stw a2, (a3, 8)
|
||||
|
||||
ldw a2, (a1, 12)
|
||||
tstnbz a2
|
||||
bf 4f
|
||||
stw a2, (a3, 12)
|
||||
|
||||
ldw a2, (a1, 16)
|
||||
tstnbz a2
|
||||
bf 5f
|
||||
stw a2, (a3, 16)
|
||||
|
||||
ldw a2, (a1, 20)
|
||||
tstnbz a2
|
||||
bf 6f
|
||||
stw a2, (a3, 20)
|
||||
|
||||
ldw a2, (a1, 24)
|
||||
tstnbz a2
|
||||
bf 7f
|
||||
stw a2, (a3, 24)
|
||||
|
||||
ldw a2, (a1, 28)
|
||||
tstnbz a2
|
||||
bf 8f
|
||||
stw a2, (a3, 28)
|
||||
|
||||
addi a3, 32
|
||||
addi a1, 32
|
||||
br 1b
|
||||
|
||||
2:
|
||||
addi a3, 4
|
||||
br 9f
|
||||
|
||||
3:
|
||||
addi a3, 8
|
||||
br 9f
|
||||
|
||||
4:
|
||||
addi a3, 12
|
||||
br 9f
|
||||
|
||||
5:
|
||||
addi a3, 16
|
||||
br 9f
|
||||
|
||||
6:
|
||||
addi a3, 20
|
||||
br 9f
|
||||
|
||||
7:
|
||||
addi a3, 24
|
||||
br 9f
|
||||
|
||||
8:
|
||||
addi a3, 28
|
||||
9:
|
||||
xtrb3 t0, a2
|
||||
st.b t0, (a3)
|
||||
bez t0, 10f
|
||||
xtrb2 t0, a2
|
||||
st.b t0, (a3, 1)
|
||||
bez t0, 10f
|
||||
xtrb1 t0, a2
|
||||
st.b t0, (a3, 2)
|
||||
bez t0, 10f
|
||||
stw a2, (a3)
|
||||
10:
|
||||
jmp lr
|
||||
|
||||
11:
|
||||
subi t0, 4
|
||||
12:
|
||||
ld.b a2, (a1)
|
||||
st.b a2, (a3)
|
||||
bez a2, 10b
|
||||
addi t0, 1
|
||||
addi a1, a1, 1
|
||||
addi a3, a3, 1
|
||||
bnez t0, 12b
|
||||
br 1b
|
||||
|
||||
END (strcpy)
|
||||
|
||||
libc_hidden_def (strcpy)
|
||||
.weak strcpy
|
102
sysdeps/csky/abiv2/strlen.S
Normal file
102
sysdeps/csky/abiv2/strlen.S
Normal file
@ -0,0 +1,102 @@
|
||||
/* The assembly function for string length. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
ENTRY (strlen)
|
||||
/* Check if the start addr is aligned. */
|
||||
mov r3, r0
|
||||
andi r1, r0, 3
|
||||
movi r2, 4
|
||||
movi r0, 0
|
||||
bnez r1, .L_start_not_aligned
|
||||
|
||||
LABLE_ALIGN
|
||||
.L_start_addr_aligned:
|
||||
/* Check if all the bytes in the word are not zero. */
|
||||
ldw r1, (r3)
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 4)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 8)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 12)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 16)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 20)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 24)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
ldw r1, (r3, 28)
|
||||
addi r0, 4
|
||||
tstnbz r1
|
||||
bf .L_string_tail
|
||||
|
||||
addi r0, 4
|
||||
addi r3, 32
|
||||
br .L_start_addr_aligned
|
||||
|
||||
.L_string_tail:
|
||||
xtrb3 r3, r1
|
||||
bez r3, .L_return
|
||||
addi r0, 1
|
||||
xtrb2 r3, r1
|
||||
bez r3, .L_return
|
||||
addi r0, 1
|
||||
xtrb1 r3, r1
|
||||
bez r3, .L_return
|
||||
addi r0, 1
|
||||
|
||||
.L_return:
|
||||
rts
|
||||
|
||||
.L_start_not_aligned:
|
||||
sub r2, r2, r1
|
||||
.L_start_not_aligned_loop:
|
||||
ldb r1, (r3)
|
||||
PRE_BNEZAD (r2)
|
||||
addi r3, 1
|
||||
bez r1, .L_return
|
||||
addi r0, 1
|
||||
BNEZAD (r2, .L_start_not_aligned_loop)
|
||||
br .L_start_addr_aligned
|
||||
END (strlen)
|
||||
|
||||
libc_hidden_def (strlen)
|
||||
.weak strlen
|
55
sysdeps/csky/abiv2/tls-macros.h
Normal file
55
sysdeps/csky/abiv2/tls-macros.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* Macros for accessing thread-local storage. C-SKY ABIV2 version.
|
||||
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/>. */
|
||||
|
||||
# define TLS_LE(x) \
|
||||
({ int *__result; \
|
||||
__asm__ ("lrw %0, " #x "@TPOFF\n\t" \
|
||||
"add %0, tls, %0" \
|
||||
: "=&r" (__result)); \
|
||||
__result; })
|
||||
|
||||
# define TLS_IE(x) \
|
||||
({ int *__result; \
|
||||
__asm__ ("grs a1, 1f\n" \
|
||||
"1:\tlrw %0, " #x "@GOTTPOFF\n\t" \
|
||||
"ldr.w %0, (a1, %0 << 0)\n\t" \
|
||||
"add %0, tls, %0" \
|
||||
: "=&r" (__result): : "a1"); \
|
||||
__result; })
|
||||
|
||||
# define TLS_LD(x) \
|
||||
({ char *__result; \
|
||||
int __offset; \
|
||||
extern void *__tls_get_addr (void *); \
|
||||
__asm__ ("grs a1, 1f\n" \
|
||||
"1:\tlrw %0, " #x "@TLSLDM32;\n\t" \
|
||||
"add %0, a1, %0" \
|
||||
: "=r" (__result) : : "a1"); \
|
||||
__result = (char *)__tls_get_addr (__result); \
|
||||
__asm__ ("lrw %0, " #x "@TLSLDO32" \
|
||||
: "=r" (__offset)); \
|
||||
(int *) (__result + __offset); })
|
||||
|
||||
# define TLS_GD(x) \
|
||||
({ int *__result; \
|
||||
extern void *__tls_get_addr (void *); \
|
||||
__asm__ ("grs a1, 1f\n" \
|
||||
"1:\tlrw %0, " #x "@TLSGD32\n\t" \
|
||||
"add %0, a1, %0" \
|
||||
: "=r" (__result) : : "a1"); \
|
||||
(int *)__tls_get_addr (__result); })
|
2
sysdeps/csky/abort-instr.h
Normal file
2
sysdeps/csky/abort-instr.h
Normal file
@ -0,0 +1,2 @@
|
||||
/* An instruction which should crash any program is a breakpoint. */
|
||||
#define ABORT_INSTRUCTION asm ("bkpt")
|
77
sysdeps/csky/atomic-machine.h
Normal file
77
sysdeps/csky/atomic-machine.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* Atomic operations. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef __CSKY_ATOMIC_H_
|
||||
#define __CSKY_ATOMIC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int32_t atomic32_t;
|
||||
typedef uint32_t uatomic32_t;
|
||||
|
||||
typedef intptr_t atomicptr_t;
|
||||
typedef uintptr_t uatomicptr_t;
|
||||
typedef intmax_t atomic_max_t;
|
||||
typedef uintmax_t uatomic_max_t;
|
||||
|
||||
#define __HAVE_64B_ATOMICS 0
|
||||
#define USE_ATOMIC_COMPILER_BUILTINS 1
|
||||
#define ATOMIC_EXCHANGE_USES_CAS 1
|
||||
|
||||
#define __arch_compare_and_exchange_bool_8_int(mem, newval, oldval, model) \
|
||||
(abort (), 0)
|
||||
|
||||
#define __arch_compare_and_exchange_bool_16_int(mem, newval, oldval, model) \
|
||||
(abort (), 0)
|
||||
|
||||
#define __arch_compare_and_exchange_bool_32_int(mem, newval, oldval, model) \
|
||||
({ \
|
||||
typeof (*mem) __oldval = (oldval); \
|
||||
!__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
|
||||
model, __ATOMIC_RELAXED); \
|
||||
})
|
||||
|
||||
#define __arch_compare_and_exchange_bool_64_int(mem, newval, oldval, model) \
|
||||
(abort (), 0)
|
||||
|
||||
#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model) \
|
||||
(abort (), (__typeof (*mem)) 0)
|
||||
|
||||
#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) \
|
||||
(abort (), (__typeof (*mem)) 0)
|
||||
|
||||
#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) \
|
||||
({ \
|
||||
typeof (*mem) __oldval = (oldval); \
|
||||
__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0, \
|
||||
model, __ATOMIC_RELAXED); \
|
||||
__oldval; \
|
||||
})
|
||||
|
||||
#define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) \
|
||||
(abort (), (__typeof (*mem)) 0)
|
||||
|
||||
#define atomic_compare_and_exchange_bool_acq(mem, new, old) \
|
||||
__atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
|
||||
mem, new, old, __ATOMIC_ACQUIRE)
|
||||
|
||||
#define atomic_compare_and_exchange_val_acq(mem, new, old) \
|
||||
__atomic_val_bysize (__arch_compare_and_exchange_val, int, \
|
||||
mem, new, old, __ATOMIC_ACQUIRE)
|
||||
|
||||
#endif /* atomic-machine.h */
|
9
sysdeps/csky/bits/endian.h
Normal file
9
sysdeps/csky/bits/endian.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef _ENDIAN_H
|
||||
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
|
||||
#endif
|
||||
|
||||
#ifdef __CSKYBE__
|
||||
# error "Big endian not supported for C-SKY."
|
||||
#else
|
||||
# define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
111
sysdeps/csky/bits/fenv.h
Normal file
111
sysdeps/csky/bits/fenv.h
Normal file
@ -0,0 +1,111 @@
|
||||
/* Floating point environment. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _FENV_H
|
||||
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
|
||||
#endif
|
||||
|
||||
#ifdef __csky_hard_float__
|
||||
/* Define bits representing the exception. We use the bit positions
|
||||
of the appropriate bits in the FPU control word. */
|
||||
enum
|
||||
{
|
||||
FE_INVALID =
|
||||
#define FE_INVALID 0x01
|
||||
FE_INVALID,
|
||||
FE_DIVBYZERO =
|
||||
#define FE_DIVBYZERO 0x02
|
||||
FE_DIVBYZERO,
|
||||
FE_OVERFLOW =
|
||||
#define FE_OVERFLOW 0x04
|
||||
FE_OVERFLOW,
|
||||
FE_UNDERFLOW =
|
||||
#define FE_UNDERFLOW 0x08
|
||||
FE_UNDERFLOW,
|
||||
FE_INEXACT =
|
||||
#define FE_INEXACT 0x10
|
||||
FE_INEXACT,
|
||||
__FE_DENORMAL = 0x20
|
||||
};
|
||||
|
||||
#define FE_ALL_EXCEPT \
|
||||
(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
|
||||
|
||||
/* The C-SKY FPU supports all of the four defined rounding modes. We
|
||||
use again the bit positions in the FPU control word as the values
|
||||
for the appropriate macros. */
|
||||
enum
|
||||
{
|
||||
FE_TONEAREST =
|
||||
#define FE_TONEAREST (0x0 << 24)
|
||||
FE_TONEAREST,
|
||||
FE_TOWARDZERO =
|
||||
#define FE_TOWARDZERO (0x1 << 24)
|
||||
FE_TOWARDZERO,
|
||||
FE_UPWARD =
|
||||
#define FE_UPWARD (0x2 << 24)
|
||||
FE_UPWARD,
|
||||
FE_DOWNWARD =
|
||||
#define FE_DOWNWARD (0x3 << 24)
|
||||
FE_DOWNWARD,
|
||||
__FE_ROUND_MASK = (0x3 << 24)
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/* In the soft-float case, only rounding to nearest is supported, with
|
||||
no exceptions. */
|
||||
|
||||
enum
|
||||
{
|
||||
__FE_UNDEFINED = -1,
|
||||
|
||||
FE_TONEAREST =
|
||||
# define FE_TONEAREST 0x0
|
||||
FE_TONEAREST
|
||||
};
|
||||
|
||||
# define FE_ALL_EXCEPT 0
|
||||
|
||||
#endif
|
||||
|
||||
/* Type representing exception flags. */
|
||||
typedef unsigned int fexcept_t;
|
||||
|
||||
/* Type representing floating-point environment. */
|
||||
typedef struct
|
||||
{
|
||||
unsigned int __fpcr;
|
||||
unsigned int __fpsr;
|
||||
} fenv_t;
|
||||
|
||||
/* If the default argument is used we use this value. */
|
||||
#define FE_DFL_ENV ((const fenv_t *) -1)
|
||||
|
||||
#if defined __USE_GNU && defined __csky_hard_float__
|
||||
/* Floating-point environment where none of the exceptions are masked. */
|
||||
# define FE_NOMASK_ENV ((const fenv_t *) -2)
|
||||
#endif
|
||||
|
||||
#if __GLIBC_USE (IEC_60559_BFP_EXT)
|
||||
/* Type representing floating-point control modes. */
|
||||
typedef unsigned int femode_t;
|
||||
|
||||
/* Default floating-point control modes. */
|
||||
# define FE_DFL_MODE ((const femode_t *) -1L)
|
||||
#endif
|
55
sysdeps/csky/bits/link.h
Normal file
55
sysdeps/csky/bits/link.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* Machine-specific declarations for dynamic linker interface. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _LINK_H
|
||||
# error "Never include <bits/link.h> directly; use <link.h> instead."
|
||||
#endif
|
||||
|
||||
/* Registers for entry into PLT on C-SKY. */
|
||||
typedef struct La_csky_regs
|
||||
{
|
||||
uint32_t lr_reg[4];
|
||||
uint32_t lr_sp;
|
||||
uint32_t lr_lr;
|
||||
} La_csky_regs;
|
||||
|
||||
/* Return values for calls from PLT on C-SKY. */
|
||||
typedef struct La_csky_retval
|
||||
{
|
||||
/* Up to four integer registers can be used for a return value. */
|
||||
uint32_t lrv_reg[4];
|
||||
uint32_t lrv_v0;
|
||||
} La_csky_retval;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern Elf32_Addr la_csky_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
|
||||
uintptr_t *__refcook,
|
||||
uintptr_t *__defcook,
|
||||
La_csky_regs *__regs,
|
||||
unsigned int *__flags,
|
||||
const char *__symname,
|
||||
long int *__framesizep);
|
||||
extern unsigned int la_csky_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
|
||||
uintptr_t *__refcook,
|
||||
uintptr_t *__defcook,
|
||||
const La_csky_regs *__inregs,
|
||||
La_csky_retval *__outregs,
|
||||
const char *__symname);
|
||||
|
||||
__END_DECLS
|
34
sysdeps/csky/bits/setjmp.h
Normal file
34
sysdeps/csky/bits/setjmp.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* Define the machine-dependent type `jmp_buf'. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _CSKY_BITS_SETJMP_H
|
||||
#define _CSKY_BITS_SETJMP_H 1
|
||||
|
||||
typedef struct __jmp_buf_str
|
||||
{
|
||||
/* Stack pointer. */
|
||||
int __sp;
|
||||
int __lr;
|
||||
/* The actual core defines which registers should be saved. The
|
||||
buffer contains 32 words, keep space for future growth.
|
||||
Callee-saved registers:
|
||||
r4 ~ r11, r16 ~ r17, r26 ~r31 for abiv2; r8 ~ r14 for abiv1. */
|
||||
int __regs[32];
|
||||
} __jmp_buf[1];
|
||||
|
||||
#endif
|
1
sysdeps/csky/bsd-_setjmp.S
Normal file
1
sysdeps/csky/bsd-_setjmp.S
Normal file
@ -0,0 +1 @@
|
||||
/* _setjmp is in setjmp.S. */
|
1
sysdeps/csky/bsd-setjmp.S
Normal file
1
sysdeps/csky/bsd-setjmp.S
Normal file
@ -0,0 +1 @@
|
||||
/* setjmp is in setjmp.S. */
|
4
sysdeps/csky/configure
vendored
Normal file
4
sysdeps/csky/configure
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
|
||||
# Local configure fragment for sysdeps/csky.
|
||||
|
||||
$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
|
4
sysdeps/csky/configure.ac
Normal file
4
sysdeps/csky/configure.ac
Normal file
@ -0,0 +1,4 @@
|
||||
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
|
||||
# Local configure fragment for sysdeps/csky.
|
||||
|
||||
AC_DEFINE(PI_STATIC_AND_HIDDEN)
|
362
sysdeps/csky/dl-machine.h
Normal file
362
sysdeps/csky/dl-machine.h
Normal file
@ -0,0 +1,362 @@
|
||||
/* Machine-dependent ELF dynamic relocation inline functions. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef dl_machine_h
|
||||
#define dl_machine_h
|
||||
|
||||
#define ELF_MACHINE_NAME "csky"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sysdep.h>
|
||||
#include <dl-tls.h>
|
||||
|
||||
/* Return nonzero if ELF header is compatible with the running host. */
|
||||
static inline int
|
||||
elf_machine_matches_host (const Elf32_Ehdr *ehdr)
|
||||
{
|
||||
return ehdr->e_machine == EM_CSKY;
|
||||
}
|
||||
|
||||
/* Return the link-time address of _DYNAMIC.
|
||||
This must be inlined in a function which uses global data. */
|
||||
static inline Elf32_Addr
|
||||
elf_machine_dynamic (void)
|
||||
{
|
||||
register Elf32_Addr *got __asm__ ("gb");
|
||||
return *got;
|
||||
}
|
||||
|
||||
/* Return the run-time load address ,of the shared object. */
|
||||
static inline Elf32_Addr
|
||||
elf_machine_load_address (void)
|
||||
{
|
||||
extern Elf32_Addr __dl_start (void *) asm ("_dl_start");
|
||||
Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
|
||||
Elf32_Addr pcrel_addr;
|
||||
asm ("grs %0,_dl_start\n" : "=r" (pcrel_addr));
|
||||
|
||||
return pcrel_addr - got_addr;
|
||||
}
|
||||
|
||||
|
||||
/* Set up the loaded object described by L so its unrelocated PLT
|
||||
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
||||
|
||||
static inline int __attribute__ ((always_inline))
|
||||
elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
||||
{
|
||||
Elf32_Addr *got;
|
||||
extern void _dl_runtime_resolve (Elf32_Word);
|
||||
|
||||
if (l->l_info[DT_JMPREL] && lazy)
|
||||
{
|
||||
/* The GOT entries for functions in the PLT have not yet been
|
||||
filled in. Their initial contents will arrange when called
|
||||
to push an offset into the .rela.plt section, push
|
||||
_GLOBAL_OFFSET_TABLE_[1], and then jump to
|
||||
_GLOBAL_OFFSET_TABLE_[2]. */
|
||||
got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
|
||||
|
||||
if (got[1])
|
||||
l->l_mach.plt = got[1] + l->l_addr;
|
||||
got[1] = (Elf32_Addr) l; /* Identify this shared object. */
|
||||
|
||||
/* The got[2] entry contains the address of a function which gets
|
||||
called to get the address of a so far unresolved function and
|
||||
jump to it. The profiling extension of the dynamic linker allows
|
||||
to intercept the calls to collect information. In this case we
|
||||
don't store the address in the GOT so that all future calls also
|
||||
end in this function. */
|
||||
got[2] = (Elf32_Addr) &_dl_runtime_resolve;
|
||||
}
|
||||
return lazy;
|
||||
}
|
||||
|
||||
/* Mask identifying addresses reserved for the user program,
|
||||
where the dynamic linker should not map anything. */
|
||||
#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL
|
||||
|
||||
/* Initial entry point code for the dynamic linker.
|
||||
The C function `_dl_start' is the real entry point;
|
||||
its return value is the user program's entry point. */
|
||||
#define RTLD_START asm ("\
|
||||
.text\n\
|
||||
.globl _start\n\
|
||||
.type _start, @function\n\
|
||||
.globl _dl_start_user\n\
|
||||
.type _dl_start_user, @function\n\
|
||||
_start:\n\
|
||||
grs gb, .Lgetpc1\n\
|
||||
.Lgetpc1:\n\
|
||||
lrw t0, .Lgetpc1@GOTPC\n\
|
||||
addu gb, t0\n\
|
||||
mov a0, sp\n\
|
||||
lrw t1, _dl_start@GOTOFF\n\
|
||||
addu t1, gb\n\
|
||||
jsr t1\n\
|
||||
_dl_start_user:\n\
|
||||
/* get _dl_skip_args */ \n\
|
||||
lrw r11, _dl_skip_args@GOTOFF\n\
|
||||
addu r11, gb\n\
|
||||
ldw r11, (r11, 0)\n\
|
||||
/* store program entry address in r11 */ \n\
|
||||
mov r10, a0\n\
|
||||
/* Get argc */\n\
|
||||
ldw a1, (sp, 0)\n\
|
||||
/* Get **argv */\n\
|
||||
mov a2, sp\n\
|
||||
addi a2, 4\n\
|
||||
cmpnei r11, 0\n\
|
||||
bt .L_fixup_stack\n\
|
||||
.L_done_fixup:\n\
|
||||
mov a3, a1\n\
|
||||
lsli a3, 2\n\
|
||||
add a3, a2\n\
|
||||
addi a3, 4\n\
|
||||
lrw a0, _rtld_local@GOTOFF\n\
|
||||
addu a0, gb\n\
|
||||
ldw a0, (a0, 0)\n\
|
||||
lrw t1, _dl_init@PLT\n\
|
||||
addu t1, gb\n\
|
||||
ldw t1, (t1)\n\
|
||||
jsr t1\n\
|
||||
lrw a0, _dl_fini@GOTOFF\n\
|
||||
addu a0, gb\n\
|
||||
jmp r10\n\
|
||||
.L_fixup_stack:\n\
|
||||
subu a1, r11\n\
|
||||
lsli r11, 2\n\
|
||||
addu sp, r11\n\
|
||||
stw a1, (sp, 0)\n\
|
||||
mov a2, sp\n\
|
||||
addi a2, 4\n\
|
||||
lrw a3, _dl_argv@GOTOFF\n\
|
||||
addu a3, gb\n\
|
||||
stw a2, (a3, 0)\n\
|
||||
br .L_done_fixup\n\
|
||||
");
|
||||
|
||||
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
|
||||
TLS variable, so undefined references should not be allowed to
|
||||
define the value.
|
||||
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
|
||||
of the main executable's symbols, as for a COPY reloc. */
|
||||
#ifndef RTLD_BOOTSTRAP
|
||||
# define elf_machine_type_class(type) \
|
||||
((((type) == R_CKCORE_JUMP_SLOT || (type) == R_CKCORE_TLS_DTPMOD32 \
|
||||
|| (type) == R_CKCORE_TLS_DTPOFF32 || (type) == R_CKCORE_TLS_TPOFF32) \
|
||||
* ELF_RTYPE_CLASS_PLT) \
|
||||
| (((type) == R_CKCORE_COPY) * ELF_RTYPE_CLASS_COPY))
|
||||
#else
|
||||
# define elf_machine_type_class(type) \
|
||||
((((type) == R_CKCORE_JUMP_SLOT \
|
||||
| (((type) == R_CKCORE_COPY) * ELF_RTYPE_CLASS_COPY))
|
||||
#endif
|
||||
|
||||
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
|
||||
#define ELF_MACHINE_JMP_SLOT R_CKCORE_JUMP_SLOT
|
||||
|
||||
/* C-SKY never uses Elf32_Rel relocations. */
|
||||
#define ELF_MACHINE_NO_REL 1
|
||||
#define ELF_MACHINE_NO_RELA 0
|
||||
|
||||
/* We define an initialization functions. This is called very early in
|
||||
_dl_sysdep_start. */
|
||||
#define DL_PLATFORM_INIT dl_platform_init ()
|
||||
|
||||
static inline void __attribute__ ((unused))
|
||||
dl_platform_init (void)
|
||||
{
|
||||
if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
|
||||
/* Avoid an empty string which would disturb us. */
|
||||
GLRO(dl_platform) = NULL;
|
||||
}
|
||||
|
||||
static inline Elf32_Addr
|
||||
elf_machine_fixup_plt (struct link_map *map, lookup_t t,
|
||||
const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
|
||||
const Elf32_Rela *reloc,
|
||||
Elf32_Addr *reloc_addr, Elf32_Addr value)
|
||||
{
|
||||
return *reloc_addr = value;
|
||||
}
|
||||
|
||||
/* Return the final value of a plt relocation. On the csky the JMP_SLOT
|
||||
relocation ignores the addend. */
|
||||
static inline Elf32_Addr
|
||||
elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
|
||||
Elf32_Addr value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/* Names of the architecture-specific auditing callback functions. */
|
||||
#define ARCH_LA_PLTENTER csky_gnu_pltenter
|
||||
#define ARCH_LA_PLTEXIT csky_gnu_pltexit
|
||||
|
||||
#endif /* !dl_machine_h */
|
||||
#ifdef RESOLVE_MAP
|
||||
|
||||
/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
|
||||
MAP is the object containing the reloc. */
|
||||
|
||||
auto inline void __attribute__ ((unused, always_inline))
|
||||
elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
|
||||
const Elf32_Sym *sym, const struct r_found_version *version,
|
||||
void *const reloc_addr_arg, int skip_ifunc)
|
||||
{
|
||||
Elf32_Addr *const reloc_addr = reloc_addr_arg;
|
||||
const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
|
||||
unsigned short __attribute__ ((unused)) *opcode16_addr;
|
||||
Elf32_Addr __attribute__ ((unused)) insn_opcode = 0x0;
|
||||
|
||||
if (__builtin_expect (r_type == R_CKCORE_RELATIVE, 0))
|
||||
*reloc_addr = map->l_addr + reloc->r_addend;
|
||||
else
|
||||
{
|
||||
const Elf32_Sym *const refsym = sym;
|
||||
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
|
||||
ElfW(Addr) value = SYMBOL_ADDRESS (sym_map, sym, true);
|
||||
opcode16_addr = (unsigned short *)reloc_addr;
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case R_CKCORE_COPY:
|
||||
if (sym == NULL)
|
||||
/* This can happen in trace mode if an object could not be
|
||||
found. */
|
||||
break;
|
||||
if (sym->st_size > refsym->st_size
|
||||
|| (sym->st_size < refsym->st_size && GLRO(dl_verbose)))
|
||||
{
|
||||
const char *strtab;
|
||||
|
||||
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
|
||||
_dl_error_printf ("\
|
||||
%s: Symbol `%s' has different size in shared object, consider re-linking\n",
|
||||
rtld_progname ?: "<program name unknown>",
|
||||
strtab + refsym->st_name);
|
||||
}
|
||||
memcpy (reloc_addr_arg, (void *) value,
|
||||
MIN (sym->st_size, refsym->st_size));
|
||||
break;
|
||||
case R_CKCORE_GLOB_DAT:
|
||||
case R_CKCORE_JUMP_SLOT:
|
||||
*reloc_addr = value;
|
||||
break;
|
||||
case R_CKCORE_ADDR32:
|
||||
*reloc_addr = value + reloc->r_addend;
|
||||
break;
|
||||
case R_CKCORE_PCREL32:
|
||||
*reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
|
||||
break;
|
||||
#if defined(__CK810__) || defined(__CK807__)
|
||||
case R_CKCORE_ADDR_HI16:
|
||||
insn_opcode = (*opcode16_addr << 16) | (*(opcode16_addr + 1));
|
||||
insn_opcode = (insn_opcode & 0xffff0000)
|
||||
| (((value + reloc->r_addend) >> 16) & 0xffff);
|
||||
*(opcode16_addr++) = (unsigned short)(insn_opcode >> 16);
|
||||
*opcode16_addr = (unsigned short)(insn_opcode & 0xffff);
|
||||
break;
|
||||
case R_CKCORE_ADDR_LO16:
|
||||
insn_opcode = (*opcode16_addr << 16) | (*(opcode16_addr + 1));
|
||||
insn_opcode = (insn_opcode & 0xffff0000)
|
||||
| ((value + reloc->r_addend) & 0xffff);
|
||||
*(opcode16_addr++) = (unsigned short)(insn_opcode >> 16);
|
||||
*opcode16_addr = (unsigned short)(insn_opcode & 0xffff);
|
||||
break;
|
||||
case R_CKCORE_PCREL_IMM26BY2:
|
||||
{
|
||||
unsigned int offset = ((value + reloc->r_addend -
|
||||
(unsigned int)reloc_addr) >> 1);
|
||||
insn_opcode = (*opcode16_addr << 16) | (*(opcode16_addr + 1));
|
||||
if (offset > 0x3ffffff){
|
||||
const char *strtab;
|
||||
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
|
||||
|
||||
_dl_error_printf ("\
|
||||
%s:The reloc R_CKCORE_PCREL_IMM26BY2 cannot reach the symbol '%s'.\n",
|
||||
rtld_progname ?: "<program name unknown>",
|
||||
strtab + refsym->st_name);
|
||||
break;
|
||||
}
|
||||
insn_opcode = (insn_opcode & ~0x3ffffff) | offset;
|
||||
*(opcode16_addr++) = (unsigned short)(insn_opcode >> 16);
|
||||
*opcode16_addr = (unsigned short)(insn_opcode & 0xffff);
|
||||
break;
|
||||
}
|
||||
case R_CKCORE_PCREL_JSR_IMM26BY2:
|
||||
break;
|
||||
#endif
|
||||
#ifndef RTLD_BOOTSTRAP
|
||||
case R_CKCORE_TLS_DTPMOD32:
|
||||
/* Get the information from the link map returned by the
|
||||
resolv function. */
|
||||
if (sym_map != NULL)
|
||||
*reloc_addr = sym_map->l_tls_modid;
|
||||
break;
|
||||
case R_CKCORE_TLS_DTPOFF32:
|
||||
if (sym != NULL)
|
||||
*reloc_addr =(sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
|
||||
break;
|
||||
case R_CKCORE_TLS_TPOFF32:
|
||||
if (sym != NULL)
|
||||
{
|
||||
CHECK_STATIC_TLS (map, sym_map);
|
||||
*reloc_addr = (sym->st_value + sym_map->l_tls_offset
|
||||
+ reloc->r_addend);
|
||||
}
|
||||
break;
|
||||
#endif /* !RTLD_BOOTSTRAP */
|
||||
case R_CKCORE_NONE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto inline void __attribute__ ((unused, always_inline))
|
||||
elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
|
||||
void *const reloc_addr_arg)
|
||||
{
|
||||
Elf32_Addr *const reloc_addr = reloc_addr_arg;
|
||||
*reloc_addr = l_addr + reloc->r_addend;
|
||||
}
|
||||
|
||||
auto inline void __attribute__ ((unused, always_inline))
|
||||
elf_machine_lazy_rel (struct link_map *map,
|
||||
Elf32_Addr l_addr, const Elf32_Rela *reloc,
|
||||
int skip_ifunc)
|
||||
{
|
||||
Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
|
||||
const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
|
||||
if (ELF32_R_TYPE (reloc->r_info) == R_CKCORE_JUMP_SLOT)
|
||||
{
|
||||
/* Check for unexpected PLT reloc type. */
|
||||
if (__builtin_expect (r_type == R_CKCORE_JUMP_SLOT, 1))
|
||||
{
|
||||
if (__builtin_expect (map->l_mach.plt, 0) == 0)
|
||||
*reloc_addr = l_addr + reloc->r_addend;
|
||||
else
|
||||
*reloc_addr = map->l_mach.plt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* RESOLVE_MAP */
|
62
sysdeps/csky/dl-procinfo.c
Normal file
62
sysdeps/csky/dl-procinfo.c
Normal file
@ -0,0 +1,62 @@
|
||||
/* Data for C-SKY version of processor capability information.
|
||||
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/>. */
|
||||
|
||||
/* This information must be kept in sync with the _DL_PLATFORM_COUNT
|
||||
definitions in procinfo.h.
|
||||
|
||||
If anything should be added here check whether the size of each string
|
||||
is still ok with the given array size.
|
||||
|
||||
All the #ifdefs in the definitions are quite irritating but
|
||||
necessary if we want to avoid duplicating the information. There
|
||||
are three different modes:
|
||||
|
||||
- PROCINFO_DECL is defined. This means we are only interested in
|
||||
declarations.
|
||||
|
||||
- PROCINFO_DECL is not defined:
|
||||
|
||||
+ if SHARED is defined the file is included in an array
|
||||
initializer. The .element = { ... } syntax is needed.
|
||||
|
||||
+ if SHARED is not defined a normal array initialization is
|
||||
needed.
|
||||
*/
|
||||
|
||||
#ifndef PROCINFO_CLASS
|
||||
# define PROCINFO_CLASS
|
||||
#endif
|
||||
|
||||
#if !defined PROCINFO_DECL && defined SHARED
|
||||
._dl_csky_platforms
|
||||
#else
|
||||
PROCINFO_CLASS const char _dl_csky_platforms[4][6]
|
||||
#endif
|
||||
#ifndef PROCINFO_DECL
|
||||
= {
|
||||
"ck610", "ck807", "ck810", "ck860"
|
||||
}
|
||||
#endif
|
||||
#if !defined SHARED || defined PROCINFO_DECL
|
||||
;
|
||||
#else
|
||||
,
|
||||
#endif
|
||||
|
||||
#undef PROCINFO_DECL
|
||||
#undef PROCINFO_CLASS
|
59
sysdeps/csky/dl-procinfo.h
Normal file
59
sysdeps/csky/dl-procinfo.h
Normal file
@ -0,0 +1,59 @@
|
||||
/* C-SKY version of processor capability information handling macros.
|
||||
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/>. */
|
||||
|
||||
|
||||
#ifndef _DL_PROCINFO_H
|
||||
#define _DL_PROCINFO_H 1
|
||||
|
||||
#include <ldsodefs.h>
|
||||
|
||||
/* Mask to filter out platforms. */
|
||||
#define _DL_HWCAP_PLATFORM (-1ULL)
|
||||
|
||||
#define _DL_PLATFORMS_COUNT 4
|
||||
|
||||
static inline int
|
||||
__attribute__ ((unused, always_inline))
|
||||
_dl_string_platform (const char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (str != NULL)
|
||||
for (i = 0; i < _DL_PLATFORMS_COUNT; ++i)
|
||||
{
|
||||
if (strcmp (str, GLRO(dl_csky_platforms)[i]) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
/* We cannot provide a general printing function. */
|
||||
#define _dl_procinfo(word, val) -1
|
||||
|
||||
/* There are no hardware capabilities defined. */
|
||||
#define _dl_hwcap_string(idx) ""
|
||||
|
||||
/* By default there is no important hardware capability. */
|
||||
#define HWCAP_IMPORTANT (0)
|
||||
|
||||
/* We don't have any hardware capabilities. */
|
||||
#define _DL_HWCAP_COUNT 0
|
||||
|
||||
#define _dl_string_hwcap(str) (-1)
|
||||
|
||||
#endif /* dl-procinfo.h */
|
23
sysdeps/csky/dl-sysdep.h
Normal file
23
sysdeps/csky/dl-sysdep.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* System-specific settings for dynamic linker code. C-SKY version.
|
||||
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_next <dl-sysdep.h>
|
||||
|
||||
/* _dl_argv cannot be attribute_relro, because _dl_start_user
|
||||
might write into it after _dl_start returns. */
|
||||
#define DL_ARGV_NOT_RELRO 1
|
26
sysdeps/csky/dl-tls.h
Normal file
26
sysdeps/csky/dl-tls.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* Thread-local storage handling in the ELF dynamic linker. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
/* Type used for the representation of TLS information in the GOT. */
|
||||
typedef struct
|
||||
{
|
||||
unsigned long int ti_module;
|
||||
unsigned long int ti_offset;
|
||||
} tls_index;
|
||||
|
||||
extern void *__tls_get_addr (tls_index *ti);
|
42
sysdeps/csky/fpu/fclrexcpt.c
Normal file
42
sysdeps/csky/fpu/fclrexcpt.c
Normal file
@ -0,0 +1,42 @@
|
||||
/* Clear given exceptions in current floating-point environment.
|
||||
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 <fenv.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
feclearexcept (int excepts)
|
||||
{
|
||||
int fpsr;
|
||||
|
||||
/* Mask out unsupported bits/exceptions. */
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
|
||||
/* Read the complete control word. */
|
||||
_FPU_GETFPSR (fpsr);
|
||||
|
||||
/* Clear the relevant bits. */
|
||||
fpsr &= ~(excepts | (excepts << CAUSE_SHIFT));
|
||||
|
||||
/* Put the new data in effect. */
|
||||
_FPU_SETFPSR (fpsr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (feclearexcept)
|
41
sysdeps/csky/fpu/fedisblxcpt.c
Normal file
41
sysdeps/csky/fpu/fedisblxcpt.c
Normal file
@ -0,0 +1,41 @@
|
||||
/* Disable floating-point exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fedisableexcept (int excepts)
|
||||
{
|
||||
unsigned int new_exc, old_exc;
|
||||
|
||||
/* Get the current control word. */
|
||||
_FPU_GETCW (new_exc);
|
||||
|
||||
old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
|
||||
|
||||
/* Get the except disable mask. */
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
new_exc &= ~(excepts << ENABLE_SHIFT);
|
||||
|
||||
/* Put the new data in effect. */
|
||||
_FPU_SETCW (new_exc);
|
||||
|
||||
return old_exc;
|
||||
}
|
40
sysdeps/csky/fpu/feenablxcpt.c
Normal file
40
sysdeps/csky/fpu/feenablxcpt.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* Enable floating-point exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
feenableexcept (int excepts)
|
||||
{
|
||||
unsigned int new_exc, old_exc;
|
||||
|
||||
/* Get the current control word. */
|
||||
_FPU_GETCW (new_exc);
|
||||
|
||||
old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
|
||||
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
|
||||
new_exc |= excepts << ENABLE_SHIFT;
|
||||
|
||||
_FPU_SETCW (new_exc);
|
||||
|
||||
return old_exc;
|
||||
}
|
37
sysdeps/csky/fpu/fegetenv.c
Normal file
37
sysdeps/csky/fpu/fegetenv.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* Store current floating-point environment.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
__fegetenv (fenv_t *envp)
|
||||
{
|
||||
unsigned int fpcr;
|
||||
unsigned int fpsr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
_FPU_GETFPSR (fpsr);
|
||||
envp->__fpcr = fpcr;
|
||||
envp->__fpsr = fpsr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__fegetenv)
|
||||
weak_alias (__fegetenv, fegetenv)
|
||||
libm_hidden_weak (fegetenv)
|
32
sysdeps/csky/fpu/fegetexcept.c
Normal file
32
sysdeps/csky/fpu/fegetexcept.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* Get enabled floating-point exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fegetexcept (void)
|
||||
{
|
||||
unsigned int exc;
|
||||
|
||||
/* Get the current control word. */
|
||||
_FPU_GETCW (exc);
|
||||
|
||||
return (exc & ENABLE_MASK) >> ENABLE_SHIFT;
|
||||
}
|
28
sysdeps/csky/fpu/fegetmode.c
Normal file
28
sysdeps/csky/fpu/fegetmode.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* Store current floating-point control modes.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fegetmode (femode_t *modep)
|
||||
{
|
||||
_FPU_GETCW (*modep);
|
||||
|
||||
return 0;
|
||||
}
|
34
sysdeps/csky/fpu/fegetround.c
Normal file
34
sysdeps/csky/fpu/fegetround.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* Return current rounding direction.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
__fegetround (void)
|
||||
{
|
||||
unsigned int cw;
|
||||
|
||||
/* Get control word. */
|
||||
_FPU_GETCW (cw);
|
||||
|
||||
return cw & __FE_ROUND_MASK;
|
||||
}
|
||||
libm_hidden_def (__fegetround)
|
||||
weak_alias (__fegetround, fegetround)
|
||||
libm_hidden_weak (fegetround)
|
34
sysdeps/csky/fpu/feholdexcpt.c
Normal file
34
sysdeps/csky/fpu/feholdexcpt.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* Store current floating-point environment and clear exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fenv_private.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
__feholdexcept (fenv_t *envp)
|
||||
{
|
||||
libc_feholdexcept_vfp (envp);
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__feholdexcept)
|
||||
weak_alias (__feholdexcept, feholdexcept)
|
||||
libm_hidden_weak (feholdexcept)
|
30
sysdeps/csky/fpu/fenv_libc.h
Normal file
30
sysdeps/csky/fpu/fenv_libc.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* fpu registers environment. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _FENV_LIBC_H
|
||||
#define _FENV_LIBC_H 1
|
||||
|
||||
/* Mask for enabling exceptions and for the CAUSE bits. */
|
||||
#define ENABLE_MASK 0x0003FU
|
||||
#define CAUSE_MASK 0x3F000U
|
||||
|
||||
/* Shift for FE_* flags to get up to the ENABLE bits and the CAUSE bits. */
|
||||
#define ENABLE_SHIFT 0
|
||||
#define CAUSE_SHIFT 8
|
||||
|
||||
#endif /* fenv_libc.h */
|
280
sysdeps/csky/fpu/fenv_private.h
Normal file
280
sysdeps/csky/fpu/fenv_private.h
Normal file
@ -0,0 +1,280 @@
|
||||
/* Private floating point rounding and exceptions handling. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef CSKY_FENV_PRIVATE_H
|
||||
#define CSKY_FENV_PRIVATE_H 1
|
||||
|
||||
#include <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdexcept_vfp (fenv_t *envp)
|
||||
{
|
||||
fpu_control_t fpsr, fpcr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
envp->__fpcr = fpcr;
|
||||
|
||||
_FPU_GETFPSR (fpsr);
|
||||
envp->__fpsr = fpsr;
|
||||
|
||||
/* Now set all exceptions to non-stop. */
|
||||
fpcr &= ~FE_ALL_EXCEPT;
|
||||
|
||||
/* And clear all exception flags. */
|
||||
fpsr &= ~(FE_ALL_EXCEPT << CAUSE_SHIFT);
|
||||
|
||||
_FPU_SETFPSR (fpsr);
|
||||
|
||||
_FPU_SETCW (fpcr);
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_fesetround_vfp (int round)
|
||||
{
|
||||
fpu_control_t fpcr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
|
||||
/* Set new rounding mode if different. */
|
||||
if (__glibc_unlikely ((fpcr & FE_DOWNWARD) != round))
|
||||
_FPU_SETCW ((fpcr & ~FE_DOWNWARD) | round);
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdexcept_setround_vfp (fenv_t *envp, int round)
|
||||
{
|
||||
fpu_control_t fpsr, fpcr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
envp->__fpcr = fpcr;
|
||||
|
||||
_FPU_GETFPSR (fpsr);
|
||||
envp->__fpsr = fpsr;
|
||||
|
||||
/* Clear exception flags, set all exceptions to non-stop,
|
||||
and set new rounding mode. */
|
||||
fpsr &= ~(FE_ALL_EXCEPT << CAUSE_SHIFT);
|
||||
_FPU_SETFPSR (fpsr);
|
||||
|
||||
fpcr &= ~(FE_ALL_EXCEPT | FE_DOWNWARD);
|
||||
_FPU_SETCW (fpcr | round);
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdsetround_vfp (fenv_t *envp, int round)
|
||||
{
|
||||
fpu_control_t fpcr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
envp->__fpcr = fpcr;
|
||||
|
||||
/* Set new rounding mode if different. */
|
||||
if (__glibc_unlikely ((fpcr & FE_DOWNWARD) != round))
|
||||
_FPU_SETCW ((fpcr & ~FE_DOWNWARD) | round);
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feresetround_vfp (fenv_t *envp)
|
||||
{
|
||||
fpu_control_t fpcr, round;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
|
||||
/* Check whether rounding modes are different. */
|
||||
round = (envp->__fpcr ^ fpcr) & FE_DOWNWARD;
|
||||
|
||||
/* Restore the rounding mode if it was changed. */
|
||||
if (__glibc_unlikely (round != 0))
|
||||
_FPU_SETCW (fpcr ^ round);
|
||||
}
|
||||
|
||||
static __always_inline int
|
||||
libc_fetestexcept_vfp (int ex)
|
||||
{
|
||||
fpu_control_t fpsr;
|
||||
|
||||
_FPU_GETFPSR (fpsr);
|
||||
fpsr = fpsr >> CAUSE_SHIFT;
|
||||
return fpsr & ex & FE_ALL_EXCEPT;
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_fesetenv_vfp (const fenv_t *envp)
|
||||
{
|
||||
fpu_control_t fpcr, fpsr, new_fpcr, new_fpsr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
_FPU_GETFPSR (fpsr);
|
||||
|
||||
new_fpcr = envp->__fpcr;
|
||||
new_fpsr = envp->__fpsr;
|
||||
|
||||
if (__glibc_unlikely (fpsr ^ new_fpsr) != 0)
|
||||
_FPU_SETFPSR (new_fpsr);
|
||||
|
||||
if (__glibc_unlikely (fpcr ^ new_fpcr) != 0)
|
||||
_FPU_SETCW (new_fpcr);
|
||||
}
|
||||
|
||||
static __always_inline int
|
||||
libc_feupdateenv_test_vfp (const fenv_t *envp, int ex)
|
||||
{
|
||||
fpu_control_t fpcr, fpsr, new_fpcr, new_fpsr, excepts;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
_FPU_GETFPSR (fpsr);
|
||||
|
||||
/* Merge current exception flags with the saved fenv. */
|
||||
excepts = (fpsr >> CAUSE_SHIFT) & FE_ALL_EXCEPT;
|
||||
new_fpcr = envp->__fpcr;
|
||||
new_fpsr = envp->__fpsr | (excepts << CAUSE_SHIFT);
|
||||
|
||||
/* Write FCR and FESR if different. */
|
||||
if (__glibc_unlikely (fpsr ^ new_fpsr) != 0)
|
||||
_FPU_SETFPSR (new_fpsr);
|
||||
|
||||
if (__glibc_unlikely (fpcr ^ new_fpcr) != 0)
|
||||
_FPU_SETCW (new_fpcr);
|
||||
|
||||
/* Raise the exceptions if enabled in the new FP state. */
|
||||
if (__glibc_unlikely (excepts & new_fpcr))
|
||||
__feraiseexcept (excepts);
|
||||
|
||||
return excepts & ex;
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feupdateenv_vfp (const fenv_t *envp)
|
||||
{
|
||||
libc_feupdateenv_test_vfp (envp, 0);
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feholdsetround_vfp_ctx (struct rm_ctx *ctx, int r)
|
||||
{
|
||||
fpu_control_t fpcr, fpsr, round;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
_FPU_GETFPSR (fpsr);
|
||||
ctx->updated_status = false;
|
||||
ctx->env.__fpcr = fpcr;
|
||||
ctx->env.__fpsr = fpsr;
|
||||
|
||||
/* Check whether rounding modes are different. */
|
||||
round = (fpcr ^ r) & FE_DOWNWARD;
|
||||
|
||||
/* Set the rounding mode if changed. */
|
||||
if (__glibc_unlikely (round != 0))
|
||||
{
|
||||
ctx->updated_status = true;
|
||||
_FPU_SETCW (fpcr ^ round);
|
||||
}
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_feresetround_vfp_ctx (struct rm_ctx *ctx)
|
||||
{
|
||||
/* Restore the rounding mode if updated. */
|
||||
if (__glibc_unlikely (ctx->updated_status))
|
||||
{
|
||||
fpu_control_t fpcr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
fpcr = (fpcr & ~FE_DOWNWARD) | (ctx->env.__fpcr & FE_DOWNWARD);
|
||||
_FPU_SETCW (fpcr);
|
||||
}
|
||||
}
|
||||
|
||||
static __always_inline void
|
||||
libc_fesetenv_vfp_ctx (struct rm_ctx *ctx)
|
||||
{
|
||||
fpu_control_t fpcr, fpsr, new_fpcr, new_fpsr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
_FPU_GETFPSR (fpsr);
|
||||
|
||||
new_fpcr = ctx->env.__fpcr;
|
||||
new_fpsr = ctx->env.__fpsr;
|
||||
|
||||
if (__glibc_unlikely (fpsr ^ new_fpsr) != 0)
|
||||
_FPU_SETFPSR (new_fpsr);
|
||||
|
||||
if (__glibc_unlikely (fpcr ^ new_fpcr) != 0)
|
||||
_FPU_SETCW (new_fpcr);
|
||||
}
|
||||
|
||||
#define libc_feholdexcept libc_feholdexcept_vfp
|
||||
#define libc_feholdexceptf libc_feholdexcept_vfp
|
||||
#define libc_feholdexceptl libc_feholdexcept_vfp
|
||||
|
||||
#define libc_fesetround libc_fesetround_vfp
|
||||
#define libc_fesetroundf libc_fesetround_vfp
|
||||
#define libc_fesetroundl libc_fesetround_vfp
|
||||
|
||||
#define libc_feresetround libc_feresetround_vfp
|
||||
#define libc_feresetroundf libc_feresetround_vfp
|
||||
#define libc_feresetroundl libc_feresetround_vfp
|
||||
|
||||
#define libc_feresetround_noex libc_fesetenv_vfp
|
||||
#define libc_feresetround_noexf libc_fesetenv_vfp
|
||||
#define libc_feresetround_noexl libc_fesetenv_vfp
|
||||
|
||||
#define libc_feholdexcept_setround libc_feholdexcept_setround_vfp
|
||||
#define libc_feholdexcept_setroundf libc_feholdexcept_setround_vfp
|
||||
#define libc_feholdexcept_setroundl libc_feholdexcept_setround_vfp
|
||||
|
||||
#define libc_feholdsetround libc_feholdsetround_vfp
|
||||
#define libc_feholdsetroundf libc_feholdsetround_vfp
|
||||
#define libc_feholdsetroundl libc_feholdsetround_vfp
|
||||
|
||||
#define libc_fetestexcept libc_fetestexcept_vfp
|
||||
#define libc_fetestexceptf libc_fetestexcept_vfp
|
||||
#define libc_fetestexceptl libc_fetestexcept_vfp
|
||||
|
||||
#define libc_fesetenv libc_fesetenv_vfp
|
||||
#define libc_fesetenvf libc_fesetenv_vfp
|
||||
#define libc_fesetenvl libc_fesetenv_vfp
|
||||
|
||||
#define libc_feupdateenv libc_feupdateenv_vfp
|
||||
#define libc_feupdateenvf libc_feupdateenv_vfp
|
||||
#define libc_feupdateenvl libc_feupdateenv_vfp
|
||||
|
||||
#define libc_feupdateenv_test libc_feupdateenv_test_vfp
|
||||
#define libc_feupdateenv_testf libc_feupdateenv_test_vfp
|
||||
#define libc_feupdateenv_testl libc_feupdateenv_test_vfp
|
||||
|
||||
/* We have support for rounding mode context. */
|
||||
#define HAVE_RM_CTX 1
|
||||
|
||||
#define libc_feholdsetround_ctx libc_feholdsetround_vfp_ctx
|
||||
#define libc_feresetround_ctx libc_feresetround_vfp_ctx
|
||||
#define libc_feresetround_noex_ctx libc_fesetenv_vfp_ctx
|
||||
|
||||
#define libc_feholdsetroundf_ctx libc_feholdsetround_vfp_ctx
|
||||
#define libc_feresetroundf_ctx libc_feresetround_vfp_ctx
|
||||
#define libc_feresetround_noexf_ctx libc_fesetenv_vfp_ctx
|
||||
|
||||
#define libc_feholdsetroundl_ctx libc_feholdsetround_vfp_ctx
|
||||
#define libc_feresetroundl_ctx libc_feresetround_vfp_ctx
|
||||
#define libc_feresetround_noexl_ctx libc_fesetenv_vfp_ctx
|
||||
|
||||
#include_next <fenv_private.h>
|
||||
|
||||
#endif /* CSKY_FENV_PRIVATE_H */
|
59
sysdeps/csky/fpu/fesetenv.c
Normal file
59
sysdeps/csky/fpu/fesetenv.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* Install given floating-point environment.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
__fesetenv (const fenv_t *envp)
|
||||
{
|
||||
unsigned int fpcr;
|
||||
unsigned int fpsr;
|
||||
|
||||
_FPU_GETCW (fpcr);
|
||||
_FPU_GETFPSR (fpsr);
|
||||
|
||||
fpcr &= _FPU_RESERVED;
|
||||
fpsr &= _FPU_FPSR_RESERVED;
|
||||
|
||||
if (envp == FE_DFL_ENV)
|
||||
{
|
||||
fpcr |= _FPU_DEFAULT;
|
||||
fpsr |= _FPU_FPSR_DEFAULT;
|
||||
}
|
||||
else if (envp == FE_NOMASK_ENV)
|
||||
{
|
||||
fpcr |= _FPU_FPCR_IEEE;
|
||||
fpsr |= _FPU_FPSR_IEEE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fpcr |= envp->__fpcr & ~_FPU_RESERVED;
|
||||
fpsr |= envp->__fpsr & ~_FPU_FPSR_RESERVED;
|
||||
}
|
||||
|
||||
_FPU_SETFPSR (fpsr);
|
||||
|
||||
_FPU_SETCW (fpcr);
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__fesetenv)
|
||||
weak_alias (__fesetenv, fesetenv)
|
||||
libm_hidden_weak (fesetenv)
|
33
sysdeps/csky/fpu/fesetexcept.c
Normal file
33
sysdeps/csky/fpu/fesetexcept.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* Set given exception flags.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
|
||||
int
|
||||
fesetexcept (int excepts)
|
||||
{
|
||||
fpu_control_t fpsr, new_fpsr;
|
||||
_FPU_GETFPSR (fpsr);
|
||||
new_fpsr = fpsr | ((excepts & FE_ALL_EXCEPT) << CAUSE_SHIFT);
|
||||
if (new_fpsr != fpsr)
|
||||
_FPU_SETFPSR (new_fpsr);
|
||||
|
||||
return 0;
|
||||
}
|
33
sysdeps/csky/fpu/fesetmode.c
Normal file
33
sysdeps/csky/fpu/fesetmode.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* Install given floating-point control modes.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
|
||||
int
|
||||
fesetmode (const femode_t *modep)
|
||||
{
|
||||
femode_t mode;
|
||||
if (modep == FE_DFL_MODE)
|
||||
mode = _FPU_DEFAULT;
|
||||
else
|
||||
mode = *modep;
|
||||
_FPU_SETCW (mode);
|
||||
|
||||
return 0;
|
||||
}
|
32
sysdeps/csky/fpu/fesetround.c
Normal file
32
sysdeps/csky/fpu/fesetround.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* Set current rounding direction.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_private.h>
|
||||
|
||||
#include <stdio.h>
|
||||
int
|
||||
__fesetround (int round)
|
||||
{
|
||||
libc_fesetround_vfp (round);
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__fesetround)
|
||||
weak_alias (__fesetround, fesetround)
|
||||
libm_hidden_weak (fesetround)
|
46
sysdeps/csky/fpu/feupdateenv.c
Normal file
46
sysdeps/csky/fpu/feupdateenv.c
Normal file
@ -0,0 +1,46 @@
|
||||
/* Install given floating-point environment and raise exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fenv_private.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
__feupdateenv (const fenv_t *envp)
|
||||
{
|
||||
int temp;
|
||||
|
||||
/* Save current exceptions. */
|
||||
_FPU_GETFPSR (temp);
|
||||
temp = (temp >> CAUSE_SHIFT) & FE_ALL_EXCEPT;
|
||||
/* Install new environment. */
|
||||
__fesetenv (envp);
|
||||
|
||||
/* Raise the safed exception. Incidently for us the implementation
|
||||
defined format of the values in objects of type fexcept_t is the
|
||||
same as the ones specified using the FE_* constants. */
|
||||
feraiseexcept (temp);
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__feupdateenv)
|
||||
weak_alias (__feupdateenv, feupdateenv)
|
||||
libm_hidden_weak (feupdateenv)
|
32
sysdeps/csky/fpu/fgetexcptflg.c
Normal file
32
sysdeps/csky/fpu/fgetexcptflg.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* Store current representation for exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fenv_private.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fegetexceptflag (fexcept_t *flagp, int excepts)
|
||||
{
|
||||
*flagp = libc_fetestexcept_vfp (excepts);
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
33
sysdeps/csky/fpu/fix-fp-int-convert-overflow.h
Normal file
33
sysdeps/csky/fpu/fix-fp-int-convert-overflow.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* Fix for conversion of floating point to integer overflow. C-SKY version.
|
||||
Copyright (C) 2015-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/>. */
|
||||
|
||||
#ifndef FIX_FP_INT_CONVERT_OVERFLOW_H
|
||||
#define FIX_FP_INT_CONVERT_OVERFLOW_H 1
|
||||
|
||||
/* Define these macros to 1 to workaround conversions of out-of-range
|
||||
floating-point numbers to integer types failing to raise the
|
||||
"invalid" exception, or raising spurious "inexact" or other
|
||||
exceptions. */
|
||||
#define FIX_FLT_LONG_CONVERT_OVERFLOW 1
|
||||
#define FIX_FLT_LLONG_CONVERT_OVERFLOW 1
|
||||
#define FIX_DBL_LONG_CONVERT_OVERFLOW 1
|
||||
#define FIX_DBL_LLONG_CONVERT_OVERFLOW 1
|
||||
#define FIX_LDBL_LONG_CONVERT_OVERFLOW 1
|
||||
#define FIX_LDBL_LLONG_CONVERT_OVERFLOW 1
|
||||
|
||||
#endif /* fix-fp-int-convert-overflow.h */
|
126
sysdeps/csky/fpu/fraiseexcpt.c
Normal file
126
sysdeps/csky/fpu/fraiseexcpt.c
Normal file
@ -0,0 +1,126 @@
|
||||
/* Raise given exceptions.
|
||||
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 <fenv.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fpu_control.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
int
|
||||
__feraiseexcept (int excepts)
|
||||
{
|
||||
/* Raise exceptions represented by EXCEPTS. But we must raise only one
|
||||
signal at a time. It is important that if the overflow/underflow
|
||||
exception and the divide by zero exception are given at the same
|
||||
time, the overflow/underflow exception follows the divide by zero
|
||||
exception. */
|
||||
|
||||
# ifndef __csky_fpuv1__
|
||||
/* First: invalid exception. */
|
||||
if (FE_INVALID & excepts)
|
||||
{
|
||||
/* One example of a invalid operation is 0 * Infinity. */
|
||||
float x = HUGE_VALF, y = 0.0f;
|
||||
__asm__ __volatile__ ("fmuls %0, %0, %1" : "+v" (x) : "v" (y));
|
||||
}
|
||||
|
||||
/* Next: division by zero. */
|
||||
if (FE_DIVBYZERO & excepts)
|
||||
{
|
||||
float x = 1.0f, y = 0.0f;
|
||||
__asm__ __volatile__ ("fdivs %0, %0, %1" : "+v" (x) : "v" (y));
|
||||
}
|
||||
|
||||
/* Next: overflow. */
|
||||
if (FE_OVERFLOW & excepts)
|
||||
{
|
||||
float x = FLT_MAX;
|
||||
__asm__ __volatile__ ("fmuls %0, %0, %0" : "+v" (x));
|
||||
}
|
||||
/* Next: underflow. */
|
||||
if (FE_UNDERFLOW & excepts)
|
||||
{
|
||||
float x = -FLT_MIN;
|
||||
|
||||
__asm__ __volatile__ ("fmuls %0, %0, %0" : "+v" (x));
|
||||
}
|
||||
|
||||
/* Last: inexact. */
|
||||
if (FE_INEXACT & excepts)
|
||||
{
|
||||
float x = 1.0f, y = 3.0f;
|
||||
__asm__ __volatile__ ("fdivs %0, %0, %1" : "+v" (x) : "v" (y));
|
||||
}
|
||||
|
||||
if (__FE_DENORMAL & excepts)
|
||||
{
|
||||
double x = 4.9406564584124654e-324;
|
||||
__asm__ __volatile__ ("fstod %0, %0" : "+v" (x));
|
||||
}
|
||||
# else
|
||||
int tmp = 0;
|
||||
/* First: invalid exception. */
|
||||
if (FE_INVALID & excepts)
|
||||
{
|
||||
/* One example of a invalid operation is 0 * Infinity. */
|
||||
float x = HUGE_VALF, y = 0.0f;
|
||||
__asm__ __volatile__ ("fmuls %0, %0, %2, %1"
|
||||
: "+f" (x), "+r"(tmp) : "f" (y));
|
||||
}
|
||||
|
||||
/* Next: division by zero. */
|
||||
if (FE_DIVBYZERO & excepts)
|
||||
{
|
||||
float x = 1.0f, y = 0.0f;
|
||||
__asm__ __volatile__ ("fdivs %0, %0, %2, %1"
|
||||
: "+f" (x), "+r"(tmp) : "f" (y));
|
||||
}
|
||||
|
||||
/* Next: overflow. */
|
||||
if (FE_OVERFLOW & excepts)
|
||||
{
|
||||
float x = FLT_MAX, y = FLT_MAX;
|
||||
__asm__ __volatile__ ("fmuls %0, %0, %2, %1"
|
||||
: "+f" (x), "+r"(tmp) : "f" (y));
|
||||
}
|
||||
|
||||
/* Next: underflow. */
|
||||
if (FE_UNDERFLOW & excepts)
|
||||
{
|
||||
float x = -FLT_MIN, y = -FLT_MIN;
|
||||
|
||||
__asm__ __volatile__ ("fmuls %0, %0, %2, %1"
|
||||
: "+f" (x), "+r"(tmp) : "f" (y));
|
||||
}
|
||||
|
||||
/* Last: inexact. */
|
||||
if (FE_INEXACT & excepts)
|
||||
{
|
||||
float x = 1.0f, y = 3.0f;
|
||||
__asm__ __volatile__ ("fdivs %0, %0, %2, %1"
|
||||
: "+f" (x), "+r"(tmp) : "f" (y));
|
||||
}
|
||||
# endif /* __csky_fpuv2__ */
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
||||
libm_hidden_def (__feraiseexcept)
|
||||
weak_alias (__feraiseexcept, feraiseexcept)
|
||||
libm_hidden_weak (feraiseexcept)
|
43
sysdeps/csky/fpu/fsetexcptflg.c
Normal file
43
sysdeps/csky/fpu/fsetexcptflg.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* Set floating-point environment exception handling.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
|
||||
int
|
||||
fesetexceptflag (const fexcept_t *flagp, int excepts)
|
||||
{
|
||||
fpu_control_t temp;
|
||||
|
||||
/* Get the current exceptions. */
|
||||
_FPU_GETFPSR (temp);
|
||||
|
||||
/* Make sure the flags we want restored are legal. */
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
|
||||
/* Now clear the bits called for, and copy them in from flagp. Note that
|
||||
we ignore all non-flag bits from *flagp, so they don't matter. */
|
||||
temp = ((temp >> CAUSE_SHIFT) & ~excepts) | (*flagp & excepts);
|
||||
temp = temp << CAUSE_SHIFT;
|
||||
|
||||
_FPU_SETFPSR (temp);
|
||||
|
||||
/* Success. */
|
||||
return 0;
|
||||
}
|
30
sysdeps/csky/fpu/ftestexcept.c
Normal file
30
sysdeps/csky/fpu/ftestexcept.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Test exception in current environment.
|
||||
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 <fenv.h>
|
||||
#include <fpu_control.h>
|
||||
#include <fenv_libc.h>
|
||||
#include <fenv_private.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fetestexcept (int excepts)
|
||||
{
|
||||
return libc_fetestexcept_vfp (excepts);
|
||||
}
|
||||
libm_hidden_def (fetestexcept)
|
1640
sysdeps/csky/fpu/libm-test-ulps
Normal file
1640
sysdeps/csky/fpu/libm-test-ulps
Normal file
File diff suppressed because it is too large
Load Diff
1
sysdeps/csky/fpu/libm-test-ulps-name
Normal file
1
sysdeps/csky/fpu/libm-test-ulps-name
Normal file
@ -0,0 +1 @@
|
||||
CSKY
|
148
sysdeps/csky/fpu_control.h
Normal file
148
sysdeps/csky/fpu_control.h
Normal file
@ -0,0 +1,148 @@
|
||||
/* FPU control word bits. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _FPU_CONTROL_H
|
||||
#define _FPU_CONTROL_H
|
||||
|
||||
/* C-SKY FPU floating point control register bits.
|
||||
|
||||
31-28 -> Reserved (read as 0, write with 0).
|
||||
27 -> 0: Flush denormalized results to zero.
|
||||
1: Flush denormalized results to signed minimal normal number.
|
||||
26 -> Reserved (read as 0, write with 0).
|
||||
25-24 -> Rounding control.
|
||||
23-6 -> Reserved (read as 0, write with 0).
|
||||
5 -> Enable exception for input denormalized exception.
|
||||
4 -> Enable exception for inexact exception.
|
||||
3 -> Enable exception for underflow exception.
|
||||
2 -> Enable exception for overflow exception.
|
||||
1 -> Enable exception for division by zero exception.
|
||||
0 -> Enable exception for invalid operation exception.
|
||||
|
||||
Rounding Control:
|
||||
00 - Rounding to nearest (RN).
|
||||
01 - Rounding toward zero (RZ).
|
||||
10 - Rounding (up) toward plus infinity (RP).
|
||||
11 - Rounding (down)toward minus infinity (RM).
|
||||
|
||||
C-SKY FPU floating point exception status register bits.
|
||||
|
||||
15 -> Accumulate bit for any exception.
|
||||
14 -> Reserved (read as 0, write with 0).
|
||||
13 -> Cause bit for input denormalized exception.
|
||||
12 -> Cause bit for inexact exception.
|
||||
11 -> Cause bit for underflow exception.
|
||||
10 -> Cause bit for overflow exception.
|
||||
9 -> Cause bit for division by zero exception.
|
||||
8 -> Cause bit for invalid operation exception.
|
||||
7 -> Flag bit for any exception.
|
||||
6 -> Reserved (read as 0, write with 0).
|
||||
5 -> Flag exception for input denormalized exception.
|
||||
4 -> Flag exception for inexact exception.
|
||||
3 -> Flag exception for underflow exception.
|
||||
2 -> Flag exception for overflow exception.
|
||||
1 -> Flag exception for division by zero exception.
|
||||
0 -> Flag exception for invalid operation exception. */
|
||||
|
||||
#include <features.h>
|
||||
|
||||
#ifdef __csky_soft_float__
|
||||
|
||||
# define _FPU_RESERVED 0xffffffff
|
||||
# define _FPU_DEFAULT 0x00000000
|
||||
typedef unsigned int fpu_control_t;
|
||||
# define _FPU_GETCW(cw) (cw) = 0
|
||||
# define _FPU_SETCW(cw) (void) (cw)
|
||||
# define _FPU_GETFPSR(cw) (cw) = 0
|
||||
# define _FPU_SETFPSR(cw) (void) (cw)
|
||||
extern fpu_control_t __fpu_control;
|
||||
|
||||
#else /* __csky_soft_float__ */
|
||||
|
||||
/* Masking of interrupts. */
|
||||
# define _FPU_MASK_IDE (1 << 5) /* Input denormalized exception. */
|
||||
# define _FPU_MASK_IXE (1 << 4) /* Inexact exception. */
|
||||
# define _FPU_MASK_UFE (1 << 3) /* Underflow exception. */
|
||||
# define _FPU_MASK_OFE (1 << 2) /* Overflow exception. */
|
||||
# define _FPU_MASK_DZE (1 << 1) /* Division by zero exception. */
|
||||
# define _FPU_MASK_IOE (1 << 0) /* Invalid operation exception. */
|
||||
|
||||
# define _FPU_MASK_FEA (1 << 15) /* Case for any exception. */
|
||||
# define _FPU_MASK_FEC (1 << 7) /* Flag for any exception. */
|
||||
|
||||
/* Flush denormalized numbers to zero. */
|
||||
# define _FPU_FLUSH_TZ 0x8000000
|
||||
|
||||
/* Rounding control. */
|
||||
# define _FPU_RC_NEAREST (0x0 << 24) /* RECOMMENDED. */
|
||||
# define _FPU_RC_ZERO (0x1 << 24)
|
||||
# define _FPU_RC_UP (0x2 << 24)
|
||||
# define _FPU_RC_DOWN (0x3 << 24)
|
||||
|
||||
# define _FPU_RESERVED 0xf460ffc0 /* Reserved bits in cw. */
|
||||
# define _FPU_FPSR_RESERVED 0xffff4040
|
||||
|
||||
/* The fdlibm code requires strict IEEE double precision arithmetic,
|
||||
and no interrupts for exceptions, rounding to nearest. */
|
||||
|
||||
# define _FPU_DEFAULT 0x00000000
|
||||
# define _FPU_FPSR_DEFAULT 0x00000000
|
||||
|
||||
/* IEEE: same as above, but exceptions. */
|
||||
# define _FPU_FPCR_IEEE 0x0000001F
|
||||
# define _FPU_FPSR_IEEE 0x00000000
|
||||
|
||||
/* Type of the control word. */
|
||||
typedef unsigned int fpu_control_t;
|
||||
|
||||
/* Macros for accessing the hardware control word. */
|
||||
# if (__CSKY__ == 2)
|
||||
# define _FPU_GETCW(cw) __asm__ volatile ("mfcr %0, cr<1, 2>" : "=a" (cw))
|
||||
# define _FPU_SETCW(cw) __asm__ volatile ("mtcr %0, cr<1, 2>" : : "a" (cw))
|
||||
# define _FPU_GETFPSR(cw) __asm__ volatile ("mfcr %0, cr<2, 2>" : "=a" (cw))
|
||||
# define _FPU_SETFPSR(cw) __asm__ volatile ("mtcr %0, cr<2, 2>" : : "a" (cw))
|
||||
# else
|
||||
# define _FPU_GETCW(cw) __asm__ volatile ("1: cprcr %0, cpcr2 \n" \
|
||||
" btsti %0, 31 \n" \
|
||||
" bt 1b \n" \
|
||||
" cprcr %0, cpcr1\n" : "=b" (cw))
|
||||
|
||||
# define _FPU_SETCW(cw) __asm__ volatile ("1: cprcr r7, cpcr2 \n" \
|
||||
" btsti r7, 31 \n" \
|
||||
" bt 1b \n" \
|
||||
" cpwcr %0, cpcr1 \n" \
|
||||
: : "b" (cw) : "r7")
|
||||
|
||||
# define _FPU_GETFPSR(cw) __asm__ volatile ("1: cprcr %0, cpcr2 \n" \
|
||||
" btsti %0, 31 \n" \
|
||||
" bt 1b \n" \
|
||||
" cprcr %0, cpcr4\n" : "=b" (cw))
|
||||
|
||||
# define _FPU_SETFPSR(cw) __asm__ volatile ("1: cprcr r7, cpcr2 \n" \
|
||||
" btsti r7, 31 \n" \
|
||||
" bt 1b \n" \
|
||||
" cpwcr %0, cpcr4 \n" \
|
||||
: : "b" (cw) : "r7")
|
||||
# endif /* __CSKY__ != 2 */
|
||||
|
||||
/* Default control word set at startup. */
|
||||
extern fpu_control_t __fpu_control;
|
||||
|
||||
#endif /* !__csky_soft_float__ */
|
||||
|
||||
#endif /* fpu_control.h */
|
21
sysdeps/csky/gccframe.h
Normal file
21
sysdeps/csky/gccframe.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* Definition of object in frame unwind info. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#define FIRST_PSEUDO_REGISTER 71
|
||||
|
||||
#include <sysdeps/generic/gccframe.h>
|
48
sysdeps/csky/jmpbuf-unwind.h
Normal file
48
sysdeps/csky/jmpbuf-unwind.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* Examine __jmp_buf for unwinding frames. C-SkY version.
|
||||
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 <setjmp.h>
|
||||
#include <stdint.h>
|
||||
#include <unwind.h>
|
||||
#include <sysdep.h>
|
||||
|
||||
/* Test if longjmp to JMPBUF would unwind the frame
|
||||
containing a local variable at ADDRESS. */
|
||||
#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
|
||||
((void *) (address) < (void *) demangle ((jmpbuf)[0].__sp))
|
||||
|
||||
#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
|
||||
_JMPBUF_UNWINDS_ADJ (_jmpbuf, \
|
||||
(void *) (_Unwind_Ptr) _Unwind_GetCFA (_context), \
|
||||
_adj)
|
||||
|
||||
static inline uintptr_t __attribute__ ((unused))
|
||||
_jmpbuf_sp (__jmp_buf regs)
|
||||
{
|
||||
uintptr_t sp = (uintptr_t) regs[0].__sp;
|
||||
#ifdef PTR_DEMANGLE
|
||||
PTR_DEMANGLE (sp);
|
||||
#endif
|
||||
return sp;
|
||||
}
|
||||
|
||||
#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
|
||||
((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
|
||||
|
||||
/* We use the normal longjmp for unwinding. */
|
||||
#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
|
42
sysdeps/csky/ldsodefs.h
Normal file
42
sysdeps/csky/ldsodefs.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* Run-time dynamic linker data structures for loaded ELF shared objects.
|
||||
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/>. */
|
||||
|
||||
#ifndef _CSKY_LDSODEFS_H
|
||||
#define _CSKY_LDSODEFS_H 1
|
||||
|
||||
#include <elf.h>
|
||||
|
||||
struct La_csky_regs;
|
||||
struct La_csky_retval;
|
||||
|
||||
#define ARCH_PLTENTER_MEMBERS \
|
||||
Elf32_Addr (*csky_gnu_pltenter) (Elf32_Sym *, unsigned int, \
|
||||
uintptr_t *, uintptr_t *, \
|
||||
struct La_csky_regs *, \
|
||||
unsigned int *, const char *, \
|
||||
long int *);
|
||||
|
||||
#define ARCH_PLTEXIT_MEMBERS \
|
||||
unsigned int (*csky_gnu_pltexit) (Elf32_Sym *, unsigned int, \
|
||||
uintptr_t *, uintptr_t *, \
|
||||
const struct La_csky_regs *, \
|
||||
struct La_csky_retval *, \
|
||||
const char *);
|
||||
|
||||
#include_next <ldsodefs.h>
|
||||
#endif
|
32
sysdeps/csky/libc-tls.c
Normal file
32
sysdeps/csky/libc-tls.c
Normal file
@ -0,0 +1,32 @@
|
||||
/* Thread-local storage handling in the ELF dynamic linker. C-SKY version.
|
||||
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 <csu/libc-tls.c>
|
||||
#include <dl-tls.h>
|
||||
|
||||
/* On C-SKY, linker optimizations are not required, so __tls_get_addr
|
||||
can be called even in statically linked binaries. In this case module
|
||||
must be always 1 and PT_TLS segment exist in the binary, otherwise it
|
||||
would not link. */
|
||||
|
||||
void *
|
||||
__tls_get_addr (tls_index *ti)
|
||||
{
|
||||
dtv_t *dtv = THREAD_DTV ();
|
||||
return (char *) dtv[1].pointer.val + ti->ti_offset;
|
||||
}
|
4
sysdeps/csky/linkmap.h
Normal file
4
sysdeps/csky/linkmap.h
Normal file
@ -0,0 +1,4 @@
|
||||
struct link_map_machine
|
||||
{
|
||||
Elf32_Addr plt; /* Address of .plt. */
|
||||
};
|
32
sysdeps/csky/machine-gmon.h
Normal file
32
sysdeps/csky/machine-gmon.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* Machine-dependent definitions for profiling support. C-SKY version.
|
||||
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>
|
||||
|
||||
/* GCC for the C-SKY cannot compile __builtin_return_address (N) for N != 0,
|
||||
so we must use an assembly stub. */
|
||||
|
||||
/* We must not pollute the global namespace. */
|
||||
#define mcount_internal __mcount_internal
|
||||
|
||||
extern void mcount_internal (u_long frompc, u_long selfpc);
|
||||
#define _MCOUNT_DECL(frompc, selfpc) \
|
||||
void mcount_internal (u_long frompc, u_long selfpc)
|
||||
|
||||
/* Define MCOUNT as empty since we have the implementation in another file. */
|
||||
#define MCOUNT
|
21
sysdeps/csky/memusage.h
Normal file
21
sysdeps/csky/memusage.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* Machine-specific definitions for memory usage profiling, C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
|
||||
|
||||
#include <sysdeps/generic/memusage.h>
|
1
sysdeps/csky/nofpu/Implies
Normal file
1
sysdeps/csky/nofpu/Implies
Normal file
@ -0,0 +1 @@
|
||||
ieee754/soft-fp
|
1694
sysdeps/csky/nofpu/libm-test-ulps
Normal file
1694
sysdeps/csky/nofpu/libm-test-ulps
Normal file
File diff suppressed because it is too large
Load Diff
1
sysdeps/csky/nofpu/libm-test-ulps-name
Normal file
1
sysdeps/csky/nofpu/libm-test-ulps-name
Normal file
@ -0,0 +1 @@
|
||||
CSKY soft-float
|
20
sysdeps/csky/nptl/Makefile
Normal file
20
sysdeps/csky/nptl/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# 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/>.
|
||||
|
||||
ifeq ($(subdir),csu)
|
||||
gen-as-const-headers += tcb-offsets.sym
|
||||
endif
|
70
sysdeps/csky/nptl/bits/pthreadtypes-arch.h
Normal file
70
sysdeps/csky/nptl/bits/pthreadtypes-arch.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* Machine-specific pthread type layouts. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _BITS_PTHREADTYPES_ARCH_H
|
||||
#define _BITS_PTHREADTYPES_ARCH_H 1
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
#define __SIZEOF_PTHREAD_ATTR_T 36
|
||||
#define __SIZEOF_PTHREAD_MUTEX_T 24
|
||||
#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
|
||||
#define __SIZEOF_PTHREAD_COND_T 48
|
||||
#define __SIZEOF_PTHREAD_CONDATTR_T 4
|
||||
#define __SIZEOF_PTHREAD_RWLOCK_T 32
|
||||
#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
|
||||
#define __SIZEOF_PTHREAD_BARRIER_T 20
|
||||
#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
|
||||
|
||||
/* Data structure for mutex handling. */
|
||||
#define __PTHREAD_COMPAT_PADDING_MID
|
||||
#define __PTHREAD_COMPAT_PADDING_END
|
||||
#define __PTHREAD_MUTEX_LOCK_ELISION 0
|
||||
#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
|
||||
#define __PTHREAD_MUTEX_USE_UNION 1
|
||||
|
||||
#define __LOCK_ALIGNMENT
|
||||
#define __ONCE_ALIGNMENT
|
||||
|
||||
/* Paddings in this structure are not strictly necessary on C-SKY.
|
||||
They are left for extensibility as most other architecture do so. */
|
||||
struct __pthread_rwlock_arch_t
|
||||
{
|
||||
unsigned int __readers;
|
||||
unsigned int __writers;
|
||||
unsigned int __wrphase_futex;
|
||||
unsigned int __writers_futex;
|
||||
unsigned int __pad3;
|
||||
unsigned int __pad4;
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
unsigned char __pad1;
|
||||
unsigned char __pad2;
|
||||
unsigned char __shared;
|
||||
unsigned char __flags;
|
||||
#else
|
||||
unsigned char __flags;
|
||||
unsigned char __shared;
|
||||
unsigned char __pad1;
|
||||
unsigned char __pad2;
|
||||
#endif
|
||||
int __cur_writer;
|
||||
};
|
||||
|
||||
#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
|
||||
|
||||
#endif
|
35
sysdeps/csky/nptl/bits/semaphore.h
Normal file
35
sysdeps/csky/nptl/bits/semaphore.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* Machine-specific POSIX semaphore type layouts. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _SEMAPHORE_H
|
||||
# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
|
||||
#endif
|
||||
|
||||
|
||||
#define __SIZEOF_SEM_T 16
|
||||
|
||||
|
||||
/* Value returned if `sem_open' failed. */
|
||||
#define SEM_FAILED ((sem_t *) 0)
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
char __size[__SIZEOF_SEM_T];
|
||||
long int __align;
|
||||
} sem_t;
|
5
sysdeps/csky/nptl/pthread-offsets.h
Normal file
5
sysdeps/csky/nptl/pthread-offsets.h
Normal file
@ -0,0 +1,5 @@
|
||||
#define __PTHREAD_MUTEX_NUSERS_OFFSET 16
|
||||
#define __PTHREAD_MUTEX_KIND_OFFSET 12
|
||||
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
|
||||
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
|
||||
#define __PTHREAD_MUTEX_LIST_OFFSET 20
|
32
sysdeps/csky/nptl/pthreaddef.h
Normal file
32
sysdeps/csky/nptl/pthreaddef.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* pthread machine parameter definitions. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
/* Default stack size. */
|
||||
#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
|
||||
|
||||
/* Required stack pointer alignment at beginning. */
|
||||
#define STACK_ALIGN 8
|
||||
|
||||
/* Minimal stack size after allocating thread descriptor and guard size. */
|
||||
#define MINIMAL_REST_STACK 2048
|
||||
|
||||
/* Alignment requirement for TCB. */
|
||||
#define TCB_ALIGNMENT 8
|
||||
|
||||
/* Location of current stack frame. */
|
||||
#define CURRENT_STACK_FRAME __builtin_frame_address (0)
|
10
sysdeps/csky/nptl/tcb-offsets.sym
Normal file
10
sysdeps/csky/nptl/tcb-offsets.sym
Normal file
@ -0,0 +1,10 @@
|
||||
#include <sysdep.h>
|
||||
#include <tls.h>
|
||||
|
||||
--
|
||||
|
||||
-- Derive offsets relative to the thread register.
|
||||
#define thread_offsetof(mem) (long)(offsetof (struct pthread, mem) - sizeof (struct pthread))
|
||||
|
||||
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
|
||||
TID_OFFSET thread_offsetof (tid)
|
156
sysdeps/csky/nptl/tls.h
Normal file
156
sysdeps/csky/nptl/tls.h
Normal file
@ -0,0 +1,156 @@
|
||||
/* Definitions for thread-local data handling. NPTL/C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _TLS_H
|
||||
#define _TLS_H 1
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
# include <stdbool.h>
|
||||
# include <stddef.h>
|
||||
# include <stdint.h>
|
||||
# include <dl-dtv.h>
|
||||
|
||||
/* Define r31 as thread pointer register. */
|
||||
# define READ_THREAD_POINTER() \
|
||||
({ void *__result; \
|
||||
__asm__ __volatile__ ("mov %0, r31" \
|
||||
: "=r" (__result)); \
|
||||
__result; })
|
||||
|
||||
#else
|
||||
# include <tcb-offsets.h>
|
||||
/* Define r31 as thread pointer register. */
|
||||
# define READ_THREAD_POINTER() \
|
||||
mov r0, r31;
|
||||
#endif /* __ASSEMBLER__ */
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
/* Get system call information. */
|
||||
# include <sysdep.h>
|
||||
|
||||
/* The TP points to the start of the thread blocks. */
|
||||
# define TLS_DTV_AT_TP 1
|
||||
# define TLS_TCB_AT_TP 0
|
||||
|
||||
/* Get the thread descriptor definition. */
|
||||
# include <nptl/descr.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dtv_t *dtv;
|
||||
void *private;
|
||||
} tcbhead_t;
|
||||
|
||||
/* This is the size of the initial TCB. */
|
||||
# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
|
||||
|
||||
/* Alignment requirements for the initial TCB. */
|
||||
# define TLS_INIT_TCB_ALIGN 8
|
||||
|
||||
/* This is the size of the TCB. */
|
||||
# define TLS_TCB_SIZE sizeof (tcbhead_t)
|
||||
|
||||
/* Alignment requirements for the TCB. */
|
||||
# define TLS_TCB_ALIGN 8
|
||||
|
||||
/* This is the size we need before TCB. */
|
||||
# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
|
||||
|
||||
/* The thread pointer tp points to the end of the TCB.
|
||||
The pthread_descr structure is immediately in front of the TCB. */
|
||||
# define TLS_TCB_OFFSET 0
|
||||
|
||||
/* Install the dtv pointer. The pointer passed is to the element with
|
||||
index -1 which contain the length. */
|
||||
# define INSTALL_DTV(tcbp, dtvp) \
|
||||
(((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
|
||||
|
||||
/* Install new dtv for current thread. */
|
||||
# define INSTALL_NEW_DTV(dtv) \
|
||||
(THREAD_DTV() = (dtv))
|
||||
|
||||
/* Return dtv of given thread descriptor. */
|
||||
# define GET_DTV(tcbp) \
|
||||
(((tcbhead_t *) (tcbp))->dtv)
|
||||
|
||||
# define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
|
||||
|
||||
/* Code to initially initialize the thread pointer. This might need
|
||||
special attention since 'errno' is not yet available and if the
|
||||
operation can cause a failure 'errno' must not be touched. */
|
||||
# define TLS_INIT_TP(tcbp) \
|
||||
({ INTERNAL_SYSCALL_DECL (err); \
|
||||
long result_var; \
|
||||
result_var = INTERNAL_SYSCALL (set_thread_area, err, 1, \
|
||||
(char *) (tcbp) + TLS_TCB_OFFSET); \
|
||||
INTERNAL_SYSCALL_ERROR_P (result_var, err) \
|
||||
? "unknown error" : NULL; })
|
||||
|
||||
/* Return the address of the dtv for the current thread. */
|
||||
# define THREAD_DTV() \
|
||||
(((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))->dtv)
|
||||
|
||||
/* Return the thread descriptor for the current thread. */
|
||||
# undef THREAD_SELF
|
||||
# define THREAD_SELF \
|
||||
((struct pthread *) (READ_THREAD_POINTER () \
|
||||
- TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
|
||||
|
||||
/* Magic for libthread_db to know how to do THREAD_SELF. */
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (32, sizeof (struct pthread))
|
||||
|
||||
/* Access to data in the thread descriptor is easy. */
|
||||
# define THREAD_GETMEM(descr, member) \
|
||||
descr->member
|
||||
# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
descr->member[idx]
|
||||
# define THREAD_SETMEM(descr, member, value) \
|
||||
descr->member = (value)
|
||||
# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
descr->member[idx] = (value)
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
# define THREAD_GSCOPE_IN_TCB 1
|
||||
# define THREAD_GSCOPE_FLAG_UNUSED 0
|
||||
# define THREAD_GSCOPE_FLAG_USED 1
|
||||
# define THREAD_GSCOPE_FLAG_WAIT 2
|
||||
# define THREAD_GSCOPE_RESET_FLAG() \
|
||||
do \
|
||||
{ int __res \
|
||||
= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
|
||||
THREAD_GSCOPE_FLAG_UNUSED); \
|
||||
if (__res == THREAD_GSCOPE_FLAG_WAIT) \
|
||||
lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
|
||||
} \
|
||||
while (0)
|
||||
# define THREAD_GSCOPE_SET_FLAG() \
|
||||
do \
|
||||
{ \
|
||||
THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
|
||||
atomic_write_barrier (); \
|
||||
} \
|
||||
while (0)
|
||||
# define THREAD_GSCOPE_WAIT() \
|
||||
GL(dl_wait_lookup_done) ()
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
|
||||
#endif /* tls.h */
|
37
sysdeps/csky/preconfigure
Normal file
37
sysdeps/csky/preconfigure
Normal file
@ -0,0 +1,37 @@
|
||||
case "$machine" in
|
||||
csky*)
|
||||
abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
|
||||
sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'`
|
||||
float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
|
||||
sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'`
|
||||
|
||||
case "$abi" in
|
||||
1)
|
||||
echo "glibc does not support abiv1 yet" >&2
|
||||
exit 1
|
||||
;;
|
||||
2)
|
||||
machine=abiv2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown abi" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$float_abi" in
|
||||
1)
|
||||
with_fp_cond=1
|
||||
;;
|
||||
*)
|
||||
with_fp_cond=0
|
||||
;;
|
||||
esac
|
||||
|
||||
base_machine=csky
|
||||
machine=csky/$machine
|
||||
|
||||
$as_echo "#define CSKYABI $abi" >>confdefs.h
|
||||
$as_echo "#define CSKY_HARD_FLOAT $with_fp_cond" >>confdefs.h
|
||||
;;
|
||||
esac
|
50
sysdeps/csky/sfp-machine.h
Normal file
50
sysdeps/csky/sfp-machine.h
Normal file
@ -0,0 +1,50 @@
|
||||
#define _FP_W_TYPE_SIZE 32
|
||||
#define _FP_W_TYPE unsigned long
|
||||
#define _FP_WS_TYPE signed long
|
||||
#define _FP_I_TYPE long
|
||||
|
||||
#define _FP_MUL_MEAT_S(R,X,Y) \
|
||||
_FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
|
||||
#define _FP_MUL_MEAT_D(R,X,Y) \
|
||||
_FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
|
||||
#define _FP_MUL_MEAT_Q(R,X,Y) \
|
||||
_FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
|
||||
|
||||
#define _FP_MUL_MEAT_DW_S(R,X,Y) \
|
||||
_FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
|
||||
#define _FP_MUL_MEAT_DW_D(R,X,Y) \
|
||||
_FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
|
||||
#define _FP_MUL_MEAT_DW_Q(R,X,Y) \
|
||||
_FP_MUL_MEAT_DW_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
|
||||
|
||||
#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y)
|
||||
#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
|
||||
#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
|
||||
|
||||
#define _FP_NANFRAC_S _FP_QNANBIT_S
|
||||
#define _FP_NANFRAC_D _FP_QNANBIT_D, 0
|
||||
#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0
|
||||
#define _FP_NANSIGN_S 0
|
||||
#define _FP_NANSIGN_D 0
|
||||
#define _FP_NANSIGN_Q 0
|
||||
|
||||
#define _FP_KEEPNANFRACP 1
|
||||
#define _FP_QNANNEGATEDP 0
|
||||
|
||||
#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
|
||||
do { \
|
||||
if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
|
||||
&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
|
||||
{ \
|
||||
R##_s = Y##_s; \
|
||||
_FP_FRAC_COPY_##wc(R,Y); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
R##_s = X##_s; \
|
||||
_FP_FRAC_COPY_##wc(R,X); \
|
||||
} \
|
||||
R##_c = FP_CLS_NAN; \
|
||||
} while (0)
|
||||
|
||||
#define _FP_TININESS_AFTER_ROUNDING 0
|
49
sysdeps/csky/sotruss-lib.c
Normal file
49
sysdeps/csky/sotruss-lib.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* Override generic sotruss-lib.c to define actual functions for 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/>. */
|
||||
|
||||
#define HAVE_ARCH_PLTENTER
|
||||
#define HAVE_ARCH_PLTEXIT
|
||||
|
||||
#include <elf/sotruss-lib.c>
|
||||
|
||||
ElfW(Addr)
|
||||
la_csky_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)),
|
||||
unsigned int ndx __attribute__ ((unused)),
|
||||
uintptr_t *refcook, uintptr_t *defcook,
|
||||
La_csky_regs *regs, unsigned int *flags,
|
||||
const char *symname, long int *framesizep)
|
||||
{
|
||||
print_enter (refcook, defcook, symname,
|
||||
regs->lr_reg[0], regs->lr_reg[1], regs->lr_reg[2],
|
||||
*flags);
|
||||
|
||||
/* No need to copy anything, we will not need the parameters in any case. */
|
||||
*framesizep = 0;
|
||||
|
||||
return sym->st_value;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
la_csky_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
||||
uintptr_t *defcook, const struct La_csky_regs *inregs,
|
||||
struct La_csky_retval *outregs, const char *symname)
|
||||
{
|
||||
print_exit (refcook, defcook, symname, outregs->lrv_v0);
|
||||
|
||||
return 0;
|
||||
}
|
29
sysdeps/csky/stackinfo.h
Normal file
29
sysdeps/csky/stackinfo.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* Stack environment definitions. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _STACKINFO_H
|
||||
#define _STACKINFO_H 1
|
||||
|
||||
#include <elf.h>
|
||||
|
||||
/* On C-SKY the stack grows down. */
|
||||
#define _STACK_GROWS_DOWN 1
|
||||
|
||||
#define DEFAULT_STACK_PERMS (PF_R|PF_W)
|
||||
|
||||
#endif /* stackinfo.h */
|
84
sysdeps/csky/sysdep.h
Normal file
84
sysdeps/csky/sysdep.h
Normal file
@ -0,0 +1,84 @@
|
||||
/* Assembler macros for 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 <sysdeps/generic/sysdep.h>
|
||||
#include <features.h>
|
||||
|
||||
#ifdef __ASSEMBLER__
|
||||
|
||||
# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
|
||||
|
||||
/* Define an entry point visible from C. */
|
||||
# define ENTRY(name) \
|
||||
.globl name; \
|
||||
.type name,@function; \
|
||||
.align 4; \
|
||||
name##:; \
|
||||
cfi_startproc; \
|
||||
CALL_MCOUNT
|
||||
|
||||
# undef END
|
||||
# define END(name) \
|
||||
cfi_endproc; \
|
||||
ASM_SIZE_DIRECTIVE(name)
|
||||
|
||||
/* If compiled for profiling, call `mcount' at the start of each function. */
|
||||
# ifdef PROF
|
||||
# ifdef __PIC__
|
||||
# define CALL_MCOUNT \
|
||||
subi sp, 4; \
|
||||
stw lr, (sp, 0); \
|
||||
grs t0, .Lgetpc; \
|
||||
.Lgetpc: \
|
||||
lrw gb, .Lgetpc@GOTPC; \
|
||||
addu gb, t0; \
|
||||
lrw t1, _mcount@PLT; \
|
||||
ldr.w t0, (gb, t1 << 0); \
|
||||
jmp t0;
|
||||
# else
|
||||
# define CALL_MCOUNT \
|
||||
subi sp, 4; \
|
||||
stw lr, (sp, 0); \
|
||||
jbsr _mcount;
|
||||
# endif
|
||||
# else
|
||||
# define CALL_MCOUNT /* Do nothing. */
|
||||
# endif
|
||||
|
||||
# if defined (__CK860__)
|
||||
/* Instruction fetch will be faster when the label is 16 bytes aligned.
|
||||
Filling with nop instruction to avoid extra jump. */
|
||||
# define LABLE_ALIGN \
|
||||
.balignw 16, 0x6c03
|
||||
|
||||
# define PRE_BNEZAD(R)
|
||||
|
||||
# define BNEZAD(R, L) \
|
||||
bnezad R, L
|
||||
# else
|
||||
# define LABLE_ALIGN \
|
||||
.balignw 8, 0x6c03
|
||||
|
||||
# define PRE_BNEZAD(R) \
|
||||
subi R, 1
|
||||
|
||||
# define BNEZAD(R, L) \
|
||||
bnez R, L
|
||||
# endif
|
||||
|
||||
#endif
|
1
sysdeps/csky/tininess.h
Normal file
1
sysdeps/csky/tininess.h
Normal file
@ -0,0 +1 @@
|
||||
#define TININESS_AFTER_ROUNDING 1
|
23
sysdeps/csky/tst-audit.h
Normal file
23
sysdeps/csky/tst-audit.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* Definitions for testing PLT entry/exit auditing. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#define pltenter la_csky_gnu_pltenter
|
||||
#define pltexit la_csky_gnu_pltexit
|
||||
#define La_regs La_csky_regs
|
||||
#define La_retval La_csky_retval
|
||||
#define int_retval lrv_reg[0]
|
3
sysdeps/unix/sysv/linux/csky/Implies
Normal file
3
sysdeps/unix/sysv/linux/csky/Implies
Normal file
@ -0,0 +1,3 @@
|
||||
unix/sysv/linux/generic/wordsize-32
|
||||
unix/sysv/linux/generic
|
||||
csky/nptl
|
8
sysdeps/unix/sysv/linux/csky/Makefile
Normal file
8
sysdeps/unix/sysv/linux/csky/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
ifeq ($(subdir),misc)
|
||||
sysdep_routines += cacheflush
|
||||
sysdep_headers += sys/cachectl.h
|
||||
endif
|
||||
|
||||
ifeq ($(subdir),stdlib)
|
||||
gen-as-const-headers += ucontext_i.sym
|
||||
endif
|
5
sysdeps/unix/sysv/linux/csky/Versions
Normal file
5
sysdeps/unix/sysv/linux/csky/Versions
Normal file
@ -0,0 +1,5 @@
|
||||
libc {
|
||||
GLIBC_2.29 {
|
||||
cacheflush;
|
||||
}
|
||||
}
|
81
sysdeps/unix/sysv/linux/csky/abiv2/____longjmp_chk.S
Normal file
81
sysdeps/unix/sysv/linux/csky/abiv2/____longjmp_chk.S
Normal file
@ -0,0 +1,81 @@
|
||||
/* longjmp with sp check for C-SKY ABIV2.
|
||||
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__
|
||||
# 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 /* __PIC__ */
|
||||
# define CALL_FAIL \
|
||||
lrw a0, longjmp_msg; \
|
||||
jsri HIDDEN_JUMPTARGET (__fortify_fail);
|
||||
#endif /* __PIC__ */
|
||||
|
||||
# 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:
|
||||
|
||||
#include <__longjmp.S>
|
95
sysdeps/unix/sysv/linux/csky/abiv2/clone.S
Normal file
95
sysdeps/unix/sysv/linux/csky/abiv2/clone.S
Normal file
@ -0,0 +1,95 @@
|
||||
/* Wrapper around clone system call. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
/* 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 stack pointers. */
|
||||
bf __error_arg
|
||||
|
||||
subi a1, 8
|
||||
stw a0, (a1, 0) /* Insert the function into the new stack. */
|
||||
stw a3, (a1, 4) /* Insert the args into the new stack. */
|
||||
|
||||
mov t1, r7 /* Save r7. */
|
||||
mov t2, r4 /* Save r4. */
|
||||
|
||||
/* The syscall expects the args to be in different slots. */
|
||||
mov a0, a2
|
||||
ldw a2, (sp, 0)
|
||||
ldw a3, (sp, 8)
|
||||
ldw r4, (sp, 4)
|
||||
lrw r7, __NR_clone
|
||||
trap 0
|
||||
|
||||
mov r7, t1 /* Restore r7. */
|
||||
mov r4, t2 /* Restore r4. */
|
||||
btsti a0, 31 /* Check if return is less than zero. */
|
||||
bt __do_syscall_error
|
||||
cmpnei a0, 0
|
||||
bf __child
|
||||
rts
|
||||
|
||||
__error_arg:
|
||||
lrw a0, -EINVAL
|
||||
|
||||
__do_syscall_error:
|
||||
#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__ */
|
||||
rts
|
||||
PSEUDO_END (__clone)
|
||||
|
||||
__child:
|
||||
ldw a0, (sp, 4) /* Restore args from new sp. */
|
||||
ldw a1, (sp, 0) /* Restore function from new sp. */
|
||||
addi sp, 8
|
||||
jsr a1
|
||||
|
||||
/* exit */
|
||||
lrw r7, __NR_exit
|
||||
trap 0
|
||||
|
||||
libc_hidden_def (__clone)
|
||||
weak_alias (__clone, clone)
|
73
sysdeps/unix/sysv/linux/csky/abiv2/getcontext.S
Normal file
73
sysdeps/unix/sysv/linux/csky/abiv2/getcontext.S
Normal file
@ -0,0 +1,73 @@
|
||||
/* Save current context. C-SKY ABIV2 version.
|
||||
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)
|
96
sysdeps/unix/sysv/linux/csky/abiv2/setcontext.S
Normal file
96
sysdeps/unix/sysv/linux/csky/abiv2/setcontext.S
Normal file
@ -0,0 +1,96 @@
|
||||
/* Set saved user context to current context. C-SKY ABIV2 version.
|
||||
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)
|
78
sysdeps/unix/sysv/linux/csky/abiv2/swapcontext.S
Normal file
78
sysdeps/unix/sysv/linux/csky/abiv2/swapcontext.S
Normal file
@ -0,0 +1,78 @@
|
||||
/* Save and set current context. C-SKY ABIV2 version.
|
||||
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 swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
|
||||
|
||||
ENTRY (swapcontext)
|
||||
/* Save params and lr. */
|
||||
subi sp, 16
|
||||
stw a0, (sp, 0)
|
||||
stw a1, (sp, 4)
|
||||
stw r15, (sp, 8)
|
||||
|
||||
/* Call getcontext. */
|
||||
#ifdef __PIC__
|
||||
grs t1, .Lgetpc1
|
||||
.Lgetpc1:
|
||||
lrw t0, .Lgetpc1@GOTPC
|
||||
addu t1, t1, t0
|
||||
lrw t0, __getcontext@GOT
|
||||
ldr.w t0, (t1, t0 << 0)
|
||||
jsr t0
|
||||
#else /* !__PIC__ */
|
||||
jsri __getcontext
|
||||
#endif
|
||||
|
||||
mov a3, a0 /* Save return value. */
|
||||
|
||||
/* Restore params and lr. */
|
||||
ldw a0, (sp, 0)
|
||||
ldw a1, (sp, 4)
|
||||
ldw r15, (sp, 8)
|
||||
addi sp, 16
|
||||
|
||||
cmpnei a3, 0
|
||||
bt error_exit
|
||||
|
||||
/* Fix up LR and the PC. */
|
||||
stw sp, (a0, MCONTEXT_CSKY_SP)
|
||||
stw r15, (a0, MCONTEXT_CSKY_LR)
|
||||
stw r15, (a0, MCONTEXT_CSKY_PC)
|
||||
|
||||
/* Set setcontext's arg. */
|
||||
mov a0, a1
|
||||
|
||||
#ifdef __PIC__
|
||||
grs t1, .Lgetpc2
|
||||
.Lgetpc2:
|
||||
lrw a3, .Lgetpc2@GOTPC
|
||||
addu t1, t1, a3
|
||||
lrw a3, __setcontext@GOT
|
||||
ldr.w a3, (t1, a3 << 0)
|
||||
#else /* __PIC__ */
|
||||
lrw a3, __setcontext
|
||||
#endif /* __PIC__ */
|
||||
jmp a3
|
||||
|
||||
error_exit:
|
||||
jmp r15
|
||||
END (swapcontext)
|
69
sysdeps/unix/sysv/linux/csky/abiv2/syscall.S
Normal file
69
sysdeps/unix/sysv/linux/csky/abiv2/syscall.S
Normal file
@ -0,0 +1,69 @@
|
||||
/* System call interface. C-SKY ABIV2 version.
|
||||
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
|
||||
|
||||
/* Put system call number in r7, adjust shift for arguments
|
||||
and load extra arguments from stack. */
|
||||
mov r7, a0
|
||||
mov a0, a1
|
||||
mov a1, a2
|
||||
mov a2, a3
|
||||
ldw a3, (sp, 8)
|
||||
ldw r4, (sp, 12)
|
||||
ldw r5, (sp, 16)
|
||||
trap 0
|
||||
|
||||
/* Restore temp registers. */
|
||||
mov r7, t0
|
||||
ldw r4, (sp, 0)
|
||||
ldw r5, (sp, 4)
|
||||
addi sp, 8
|
||||
|
||||
/* Check return value. */
|
||||
lrw t0, 0xfffff000
|
||||
cmphs a0, t0
|
||||
bf 1f
|
||||
#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__ */
|
||||
1:
|
||||
rts
|
||||
PSEUDO_END (syscall)
|
65
sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S
Normal file
65
sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S
Normal file
@ -0,0 +1,65 @@
|
||||
/* syscall error handlers. C-SKY ABIV2 version.
|
||||
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>
|
||||
|
||||
/* The syscall stubs jump here when they detect an error.
|
||||
The code for Linux is almost identical to the canonical Unix
|
||||
code, except that the error number in R0 is negated. */
|
||||
|
||||
#undef CALL_MCOUNT
|
||||
#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */
|
||||
|
||||
.text
|
||||
ENTRY (__syscall_error)
|
||||
movi a1, 0
|
||||
rsub a0, a0, a1
|
||||
|
||||
#if !IS_IN (rtld)
|
||||
mov a1, a0
|
||||
mov a0, tls
|
||||
|
||||
grs t1, .Lgetpc1
|
||||
.Lgetpc1:
|
||||
lrw t0, errno@gottpoff
|
||||
add t1, t1, t0
|
||||
ldw t1, (t1)
|
||||
add t1, a0
|
||||
stw a1, (t1)
|
||||
bmaski a0, 0
|
||||
rts
|
||||
#elif RTLD_PRIVATE_ERRNO /* !IS_IN (rtld) */
|
||||
# ifdef __PIC__
|
||||
grs t1, .Lgetpc2
|
||||
.Lgetpc2:
|
||||
lrw t0, .Lgetpc2@GOTPC
|
||||
addu t1, t1, t0
|
||||
lrw t0, rtld_errno@PLT
|
||||
ldr.w t0, (t1, t0 << 0)
|
||||
# else
|
||||
lrw t0, rtld_errno
|
||||
# endif /* __PIC__ */
|
||||
stw a0, (t0)
|
||||
bmaski a0, 0
|
||||
rts
|
||||
#else
|
||||
# error "Unsupported non-TLS case"
|
||||
#endif /* RTLD_PRIVATE_ERRNO */
|
||||
|
||||
#undef __syscall_error
|
||||
END (__syscall_error)
|
32
sysdeps/unix/sysv/linux/csky/abiv2/ucontext_i.sym
Normal file
32
sysdeps/unix/sysv/linux/csky/abiv2/ucontext_i.sym
Normal file
@ -0,0 +1,32 @@
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
SIG_BLOCK
|
||||
SIG_SETMASK
|
||||
|
||||
-- Offsets of the fields in the ucontext_t structure.
|
||||
#define ucontext(member) offsetof (ucontext_t, member)
|
||||
#define mcontext(member) ucontext (uc_mcontext.member)
|
||||
#define greg(member) mcontext (__gregs.member)
|
||||
#define fpreg(member) mcontext (__fpregs.member)
|
||||
|
||||
UCONTEXT_FLAGS ucontext (__uc_flags)
|
||||
UCONTEXT_LINK ucontext (uc_link)
|
||||
UCONTEXT_STACK ucontext (uc_stack)
|
||||
UCONTEXT_MCONTEXT ucontext (uc_mcontext)
|
||||
UCONTEXT_SIGMASK ucontext (uc_sigmask)
|
||||
|
||||
MCONTEXT_CSKY_PC greg (__pc)
|
||||
MCONTEXT_CSKY_SP greg (__usp)
|
||||
MCONTEXT_CSKY_LR greg (__lr)
|
||||
MCONTEXT_CSKY_A0 greg (__a0)
|
||||
MCONTEXT_CSKY_R8 greg (__regs[2])
|
||||
MCONTEXT_CSKY_R16 greg (__exregs[0])
|
||||
MCONTEXT_CSKY_HI greg (__rhi)
|
||||
MCONTEXT_CSKY_LO greg (__rlo)
|
||||
MCONTEXT_CSKY_R4 greg (__regs[0])
|
||||
MCONTEXT_CSKY_FESR fpreg (__fesr)
|
||||
MCONTEXT_CSKY_FCR fpreg (__fcr)
|
||||
MCONTEXT_CSKY_FR0 fpreg (__vr[0])
|
34
sysdeps/unix/sysv/linux/csky/bits/procfs.h
Normal file
34
sysdeps/unix/sysv/linux/csky/bits/procfs.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* Types for registers for sys/procfs.h. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _SYS_PROCFS_H
|
||||
# error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
|
||||
#endif
|
||||
|
||||
/* Type for a general-purpose register. */
|
||||
typedef unsigned long elf_greg_t;
|
||||
|
||||
/* And the whole bunch of them. We could have used `struct
|
||||
user_regs' directly in the typedef, but tradition says that
|
||||
the register set is an array, which does have some peculiar
|
||||
semantics, so leave it that way. */
|
||||
#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
|
||||
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
|
||||
|
||||
/* Register set for the floating-point registers. */
|
||||
typedef struct user_fpregs elf_fpregset_t;
|
29
sysdeps/unix/sysv/linux/csky/bits/shmlba.h
Normal file
29
sysdeps/unix/sysv/linux/csky/bits/shmlba.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* Define SHMLBA. C-SKY version.
|
||||
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/>. */
|
||||
|
||||
#ifndef _SYS_SHM_H
|
||||
# error "Never use <bits/shmlba.h> directly; include <sys/shm.h> instead."
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Segment low boundary address multiple. */
|
||||
#define SHMLBA (__getpagesize () << 2)
|
||||
extern int __getpagesize (void) __THROW __attribute__ ((__const__));
|
||||
|
||||
__END_DECLS
|
67
sysdeps/unix/sysv/linux/csky/c++-types.data
Normal file
67
sysdeps/unix/sysv/linux/csky/c++-types.data
Normal file
@ -0,0 +1,67 @@
|
||||
blkcnt64_t:x
|
||||
blkcnt_t:l
|
||||
blksize_t:i
|
||||
caddr_t:Pc
|
||||
clockid_t:i
|
||||
clock_t:l
|
||||
daddr_t:i
|
||||
dev_t:y
|
||||
fd_mask:l
|
||||
fsblkcnt64_t:y
|
||||
fsblkcnt_t:m
|
||||
fsfilcnt64_t:y
|
||||
fsfilcnt_t:m
|
||||
fsid_t:8__fsid_t
|
||||
gid_t:j
|
||||
id_t:j
|
||||
ino64_t:y
|
||||
ino_t:m
|
||||
int16_t:s
|
||||
int32_t:i
|
||||
int64_t:x
|
||||
int8_t:a
|
||||
intptr_t:i
|
||||
key_t:i
|
||||
loff_t:x
|
||||
mode_t:j
|
||||
nlink_t:j
|
||||
off64_t:x
|
||||
off_t:l
|
||||
pid_t:i
|
||||
pthread_attr_t:14pthread_attr_t
|
||||
pthread_barrier_t:17pthread_barrier_t
|
||||
pthread_barrierattr_t:21pthread_barrierattr_t
|
||||
pthread_cond_t:14pthread_cond_t
|
||||
pthread_condattr_t:18pthread_condattr_t
|
||||
pthread_key_t:j
|
||||
pthread_mutex_t:15pthread_mutex_t
|
||||
pthread_mutexattr_t:19pthread_mutexattr_t
|
||||
pthread_once_t:i
|
||||
pthread_rwlock_t:16pthread_rwlock_t
|
||||
pthread_rwlockattr_t:20pthread_rwlockattr_t
|
||||
pthread_spinlock_t:i
|
||||
pthread_t:m
|
||||
quad_t:x
|
||||
register_t:i
|
||||
rlim64_t:y
|
||||
rlim_t:m
|
||||
sigset_t:10__sigset_t
|
||||
size_t:j
|
||||
socklen_t:j
|
||||
ssize_t:i
|
||||
suseconds_t:l
|
||||
time_t:l
|
||||
u_char:h
|
||||
uid_t:j
|
||||
uint:j
|
||||
u_int:j
|
||||
u_int16_t:t
|
||||
u_int32_t:j
|
||||
u_int64_t:y
|
||||
u_int8_t:h
|
||||
ulong:m
|
||||
u_long:m
|
||||
u_quad_t:y
|
||||
useconds_t:j
|
||||
ushort:t
|
||||
u_short:t
|
4
sysdeps/unix/sysv/linux/csky/configure
vendored
Normal file
4
sysdeps/unix/sysv/linux/csky/configure
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
|
||||
|
||||
arch_minimum_kernel=4.20.0
|
||||
ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed
|
5
sysdeps/unix/sysv/linux/csky/configure.ac
Normal file
5
sysdeps/unix/sysv/linux/csky/configure.ac
Normal file
@ -0,0 +1,5 @@
|
||||
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
|
||||
# Local configure fragment for sysdeps/unix/sysv/linux/csky
|
||||
|
||||
arch_minimum_kernel=4.20.0
|
||||
ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed
|
21
sysdeps/unix/sysv/linux/csky/ipc_priv.h
Normal file
21
sysdeps/unix/sysv/linux/csky/ipc_priv.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* Old SysV permission definition for Linux. C-SKY version.
|
||||
Copyright (C) 2017-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/ipc.h> /* For __key_t */
|
||||
|
||||
#define __IPC_64 0x0
|
6
sysdeps/unix/sysv/linux/csky/jmp_buf-macros.h
Normal file
6
sysdeps/unix/sysv/linux/csky/jmp_buf-macros.h
Normal file
@ -0,0 +1,6 @@
|
||||
#define JMP_BUF_SIZE 268
|
||||
#define SIGJMP_BUF_SIZE 268
|
||||
#define JMP_BUF_ALIGN 4
|
||||
#define SIGJMP_BUF_ALIGN 4
|
||||
#define MASK_WAS_SAVED_OFFSET 136
|
||||
#define SAVED_MASK_OFFSET 140
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user