Hi,
This fixes ARC port to support configs lacking llock/scond using kernel
assisted cmpxchg.
Thx,
-Vineet
Vineet Gupta (3):
NPTL/ARC: implement __arch_exchange_32_acq using native EX
ARC: introduce explicit support for atomics
NPTL/ARC: provide a kernel assisted atomic cmpxchg
extra/Configs/Config.arc | 8 +++++
libc/sysdeps/linux/arc/bits/atomic.h | 61 ++++++++++++++++++++++++++++++++++--
2 files changed, 67 insertions(+), 2 deletions(-)
--
2.7.4
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via a9a2380cf01cdae519fdaf8ab021d486c8917e43 (commit)
from b8fcdddcbb192fc367ff04bbd753b9deb69b09f3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a9a2380cf01cdae519fdaf8ab021d486c8917e43
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Thu Nov 10 02:26:09 2016 +0100
nptl: add pthread_getname_np/pthread_setname_np from GNU libc
These functions are used by firefox for example.
Tested with running firefox on x86 system.
-----------------------------------------------------------------------
Summary of changes:
libc/sysdeps/linux/common/not-cancel.h | 2 +-
libpthread/nptl/pthread_getname.c | 69 +++++++++++++++++++++++++++++++
libpthread/nptl/pthread_setname.c | 63 ++++++++++++++++++++++++++++
libpthread/nptl/sysdeps/pthread/pthread.h | 10 +++++
4 files changed, 143 insertions(+), 1 deletion(-)
create mode 100644 libpthread/nptl/pthread_getname.c
create mode 100644 libpthread/nptl/pthread_setname.c
diff --git a/libc/sysdeps/linux/common/not-cancel.h b/libc/sysdeps/linux/common/not-cancel.h
index 08c544b..9d15884 100644
--- a/libc/sysdeps/linux/common/not-cancel.h
+++ b/libc/sysdeps/linux/common/not-cancel.h
@@ -70,7 +70,7 @@ extern int __openat64_nocancel (int fd, const char *fname, int oflag,
#define read_not_cancel(fd, buf, n) \
INLINE_SYSCALL (read, 3, (fd), (buf), (n))
-#ifdef __UCLIBC_HAS_LINUXTHREADS__
+#ifdef __UCLIBC_HAS_THREADS__
/* Uncancelable write. */
#define write_not_cancel(fd, buf, n) \
INLINE_SYSCALL (write, 3, (fd), (buf), (n))
diff --git a/libpthread/nptl/pthread_getname.c b/libpthread/nptl/pthread_getname.c
new file mode 100644
index 0000000..862c8c7
--- /dev/null
+++ b/libpthread/nptl/pthread_getname.c
@@ -0,0 +1,69 @@
+/* pthread_getname_np -- Get thread name. Linux version
+ Copyright (C) 2010-2016 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthreadP.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+
+#include <not-cancel.h>
+
+
+int
+pthread_getname_np (pthread_t th, char *buf, size_t len)
+{
+ const struct pthread *pd = (const struct pthread *) th;
+
+ /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
+ macro. So we have to define it here. */
+#define TASK_COMM_LEN 16
+ if (len < TASK_COMM_LEN)
+ return ERANGE;
+
+ if (pd == THREAD_SELF)
+ return prctl (PR_GET_NAME, buf) ? errno : 0;
+
+#define FMT "/proc/self/task/%u/comm"
+ char fname[sizeof (FMT) + 8];
+ sprintf (fname, FMT, (unsigned int) pd->tid);
+
+ int fd = open_not_cancel_2 (fname, O_RDONLY);
+ if (fd == -1)
+ return errno;
+
+ int res = 0;
+ ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, len));
+ if (n < 0)
+ res = errno;
+ else
+ {
+ if (buf[n - 1] == '\n')
+ buf[n - 1] = '\0';
+ else if (n == len)
+ res = ERANGE;
+ else
+ buf[n] = '\0';
+ }
+
+ close_not_cancel_no_status (fd);
+
+ return res;
+}
diff --git a/libpthread/nptl/pthread_setname.c b/libpthread/nptl/pthread_setname.c
new file mode 100644
index 0000000..6c5e1d6
--- /dev/null
+++ b/libpthread/nptl/pthread_setname.c
@@ -0,0 +1,63 @@
+/* pthread_setname_np -- Set thread name. Linux version
+ Copyright (C) 2010-2016 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pthreadP.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+
+#include <not-cancel.h>
+
+
+int
+pthread_setname_np (pthread_t th, const char *name)
+{
+ const struct pthread *pd = (const struct pthread *) th;
+
+ /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
+ macro. So we have to define it here. */
+#define TASK_COMM_LEN 16
+ size_t name_len = strlen (name);
+ if (name_len >= TASK_COMM_LEN)
+ return ERANGE;
+
+ if (pd == THREAD_SELF)
+ return prctl (PR_SET_NAME, name) ? errno : 0;
+
+#define FMT "/proc/self/task/%u/comm"
+ char fname[sizeof (FMT) + 8];
+ sprintf (fname, FMT, (unsigned int) pd->tid);
+
+ int fd = open_not_cancel_2 (fname, O_RDWR);
+ if (fd == -1)
+ return errno;
+
+ int res = 0;
+ ssize_t n = TEMP_FAILURE_RETRY (write_not_cancel (fd, name, name_len));
+ if (n < 0)
+ res = errno;
+ else if (n != name_len)
+ res = EIO;
+
+ close_not_cancel_no_status (fd);
+
+ return res;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread.h b/libpthread/nptl/sysdeps/pthread/pthread.h
index 4103a06..b2897b3 100644
--- a/libpthread/nptl/sysdeps/pthread/pthread.h
+++ b/libpthread/nptl/sysdeps/pthread/pthread.h
@@ -428,6 +428,16 @@ extern int pthread_getschedparam (pthread_t __target_thread,
extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
__THROW;
+#ifdef __USE_GNU
+/* Get thread name visible in the kernel and its interfaces. */
+extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
+ size_t __buflen)
+ __THROW __nonnull ((2));
+
+/* Set thread name visible in the kernel and its interfaces. */
+extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
+ __THROW __nonnull ((2));
+#endif
#if defined __USE_UNIX98 && defined __UCLIBC_SUSV4_LEGACY__
/* Determine level of concurrency. */
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via b8fcdddcbb192fc367ff04bbd753b9deb69b09f3 (commit)
from 191739597c6d380692885cfdd8dd8aa4f31f029d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b8fcdddcbb192fc367ff04bbd753b9deb69b09f3
Author: Waldemar Brodkorb <wbx(a)openadk.org>
Date: Sat May 28 18:12:58 2016 +0200
nios2: sync support with glibc
Only static linking is supported for now.
More debugging and analyzing for ld.so, TLS and NPTL
is required. But at least you can bootup a static
root fileystem in Qemu.
-----------------------------------------------------------------------
Summary of changes:
extra/Configs/Config.in | 1 -
extra/Configs/Config.nios2 | 2 -
include/elf.h | 97 ++++++------
ldso/ldso/nios2/dl-debug.h | 18 +++
ldso/ldso/nios2/dl-inlines.h | 12 ++
ldso/ldso/nios2/dl-startup.h | 34 ++++
ldso/ldso/{xtensa => nios2}/dl-syscalls.h | 0
ldso/ldso/nios2/dl-sysdep.h | 74 +++++++++
ldso/ldso/{or1k => nios2}/elfinterp.c | 74 +++------
ldso/ldso/nios2/resolve.S | 73 +++++++++
libc/sysdeps/linux/nios2/Makefile.arch | 11 +-
libc/sysdeps/linux/nios2/__longjmp.S | 71 ++++-----
.../linux/{xtensa => nios2}/__syscall_error.c | 0
libc/sysdeps/linux/nios2/bits/fcntl.h | 6 +-
libc/sysdeps/linux/nios2/bits/kernel_stat.h | 50 ------
libc/sysdeps/linux/nios2/bits/kernel_types.h | 6 +-
libc/sysdeps/linux/nios2/bits/setjmp.h | 30 +---
libc/sysdeps/linux/nios2/bits/stat.h | 167 --------------------
libc/sysdeps/linux/nios2/bits/syscalls.h | 173 ++++++++++-----------
libc/sysdeps/linux/nios2/bsd-_setjmp.S | 44 ------
libc/sysdeps/linux/nios2/bsd-setjmp.S | 51 ------
libc/sysdeps/linux/nios2/clone.S | 152 ++++++++++--------
libc/sysdeps/linux/nios2/clone.c | 50 ------
libc/sysdeps/linux/nios2/crt1.S | 147 ++++++++++-------
libc/sysdeps/linux/nios2/fpu_control.h | 98 ------------
libc/sysdeps/linux/nios2/jmpbuf-offsets.h | 16 +-
libc/sysdeps/linux/nios2/jmpbuf-unwind.h | 39 ++++-
libc/sysdeps/linux/nios2/setjmp.S | 101 ++++++------
libc/sysdeps/linux/nios2/syscall.c | 47 ------
.../dl-tls.h => libc/sysdeps/linux/nios2/sysdep.h | 26 ++--
libc/sysdeps/linux/nios2/vfork.S | 100 ++++++------
libpthread/nptl/pthread_create.c | 2 +-
.../nptl/sysdeps/{powerpc => nios2}/Makefile.arch | 5 +-
libpthread/nptl/sysdeps/{mips => nios2}/dl-tls.h | 17 +-
libpthread/nptl/sysdeps/{mips => nios2}/libc-tls.c | 12 +-
.../sysdeps/{arm => nios2}/pthread_spin_lock.c | 0
.../{microblaze => nios2}/pthread_spin_trylock.c | 0
.../nptl/sysdeps/{mips => nios2}/pthreaddef.h | 12 +-
.../nptl/sysdeps/{mips => nios2}/tcb-offsets.sym | 5 +-
libpthread/nptl/sysdeps/{mips => nios2}/tls.h | 72 +++++----
.../unix/sysv/linux/{mips => nios2}/Makefile | 4 -
.../sysv/linux/{powerpc => nios2}/Makefile.arch | 8 +-
.../linux/{xtensa => nios2}/bits/pthreadtypes.h | 19 ++-
.../unix/sysv/linux/{sh => nios2}/bits/semaphore.h | 7 +-
.../nptl/sysdeps/unix/sysv/linux/nios2/clone.S | 3 +
.../linux/{microblaze => nios2}/createthread.c | 0
.../sysdeps/unix/sysv/linux/{arm => nios2}/fork.c | 0
.../unix/sysv/linux/{arm => nios2}/lowlevellock.h | 0
.../sysv/linux/{arm => nios2}/pt-gettimeofday.c | 0
.../unix/sysv/linux/{arm => nios2}/pthread_once.c | 0
.../sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 140 +++++++++++++++++
.../sysdeps/unix/sysv/linux/{arm => nios2}/vfork.S | 2 +-
utils/ldd.c | 5 +
53 files changed, 979 insertions(+), 1104 deletions(-)
create mode 100644 ldso/ldso/nios2/dl-debug.h
create mode 100644 ldso/ldso/nios2/dl-inlines.h
create mode 100644 ldso/ldso/nios2/dl-startup.h
copy ldso/ldso/{xtensa => nios2}/dl-syscalls.h (100%)
create mode 100644 ldso/ldso/nios2/dl-sysdep.h
copy ldso/ldso/{or1k => nios2}/elfinterp.c (80%)
create mode 100644 ldso/ldso/nios2/resolve.S
copy libc/sysdeps/linux/{xtensa => nios2}/__syscall_error.c (100%)
delete mode 100644 libc/sysdeps/linux/nios2/bits/kernel_stat.h
delete mode 100644 libc/sysdeps/linux/nios2/bits/stat.h
delete mode 100644 libc/sysdeps/linux/nios2/bsd-_setjmp.S
delete mode 100644 libc/sysdeps/linux/nios2/bsd-setjmp.S
delete mode 100644 libc/sysdeps/linux/nios2/clone.c
delete mode 100644 libc/sysdeps/linux/nios2/fpu_control.h
delete mode 100644 libc/sysdeps/linux/nios2/syscall.c
copy libpthread/nptl/sysdeps/microblaze/dl-tls.h => libc/sysdeps/linux/nios2/sysdep.h (64%)
copy libpthread/nptl/sysdeps/{powerpc => nios2}/Makefile.arch (58%)
copy libpthread/nptl/sysdeps/{mips => nios2}/dl-tls.h (73%)
copy libpthread/nptl/sysdeps/{mips => nios2}/libc-tls.c (79%)
copy libpthread/nptl/sysdeps/{arm => nios2}/pthread_spin_lock.c (100%)
copy libpthread/nptl/sysdeps/{microblaze => nios2}/pthread_spin_trylock.c (100%)
copy libpthread/nptl/sysdeps/{mips => nios2}/pthreaddef.h (84%)
copy libpthread/nptl/sysdeps/{mips => nios2}/tcb-offsets.sym (50%)
copy libpthread/nptl/sysdeps/{mips => nios2}/tls.h (73%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{mips => nios2}/Makefile (81%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{powerpc => nios2}/Makefile.arch (71%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{xtensa => nios2}/bits/pthreadtypes.h (89%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{sh => nios2}/bits/semaphore.h (89%)
create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S
copy libpthread/nptl/sysdeps/unix/sysv/linux/{microblaze => nios2}/createthread.c (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => nios2}/fork.c (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => nios2}/lowlevellock.h (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => nios2}/pt-gettimeofday.c (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => nios2}/pthread_once.c (100%)
create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => nios2}/vfork.S (95%)
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index cb2d4d1..719218f 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -522,7 +522,6 @@ config UCLIBC_HAS_THREADS_NATIVE
!TARGET_ia64 && \
!TARGET_m68k && \
!TARGET_nds32 && \
- !TARGET_nios2 && \
!TARGET_or1k && \
ARCH_USE_MMU
help
diff --git a/extra/Configs/Config.nios2 b/extra/Configs/Config.nios2
index 2310a46..958607c 100644
--- a/extra/Configs/Config.nios2
+++ b/extra/Configs/Config.nios2
@@ -11,6 +11,4 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_MMU
select ARCH_HAS_NO_LDSO
- select HAVE_NO_PIC
diff --git a/include/elf.h b/include/elf.h
index cca3d38..e0937b7 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -3081,53 +3081,56 @@ typedef Elf32_Addr Elf32_Conflict;
/* Andes ELF Version 1.3 and after */
#define E_NDS32_ELF_VER_1_3 0x1
-/* NIOS relocations. */
-#define R_NIOS_NONE 0
-#define R_NIOS_32 1 /* A 32 bit absolute relocation.*/
-#define R_NIOS_LO16_LO5 2 /* A LO-16 5 bit absolute relocation. */
-#define R_NIOS_LO16_HI11 3 /* A LO-16 top 11 bit absolute relocation. */
-#define R_NIOS_HI16_LO5 4 /* A HI-16 5 bit absolute relocation. */
-#define R_NIOS_HI16_HI11 5 /* A HI-16 top 11 bit absolute relocation. */
-#define R_NIOS_PCREL6 6 /* A 6 bit relative relocation. */
-#define R_NIOS_PCREL8 7 /* An 8 bit relative relocation. */
-#define R_NIOS_PCREL11 8 /* An 11 bit relative relocation. */
-#define R_NIOS_16 9 /* A 16 bit absolute relocation. */
-#define R_NIOS_H_LO5 10 /* Low 5-bits of absolute relocation in halfwords. */
-#define R_NIOS_H_HI11 11 /* Top 11 bits of 16-bit absolute relocation in halfwords. */
-#define R_NIOS_H_XLO5 12 /* Low 5 bits of top 16-bits of 32-bit absolute relocation in halfwords. */
-#define R_NIOS_H_XHI11 13 /* Top 11 bits of top 16-bits of 32-bit absolute relocation in halfwords. */
-#define R_NIOS_H_16 14 /* Half-word @h value */
-#define R_NIOS_H_32 15 /* Word @h value */
-#define R_NIOS_GNU_VTINHERIT 200 /* GNU extension to record C++ vtable hierarchy */
-#define R_NIOS_GNU_VTENTRY 201 /* GNU extension to record C++ vtable member usage */
-/* Keep this the last entry. */
-#define R_NIOS_NUM 202
-
-/* NIOS II relocations */
-#define R_NIOS2_NONE 0
-#define R_NIOS2_S16 1
-#define R_NIOS2_U16 2
-#define R_NIOS2_PCREL16 3
-#define R_NIOS2_CALL26 4
-#define R_NIOS2_IMM5 5
-#define R_NIOS2_CACHE_OPX 6
-#define R_NIOS2_IMM6 7
-#define R_NIOS2_IMM8 8
-#define R_NIOS2_HI16 9
-#define R_NIOS2_LO16 10
-#define R_NIOS2_HIADJ16 11
-#define R_NIOS2_BFD_RELOC_32 12
-#define R_NIOS2_BFD_RELOC_16 13
-#define R_NIOS2_BFD_RELOC_8 14
-#define R_NIOS2_GPREL 15
-#define R_NIOS2_GNU_VTINHERIT 16
-#define R_NIOS2_GNU_VTENTRY 17
-#define R_NIOS2_UJMP 18
-#define R_NIOS2_CJMP 19
-#define R_NIOS2_CALLR 20
-#define R_NIOS2_ALIGN 21
-/* Keep this the last entry. */
-#define R_NIOS2_NUM 22
+/* Legal values for d_tag (dynamic entry type). */
+#define DT_NIOS2_GP 0x70000002 /* Address of _gp. */
+
+/* Nios II relocations. */
+#define R_NIOS2_NONE 0 /* No reloc. */
+#define R_NIOS2_S16 1 /* Direct signed 16 bit. */
+#define R_NIOS2_U16 2 /* Direct unsigned 16 bit. */
+#define R_NIOS2_PCREL16 3 /* PC relative 16 bit. */
+#define R_NIOS2_CALL26 4 /* Direct call. */
+#define R_NIOS2_IMM5 5 /* 5 bit constant expression. */
+#define R_NIOS2_CACHE_OPX 6 /* 5 bit expression, shift 22. */
+#define R_NIOS2_IMM6 7 /* 6 bit constant expression. */
+#define R_NIOS2_IMM8 8 /* 8 bit constant expression. */
+#define R_NIOS2_HI16 9 /* High 16 bit. */
+#define R_NIOS2_LO16 10 /* Low 16 bit. */
+#define R_NIOS2_HIADJ16 11 /* High 16 bit, adjusted. */
+#define R_NIOS2_BFD_RELOC_32 12 /* 32 bit symbol value + addend. */
+#define R_NIOS2_BFD_RELOC_16 13 /* 16 bit symbol value + addend. */
+#define R_NIOS2_BFD_RELOC_8 14 /* 8 bit symbol value + addend. */
+#define R_NIOS2_GPREL 15 /* 16 bit GP pointer offset. */
+#define R_NIOS2_GNU_VTINHERIT 16 /* GNU C++ vtable hierarchy. */
+#define R_NIOS2_GNU_VTENTRY 17 /* GNU C++ vtable member usage. */
+#define R_NIOS2_UJMP 18 /* Unconditional branch. */
+#define R_NIOS2_CJMP 19 /* Conditional branch. */
+#define R_NIOS2_CALLR 20 /* Indirect call through register. */
+#define R_NIOS2_ALIGN 21 /* Alignment requirement for linker relaxation. */
+#define R_NIOS2_GOT16 22 /* 16 bit GOT entry. */
+#define R_NIOS2_CALL16 23 /* 16 bit GOT entry for function. */
+#define R_NIOS2_GOTOFF_LO 24 /* %lo of offset to GOT pointer. */
+#define R_NIOS2_GOTOFF_HA 25 /* %hiadj of offset to GOT pointer. */
+#define R_NIOS2_PCREL_LO 26 /* %lo of PC relative offset. */
+#define R_NIOS2_PCREL_HA 27 /* %hiadj of PC relative offset. */
+#define R_NIOS2_TLS_GD16 28 /* 16 bit GOT offset for TLS GD. */
+#define R_NIOS2_TLS_LDM16 29 /* 16 bit GOT offset for TLS LDM. */
+#define R_NIOS2_TLS_LDO16 30 /* 16 bit module relative offset. */
+#define R_NIOS2_TLS_IE16 31 /* 16 bit GOT offset for TLS IE. */
+#define R_NIOS2_TLS_LE16 32 /* 16 bit LE TP-relative offset. */
+#define R_NIOS2_TLS_DTPMOD 33 /* Module number. */
+#define R_NIOS2_TLS_DTPREL 34 /* Module-relative offset. */
+#define R_NIOS2_TLS_TPREL 35 /* TP-relative offset. */
+#define R_NIOS2_COPY 36 /* Copy symbol at runtime. */
+#define R_NIOS2_GLOB_DAT 37 /* Create GOT entry. */
+#define R_NIOS2_JUMP_SLOT 38 /* Create PLT entry. */
+#define R_NIOS2_RELATIVE 39 /* Adjust by program base. */
+#define R_NIOS2_GOTOFF 40 /* 16 bit offset to GOT pointer. */
+#define R_NIOS2_CALL26_NOAT 41 /* Direct call in .noat section. */
+#define R_NIOS2_GOT_LO 42 /* %lo() of GOT entry. */
+#define R_NIOS2_GOT_HA 43 /* %hiadj() of GOT entry. */
+#define R_NIOS2_CALL_LO 44 /* %lo() of function GOT entry. */
+#define R_NIOS2_CALL_HA 45 /* %hiadj() of function GOT entry. */
/* Xtensa-specific declarations */
diff --git a/ldso/ldso/nios2/dl-debug.h b/ldso/ldso/nios2/dl-debug.h
new file mode 100644
index 0000000..1fb596a
--- /dev/null
+++ b/ldso/ldso/nios2/dl-debug.h
@@ -0,0 +1,18 @@
+/* nios2 shared library loader suppport */
+
+static const char * const _dl_reltypes_tab[] =
+ {
+ "R_NIOS2_NONE",
+ "R_NIOS2_BFD_RELOC_32",
+ "R_NIOS2_BFD_RELOC_16",
+ "R_NIOS2_BFD_RELOC_8",
+ "R_NIOS2_GNU_VTINHERIT",
+ "R_NIOS2_GNU_VTENTRY",
+ "R_NIOS2_GOT16",
+ "R_NIOS2_CALL16",
+ "R_NIOS2_JUMP_SLOT",
+ "R_NIOS2_GLOB_DAT",
+ "R_NIOS2_RELATIVE",
+ "R_NIOS2_GOTOFF",
+ "R_NIOS2_COPY",
+ };
diff --git a/ldso/ldso/nios2/dl-inlines.h b/ldso/ldso/nios2/dl-inlines.h
new file mode 100644
index 0000000..7cf7e4a
--- /dev/null
+++ b/ldso/ldso/nios2/dl-inlines.h
@@ -0,0 +1,12 @@
+
+unsigned int
+internal_function
+_dl_nios2_get_gp_value (struct link_map *main_map)
+{
+ ElfW(Dyn) *dyn = main_map->l_ld;
+ for (dyn = main_map->l_ld; dyn->d_tag != DT_NULL; ++dyn)
+ if (dyn->d_tag == DT_NIOS2_GP)
+ return (unsigned int)(dyn->d_un.d_ptr);
+ return 0;
+}
+
diff --git a/ldso/ldso/nios2/dl-startup.h b/ldso/ldso/nios2/dl-startup.h
new file mode 100644
index 0000000..982e555
--- /dev/null
+++ b/ldso/ldso/nios2/dl-startup.h
@@ -0,0 +1,34 @@
+__asm__ ("\
+ .text\n\
+ .globl _start\n\
+ .type _start, %function\n\
+_start:\n\
+ mov r4, sp\n\
+ br _dl_start\n\
+ mov r16, r4\n\
+ jmp r16\n\
+");
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
+
+/* The ld.so library requires relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+static __always_inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
+ unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
+{
+ switch (ELF_R_TYPE(rpnt->r_info)) {
+ case R_NIOS2_RELATIVE:
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+ default:
+ _dl_exit(1);
+ break;
+ }
+}
diff --git a/ldso/ldso/xtensa/dl-syscalls.h b/ldso/ldso/nios2/dl-syscalls.h
similarity index 100%
copy from ldso/ldso/xtensa/dl-syscalls.h
copy to ldso/ldso/nios2/dl-syscalls.h
diff --git a/ldso/ldso/nios2/dl-sysdep.h b/ldso/ldso/nios2/dl-sysdep.h
new file mode 100644
index 0000000..5ae3ce3
--- /dev/null
+++ b/ldso/ldso/nios2/dl-sysdep.h
@@ -0,0 +1,74 @@
+/* Use reloca */
+#define ELF_USES_RELOCA
+
+#include <elf.h>
+
+/* Initialise the GOT */
+#define INIT_GOT(GOT_BASE,MODULE) \
+do { \
+ GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+} while(0)
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+
+#define MAGIC1 EM_ALTERA_NIOS2
+#undef MAGIC2
+/* Used for error messages */
+#define ELF_TARGET "nios2"
+
+struct elf_resolve;
+unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value.
+ ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_NIOS2_JUMP_SLOT \
+ || (type) == R_NIOS2_TLS_DTPMOD \
+ || (type) == R_NIOS2_TLS_DTPREL \
+ || (type) == R_NIOS2_TLS_TPREL) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_NIOS2_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ Elf32_Addr *dynamic;
+ int tmp;
+ __asm__ ("nextpc\t%0\n\t"
+ "1: movhi\t%1, %%hiadj(_GLOBAL_OFFSET_TABLE_ - 1b)\n\t"
+ "addi\t%1, %1, %%lo(_GLOBAL_OFFSET_TABLE_ - 1b)\n\t"
+ "add\t%0, %0, %1\n"
+ : "=r" (dynamic), "=r" (tmp));
+ return *dynamic;
+}
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ Elf32_Addr result;
+ int tmp;
+ __asm__ ("nextpc\t%0\n\t"
+ "1: movhi\t%1, %%hiadj(1b)\n\t"
+ "addi\t%1, %1, %%lo(1b)\n\t"
+ "sub\t%0, %0, %1\n"
+ : "=r" (result), "=r" (tmp));
+ return result;
+}
+
+static __always_inline void
+elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ Elf32_Rel * rpnt = (void *) rel_addr;
+ do {
+ Elf32_Addr *const reloc_addr = (void *) (load_off + (rpnt)->r_offset);
+
+ *reloc_addr += load_off;
+ } while (--relative_count);
+}
+
diff --git a/ldso/ldso/or1k/elfinterp.c b/ldso/ldso/nios2/elfinterp.c
similarity index 80%
copy from ldso/ldso/or1k/elfinterp.c
copy to ldso/ldso/nios2/elfinterp.c
index 928e95b..bdbaa33 100644
--- a/ldso/ldso/or1k/elfinterp.c
+++ b/ldso/ldso/nios2/elfinterp.c
@@ -1,5 +1,4 @@
-/* vi: set sw=4 ts=4: */
-/* OpenRISC 1000 ELF shared library loader suppport
+/* nios2 ELF shared library loader suppport
*
* Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
* David Engel, Hongjiu Lu and Mitch D'Souza
@@ -35,13 +34,6 @@
References to symbols in sharable libraries can be resolved by either
an ELF sharable library or a linux style of shared library. */
-/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
- I ever taken any courses on internals. This program was developed using
- information available through the book "UNIX SYSTEM V RELEASE 4,
- Programmers guide: Ansi C and Programming Support Tools", which did
- a more than adequate job of explaining everything required to get this
- working. */
-
extern int _dl_linux_resolve(void);
unsigned long
@@ -72,20 +64,17 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
/* Get the address of the GOT entry. */
new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
- _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n",
- _dl_progname, symname, tpnt->libname);
+ _dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
}
#if defined (__SUPPORT_LD_DEBUG__)
- if ((unsigned long)got_addr < 0x40000000) {
- if (_dl_debug_bindings) {
- _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
- if (_dl_debug_detail)
- _dl_dprintf(_dl_debug_file,
- "\tpatched: %x ==> %x @ %x\n",
- *got_addr, new_addr, got_addr);
- }
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\tpatched: %x ==> %x @ %x\n",
+ *got_addr, new_addr, got_addr);
}
if (!_dl_debug_nofixups)
#endif
@@ -159,7 +148,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
int symtab_index;
char *symname;
#if defined USE_TLS && USE_TLS
- struct elf_resolve *tls_tpnt;
+ struct elf_resolve *tls_tpnt = NULL;
#endif
struct symbol_ref sym_ref;
ElfW(Addr) *reloc_addr;
@@ -168,10 +157,6 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ElfW(Addr) old_val;
#endif
- struct unaligned {
- Elf32_Addr x;
- } __attribute__ ((packed, may_alias));
-
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
reloc_type = ELF_R_TYPE(rpnt->r_info);
symtab_index = ELF_R_SYM(rpnt->r_info);
@@ -209,41 +194,27 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (reloc_addr) {
- old_val = ((struct unaligned *)reloc_addr)->x;
+ old_val = *reloc_addr;
} else {
old_val = 0;
}
#endif
switch (reloc_type) {
- case R_OR1K_NONE:
+ case R_NIOS2_NONE:
break;
- case R_OR1K_8:
- case R_OR1K_16:
- case R_OR1K_32:
- /* Support relocations on mis-aligned offsets. */
- ((struct unaligned *)reloc_addr)->x = symbol_addr +
- rpnt->r_addend;
- break;
-
- case R_OR1K_8_PCREL:
- case R_OR1K_16_PCREL:
- case R_OR1K_32_PCREL:
- case R_OR1K_INSN_REL_26:
+ case R_NIOS2_BFD_RELOC_32:
+ case R_NIOS2_GLOB_DAT:
+ case R_NIOS2_JUMP_SLOT:
*reloc_addr = symbol_addr + rpnt->r_addend;
break;
- case R_OR1K_GLOB_DAT:
- case R_OR1K_JMP_SLOT:
- *reloc_addr = symbol_addr + rpnt->r_addend;
- break;
-/* Handled by elf_machine_relative */
- case R_OR1K_RELATIVE:
+ case R_NIOS2_RELATIVE:
*reloc_addr = (unsigned long)tpnt->loadaddr + rpnt->r_addend;
break;
- case R_OR1K_COPY:
+ case R_NIOS2_COPY:
if (symbol_addr) {
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_move)
@@ -257,10 +228,6 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
(char *)symbol_addr,
sym_ref.sym->st_size);
}
-#if defined (__SUPPORT_LD_DEBUG__)
- else
- _dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
-#endif
break;
default:
@@ -270,8 +237,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
_dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
- old_val, ((struct unaligned *)reloc_addr)->x,
- reloc_addr);
+ old_val, *reloc_addr, reloc_addr);
#endif
return 0;
@@ -282,14 +248,12 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
- int symtab_index;
ElfW(Addr) *reloc_addr;
#if defined (__SUPPORT_LD_DEBUG__)
ElfW(Addr) old_val;
#endif
(void)scope;
- symtab_index = ELF_R_SYM(rpnt->r_info);
(void)strtab;
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
@@ -300,9 +264,9 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
#endif
switch (reloc_type) {
- case R_OR1K_NONE:
+ case R_NIOS2_NONE:
break;
- case R_OR1K_JMP_SLOT:
+ case R_NIOS2_JUMP_SLOT:
*reloc_addr += (unsigned long)tpnt->loadaddr;
break;
default:
diff --git a/ldso/ldso/nios2/resolve.S b/ldso/ldso/nios2/resolve.S
new file mode 100644
index 0000000..a71839e
--- /dev/null
+++ b/ldso/ldso/nios2/resolve.S
@@ -0,0 +1,73 @@
+/* PLT trampolines. Nios II version.
+ Copyright (C) 2005-2016 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 code is used in dl-runtime.c to call the `fixup' function
+ and then redirect to the address it returns. */
+
+ .text
+ .align 4
+ .globl _dl_linux_resolver
+ .globl _dl_linux_resolve
+ .type _dl_linux_resolve,@function
+
+_dl_linux_resolve:
+/* The runtime resolver receives the original function arguments in r4
+ through r7, the shared library identifier from GOT[1]? in r14, and the
+ relocation index times four in r15. It updates the corresponding PLT GOT
+ entry so that the PLT entry will transfer control directly to the target
+ in the future, and then transfers control to the target. */
+ /* Save arguments and return address. */
+ subi sp, sp, 28
+ stw r22, 24(sp)
+ stw r8, 20(sp) /* save r8, because this might be a call to mcount */
+ stw r7, 16(sp)
+ stw r6, 12(sp)
+ stw r5, 8(sp)
+ stw r4, 4(sp)
+ stw ra, 0(sp)
+
+ /* Get pointer to linker struct. */
+ mov r4, r14
+
+ /* Get the relocation offset. We're given a multiple of 4 and
+ need a multiple of 12, so multiply by 3. */
+ slli r5, r15, 1
+ add r5, r5, r15
+
+ /* Call the fixup routine. */
+ nextpc r22
+1: movhi r2, %hiadj(_gp_got - 1b)
+ addi r2, r2, %lo(_gp_got - 1b)
+ add r22, r22, r2
+ ldw r2, %call(_dl_linux_resolver)(r22)
+ callr r2
+
+ /* Restore the arguments and return address. */
+ ldw ra, 0(sp)
+ ldw r4, 4(sp)
+ ldw r5, 8(sp)
+ ldw r6, 12(sp)
+ ldw r7, 16(sp)
+ ldw r8, 20(sp)
+ ldw r22, 24(sp)
+ addi sp, sp, 28
+
+ /* Jump to the newly found address. */
+ jmp r2
+
+ .size _dl_linux_resolve, . - _dl_linux_resolve
diff --git a/libc/sysdeps/linux/nios2/Makefile.arch b/libc/sysdeps/linux/nios2/Makefile.arch
index e36e06b..887ce5a 100644
--- a/libc/sysdeps/linux/nios2/Makefile.arch
+++ b/libc/sysdeps/linux/nios2/Makefile.arch
@@ -1,12 +1,5 @@
# Makefile for uClibc
-#
-# Copyright (C) 2000-2005 Erik Andersen <andersen(a)uclibc.org>
-#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-CSRC-y := brk.c syscall.c
-
-SSRC-y := \
- __longjmp.S bsd-_setjmp.S bsd-setjmp.S setjmp.S \
- vfork.S clone.S
+CSRC-y := __syscall_error.c
+SSRC-y := __longjmp.S setjmp.S vfork.S clone.S
diff --git a/libc/sysdeps/linux/nios2/__longjmp.S b/libc/sysdeps/linux/nios2/__longjmp.S
index 7df5997..3f112f1 100644
--- a/libc/sysdeps/linux/nios2/__longjmp.S
+++ b/libc/sysdeps/linux/nios2/__longjmp.S
@@ -1,48 +1,39 @@
-/*
- * libc/sysdeps/linux/nios2/__longjmp.S
- *
- * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- *
- */
+/* longjmp for Nios II.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-#include <features.h>
-#include <jmpbuf-offsets.h>
+ 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/>. */
-.globl __longjmp
-.type __longjmp,@function
-.balign 4
+#include <sysdep.h>
+#include <jmpbuf-offsets.h>
-__longjmp:
- /* return value is in r5*/
+ENTRY (__longjmp)
mov r2, r5
-
- /* jmp_buf in r4, restore regs. */
- ldw r16, (JB_REGS+ 0)(r4)
- ldw r17, (JB_REGS+ 4)(r4)
- ldw r18, (JB_REGS+ 8)(r4)
- ldw r19, (JB_REGS+12)(r4)
- ldw r20, (JB_REGS+16)(r4)
- ldw r21, (JB_REGS+20)(r4)
- ldw r22, (JB_REGS+24)(r4)
- ldw r23, (JB_REGS+28)(r4)
-
- ldw ra, JB_PC(r4)
- ldw fp, JB_FP(r4)
- ldw gp, JB_GP(r4)
- ldw sp, JB_SP(r4)
-
-#ifdef __UCLIBC_HAS_FPU__
- RESTORE_FPU r4 JB_FPREGS
-#endif
- /* return to saved RA */
+ ldw r16, (JB_R16*4)(r4)
+ ldw r17, (JB_R17*4)(r4)
+ ldw r18, (JB_R18*4)(r4)
+ ldw r19, (JB_R19*4)(r4)
+ ldw r20, (JB_R20*4)(r4)
+ ldw r21, (JB_R21*4)(r4)
+ ldw r22, (JB_R22*4)(r4)
+ ldw fp, (JB_FP*4)(r4)
+ ldw ra, (JB_RA*4)(r4)
+ ldw sp, (JB_SP*4)(r4)
+
ret
-.size __longjmp,.-__longjmp
+END (__longjmp)
libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/xtensa/__syscall_error.c b/libc/sysdeps/linux/nios2/__syscall_error.c
similarity index 100%
copy from libc/sysdeps/linux/xtensa/__syscall_error.c
copy to libc/sysdeps/linux/nios2/__syscall_error.c
diff --git a/libc/sysdeps/linux/nios2/bits/fcntl.h b/libc/sysdeps/linux/nios2/bits/fcntl.h
index d8386d6..4fe1ee3 100644
--- a/libc/sysdeps/linux/nios2/bits/fcntl.h
+++ b/libc/sysdeps/linux/nios2/bits/fcntl.h
@@ -44,9 +44,9 @@
#define O_ASYNC 020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_DIRECT 0200000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_DIRECT 040000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
# define O_CLOEXEC 02000000 /* set close_on_exec */
# define O_PATH 010000000 /* Resolve pathname but do not open file. */
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_stat.h b/libc/sysdeps/linux/nios2/bits/kernel_stat.h
deleted file mode 100644
index 99a6cba..0000000
--- a/libc/sysdeps/linux/nios2/bits/kernel_stat.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef _BITS_STAT_STRUCT_H
-#define _BITS_STAT_STRUCT_H
-
-/* This file provides whatever this particular arch's kernel thinks
- * struct kernel_stat should look like... It turns out each arch has a
- * different opinion on the subject... */
-
-struct kernel_stat {
- unsigned short st_dev;
- unsigned short __pad1;
- unsigned long st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned short __pad2;
- unsigned long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned long __unused4;
- unsigned long __unused5;
-};
-
-struct kernel_stat64 {
- unsigned short st_dev;
- unsigned char __pad0[10];
-#define _HAVE_STAT64___ST_INO
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned short st_rdev;
- unsigned char __pad3[10];
- long long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
- struct timespec st_atim;
- struct timespec st_mtim;
- struct timespec st_ctim;
- unsigned long long st_ino;
-};
-
-#endif /* _BITS_STAT_STRUCT_H */
-
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_types.h b/libc/sysdeps/linux/nios2/bits/kernel_types.h
index 004f9c7..5c122b5 100644
--- a/libc/sysdeps/linux/nios2/bits/kernel_types.h
+++ b/libc/sysdeps/linux/nios2/bits/kernel_types.h
@@ -10,10 +10,10 @@
typedef unsigned long __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
typedef unsigned short __kernel_mode_t;
-typedef unsigned short __kernel_nlink_t;
+typedef unsigned long __kernel_nlink_t;
typedef long __kernel_off_t;
typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
+typedef int __kernel_ipc_pid_t;
typedef unsigned int __kernel_uid_t;
typedef unsigned int __kernel_gid_t;
typedef unsigned int __kernel_size_t;
@@ -22,6 +22,8 @@ typedef int __kernel_ptrdiff_t;
typedef long __kernel_time_t;
typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
typedef int __kernel_daddr_t;
typedef char * __kernel_caddr_t;
typedef unsigned short __kernel_uid16_t;
diff --git a/libc/sysdeps/linux/nios2/bits/setjmp.h b/libc/sysdeps/linux/nios2/bits/setjmp.h
index bc6f308..2fbb395 100644
--- a/libc/sysdeps/linux/nios2/bits/setjmp.h
+++ b/libc/sysdeps/linux/nios2/bits/setjmp.h
@@ -1,5 +1,5 @@
-/* Define the machine-dependent type `jmp_buf'. Nios2 version.
- Copyright (C) 1992,93,95,97,2000 Free Software Foundation, Inc.
+/* Define the machine-dependent type `jmp_buf'. Nios II version.
+ Copyright (C) 1992-2016 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
@@ -13,7 +13,7 @@
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
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
@@ -23,27 +23,9 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-typedef struct
-{
- /* Callee-saved registers r16 through r23. */
- unsigned long __regs[8];
+/* Saves r16-r22 (callee-saved, including GOT pointer), fp (frame pointer),
+ ra (return address), and sp (stack pointer). */
- /* Program counter. */
- unsigned long __pc;
-
- /* Stack pointer. */
- unsigned long __sp;
-
- /* The frame pointer. */
- unsigned long __fp;
-
- /* The global pointer. */
- unsigned long __gp;
-
- /* floating point regs, if any */
-#ifdef __UCLIBC_HAS_FPU__
- unsigned long __fpregs[64];
-#endif
-} __jmp_buf[1];
+typedef int __jmp_buf[10];
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/nios2/bits/stat.h b/libc/sysdeps/linux/nios2/bits/stat.h
deleted file mode 100644
index 6e3b019..0000000
--- a/libc/sysdeps/linux/nios2/bits/stat.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Copyright (C) 1992,95,96,97,98,99,2000,2001 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_STAT_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
-#endif
-
-/* Versions of the `struct stat' data structure. */
-#define _STAT_VER_LINUX_OLD 1
-#define _STAT_VER_KERNEL 1
-#define _STAT_VER_SVR4 2
-#define _STAT_VER_LINUX 3
-#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
-
-/* Versions of the `xmknod' interface. */
-#define _MKNOD_VER_LINUX 1
-#define _MKNOD_VER_SVR4 2
-#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
-
-
-struct stat
- {
- __dev_t st_dev; /* Device. */
- unsigned short int __pad1;
-#ifndef __USE_FILE_OFFSET64
- __ino_t st_ino; /* File serial number. */
-#else
- __ino_t __st_ino; /* 32bit file serial number. */
-#endif
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group.*/
- __dev_t st_rdev; /* Device number, if device. */
- unsigned short int __pad2;
-#ifndef __USE_FILE_OFFSET64
- __off_t st_size; /* Size of file, in bytes. */
-#else
- __off64_t st_size; /* Size of file, in bytes. */
-#endif
- __blksize_t st_blksize; /* Optimal block size for I/O. */
-
-#ifndef __USE_FILE_OFFSET64
- __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
-#else
- __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#endif
-#ifdef __USE_MISC
- /* Nanosecond resolution timestamps are stored in a format
- equivalent to 'struct timespec'. This is the type used
- whenever possible but the Unix namespace rules do not allow the
- identifier 'timespec' to appear in the <sys/stat.h> header.
- Therefore we have to handle the use of this header in strictly
- standard-compliant sources special. */
- struct timespec st_atim; /* Time of last access. */
- struct timespec st_mtim; /* Time of last modification. */
- struct timespec st_ctim; /* Time of last status change. */
-# define st_atime st_atim.tv_sec /* Backward compatibility. */
-# define st_mtime st_mtim.tv_sec
-# define st_ctime st_ctim.tv_sec
-#else
- __time_t st_atime; /* Time of last access. */
- unsigned long int st_atimensec; /* Nscecs of last access. */
- __time_t st_mtime; /* Time of last modification. */
- unsigned long int st_mtimensec; /* Nsecs of last modification. */
- __time_t st_ctime; /* Time of last status change. */
- unsigned long int st_ctimensec; /* Nsecs of last status change. */
-#endif
-#ifndef __USE_FILE_OFFSET64
- unsigned long int __unused4;
- unsigned long int __unused5;
-#else
- __ino64_t st_ino; /* File serial number. */
-#endif
- };
-
-#ifdef __USE_LARGEFILE64
-struct stat64
- {
- __dev_t st_dev; /* Device. */
- unsigned int __pad1;
-
- __ino_t __st_ino; /* 32bit file serial number. */
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group.*/
- __dev_t st_rdev; /* Device number, if device. */
- unsigned int __pad2;
- __off64_t st_size; /* Size of file, in bytes. */
- __blksize_t st_blksize; /* Optimal block size for I/O. */
-
- __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#ifdef __USE_MISC
- /* Nanosecond resolution timestamps are stored in a format
- equivalent to 'struct timespec'. This is the type used
- whenever possible but the Unix namespace rules do not allow the
- identifier 'timespec' to appear in the <sys/stat.h> header.
- Therefore we have to handle the use of this header in strictly
- standard-compliant sources special. */
- struct timespec st_atim; /* Time of last access. */
- struct timespec st_mtim; /* Time of last modification. */
- struct timespec st_ctim; /* Time of last status change. */
-#else
- __time_t st_atime; /* Time of last access. */
- unsigned long int st_atimensec; /* Nscecs of last access. */
- __time_t st_mtime; /* Time of last modification. */
- unsigned long int st_mtimensec; /* Nsecs of last modification. */
- __time_t st_ctime; /* Time of last status change. */
- unsigned long int st_ctimensec; /* Nsecs of last status change. */
-#endif
- __ino64_t st_ino; /* File serial number. */
- };
-#endif
-
-/* Tell code we have these members. */
-#define _STATBUF_ST_BLKSIZE
-#define _STATBUF_ST_RDEV
-/* Nanosecond resolution time values are supported. */
-#define _STATBUF_ST_NSEC
-
-/* Encoding of the file mode. */
-
-#define __S_IFMT 0170000 /* These bits determine file type. */
-
-/* File types. */
-#define __S_IFDIR 0040000 /* Directory. */
-#define __S_IFCHR 0020000 /* Character device. */
-#define __S_IFBLK 0060000 /* Block device. */
-#define __S_IFREG 0100000 /* Regular file. */
-#define __S_IFIFO 0010000 /* FIFO. */
-#define __S_IFLNK 0120000 /* Symbolic link. */
-#define __S_IFSOCK 0140000 /* Socket. */
-
-/* POSIX.1b objects. Note that these macros always evaluate to zero. But
- they do it by enforcing the correct use of the macros. */
-#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits. */
-
-#define __S_ISUID 04000 /* Set user ID on execution. */
-#define __S_ISGID 02000 /* Set group ID on execution. */
-#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
-#define __S_IREAD 0400 /* Read by owner. */
-#define __S_IWRITE 0200 /* Write by owner. */
-#define __S_IEXEC 0100 /* Execute by owner. */
-
-#ifdef __USE_ATFILE
-# define UTIME_NOW ((1l << 30) - 1l)
-# define UTIME_OMIT ((1l << 30) - 2l)
-#endif
diff --git a/libc/sysdeps/linux/nios2/bits/syscalls.h b/libc/sysdeps/linux/nios2/bits/syscalls.h
index 5be5d4d..2b12343 100644
--- a/libc/sysdeps/linux/nios2/bits/syscalls.h
+++ b/libc/sysdeps/linux/nios2/bits/syscalls.h
@@ -4,106 +4,97 @@
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-#define TRAP_ID_SYSCALL 0
+#ifdef __ASSEMBLER__
-#ifndef __ASSEMBLER__
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ movi r2, SYS_ify(syscall_name); \
+ trap;
-#include <errno.h>
-
-#define __syscall_return(type, res) \
- do { \
- if (unlikely(INTERNAL_SYSCALL_ERROR_P(res, ))) { \
- __set_errno(INTERNAL_SYSCALL_ERRNO(res, )); \
- res = (unsigned long) -1; \
- } \
- return (type) (res); \
- } while (0)
+#define DOARGS_0 /* nothing */
+#define DOARGS_1 /* nothing */
+#define DOARGS_2 /* nothing */
+#define DOARGS_3 /* nothing */
+#define DOARGS_4 /* nothing */
+#define DOARGS_5 ldw r8, 0(sp);
+#define DOARGS_6 ldw r9, 4(sp); ldw r8, 0(sp);
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
-(__extension__ \
- ({ \
- long __res; \
- __asm__ __volatile__ ( \
- "movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- "movi r3, %1\n\t" /* __NR_##name */ \
- ASM_ARGS_##nr \
- "trap\n\t" \
- "mov %0, r2\n\t" /* syscall return */ \
- : "=r" (__res) /* %0 */ \
- : "i" (name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- MAP_ARGS_##nr (args) /* %3-%8 */ \
- : "r2" \
- , "r3" \
- CLOB_ARGS_##nr /* Clobbered */ \
- ); \
- __res; \
- }) \
-)
+#else
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
- ((unsigned long)(val) >= (unsigned long)(-125))
-
-#define ASM_ARGS_0
-#define MAP_ARGS_0()
-#define CLOB_ARGS_0
-
-#define ASM_ARGS_1 \
- "mov r4, %3\n\t"
-#define MAP_ARGS_1(a) \
- , "r" ((long) a)
-#define CLOB_ARGS_1 \
- , "r4"
+#include <errno.h>
-#define ASM_ARGS_2 \
- ASM_ARGS_1 \
- "mov r5, %4\n\t"
-#define MAP_ARGS_2(a, b) \
- MAP_ARGS_1(a) \
- , "r" ((long) b)
-#define CLOB_ARGS_2 \
- CLOB_ARGS_1 \
- , "r5"
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
-#define ASM_ARGS_3 \
- ASM_ARGS_2 \
- "mov r6, %5\n\t"
-#define MAP_ARGS_3(a, b, c) \
- MAP_ARGS_2(a, b) \
- , "r" ((long) c)
-#define CLOB_ARGS_3 \
- CLOB_ARGS_2 \
- , "r6"
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
-#define ASM_ARGS_4 \
- ASM_ARGS_3 \
- "mov r7, %6\n\t"
-#define MAP_ARGS_4(a, b, c, d) \
- MAP_ARGS_3(a, b, c) \
- , "r" ((long) d)
-#define CLOB_ARGS_4 \
- CLOB_ARGS_3 \
- , "r7"
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
-#define ASM_ARGS_5 \
- ASM_ARGS_4 \
- "mov r8, %7\n\t"
-#define MAP_ARGS_5(a, b, c, d, e) \
- MAP_ARGS_4(a, b, c, d) \
- , "r" ((long) e)
-#define CLOB_ARGS_5 \
- CLOB_ARGS_4 \
- , "r8"
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ unsigned int _sys_result; \
+ { \
+ LOAD_ARGS_##nr (args) \
+ LOAD_REGS_##nr \
+ register int _r2 __asm__ ("r2") = (int)(name); \
+ register int _sys_err __asm__ ("r7"); \
+ __asm__ volatile ("trap" \
+ : "+r" (_r2), "=r" (_sys_err) \
+ : ASM_ARGS_##nr \
+ : "memory"); \
+ _sys_result = _r2; \
+ err = _sys_err; \
+ } \
+ (int) _sys_result; })
-#define ASM_ARGS_6 \
- ASM_ARGS_5 \
- "mov r9, %8\n\t"
-#define MAP_ARGS_6(a, b, c, d, e, f) \
- MAP_ARGS_5(a, b, c, d, e) \
- , "r" ((long) f)
-#define CLOB_ARGS_6 \
- CLOB_ARGS_5 \
- , "r9"
+#define LOAD_ARGS_0()
+#define LOAD_REGS_0
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ LOAD_ARGS_0 () \
+ int __arg1 = (int) (a1);
+#define LOAD_REGS_1 \
+ register int _r4 __asm__ ("r4") = __arg1; \
+ LOAD_REGS_0
+#define ASM_ARGS_1 "r" (_r4)
+#define LOAD_ARGS_2(a1, a2) \
+ LOAD_ARGS_1 (a1) \
+ int __arg2 = (int) (a2);
+#define LOAD_REGS_2 \
+ register int _r5 __asm__ ("r5") = __arg2; \
+ LOAD_REGS_1
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (_r5)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ LOAD_ARGS_2 (a1, a2) \
+ int __arg3 = (int) (a3);
+#define LOAD_REGS_3 \
+ register int _r6 __asm__ ("r6") = __arg3; \
+ LOAD_REGS_2
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (_r6)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ int __arg4 = (int) (a4);
+#define LOAD_REGS_4 \
+ register int _r7 __asm__ ("r7") = __arg4; \
+ LOAD_REGS_3
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (_r7)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ int __arg5 = (int) (a5);
+#define LOAD_REGS_5 \
+ register int _r8 __asm__ ("r8") = __arg5; \
+ LOAD_REGS_4
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (_r8)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ int __arg6 = (int) (a6);
+#define LOAD_REGS_6 \
+ register int _r9 __asm__ ("r9") = __arg6; \
+ LOAD_REGS_5
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (_r9)
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/nios2/bsd-_setjmp.S b/libc/sysdeps/linux/nios2/bsd-_setjmp.S
deleted file mode 100644
index e1350f5..0000000
--- a/libc/sysdeps/linux/nios2/bsd-_setjmp.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * libc/sysdeps/linux/nios2/bsd-_setjmp.S
- *
- * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- *
- */
-
-#include <features.h>
-#include <jmpbuf-offsets.h>
-
- .globl _setjmp
- .type _setjmp,@function
- .balign 4
-
-_setjmp:
- stw r16, (JB_REGS+ 0)(r4)
- stw r17, (JB_REGS+ 4)(r4)
- stw r18, (JB_REGS+ 8)(r4)
- stw r19, (JB_REGS+12)(r4)
- stw r20, (JB_REGS+16)(r4)
- stw r21, (JB_REGS+20)(r4)
- stw r22, (JB_REGS+24)(r4)
- stw r23, (JB_REGS+28)(r4)
-
- stw ra, JB_PC(r4)
- stw sp, JB_SP(r4)
- stw fp, JB_FP(r4)
- stw gp, JB_GP(r4)
-
-#ifdef __UCLIBC_HAS_FPU__
- SAVE_FPU r4 JB_FPREGS
-#endif
- stw r0, JB_SIZE(r4) /* signal mask is not saved */
- mov r2, zero
- ret
-
-
-
diff --git a/libc/sysdeps/linux/nios2/bsd-setjmp.S b/libc/sysdeps/linux/nios2/bsd-setjmp.S
deleted file mode 100644
index f533754..0000000
--- a/libc/sysdeps/linux/nios2/bsd-setjmp.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * libc/sysdeps/linux/nios2/bsd-setjmp.S
- *
- * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- *
- */
-
-
-#include <features.h>
-#include <jmpbuf-offsets.h>
-
- .globl setjmp
- .type setjmp,@function
- .balign 4
-
-setjmp:
- stw r16, (JB_REGS+ 0)(r4)
- stw r17, (JB_REGS+ 4)(r4)
- stw r18, (JB_REGS+ 8)(r4)
- stw r19, (JB_REGS+12)(r4)
- stw r20, (JB_REGS+16)(r4)
- stw r21, (JB_REGS+20)(r4)
- stw r22, (JB_REGS+24)(r4)
- stw r23, (JB_REGS+28)(r4)
-
- stw ra, JB_PC(r4)
- stw sp, JB_SP(r4)
- stw fp, JB_FP(r4)
- stw gp, JB_GP(r4)
-
-#ifdef __UCLIBC_HAS_FPU__
- SAVE_FPU r4 JB_FPREGS
-#endif
-
- movui r5, 1
-#ifdef __PIC__
- /* just pray 16 bit offset is enough */
- br __sigjmp_save
-#else
- movhi r8, %hi(__sigjmp_save)
- ori r8, r8, %lo(__sigjmp_save)
- jmp r8
-#endif
-
-
diff --git a/libc/sysdeps/linux/nios2/clone.S b/libc/sysdeps/linux/nios2/clone.S
index 4afcb7d..0626d8a 100644
--- a/libc/sysdeps/linux/nios2/clone.S
+++ b/libc/sysdeps/linux/nios2/clone.S
@@ -1,70 +1,94 @@
-/*
- * libc/sysdeps/linux/nios2/clone.S -- `clone' syscall for linux/nios2
- *
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- */
-
-#define _ERRNO_H
+/* clone() implementation for Nios II.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andrew Jenner <andrew(a)codesourcery.com>, 2008.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
#include <bits/errno.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_clone
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
-
-.text
-.global clone
-.type clone,%function
-.align 4
-clone:
- addi sp,sp,-8
- mov r8,r4
- stw ra,4(sp)
- stw r16,0(sp)
-
- mov r4,r6
- movi r2,-EINVAL
-
- /* sanity check */
- beq r8,zero,CLONE_ERROR_LABEL
- beq r5,zero,CLONE_ERROR_LABEL
-
- /* system call */
- movi r2,TRAP_ID_SYSCALL
- movi r3,__NR_clone
- trap
-
- /* child call the function */
- mov r4,r7
- bne r2,zero,CLONE_ERROR_LABEL
- callr r8
-
- /* exit if it returns */
- mov r4,r2
- movi r3,__NR_exit
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <tcb-offsets.h>
+#endif
+
+#define CLONE_VM 0x00000100
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ void *parent_tidptr, void *tls, void *child_tidptr) */
+
+ .text
+ENTRY(__clone)
+ /* Sanity check arguments. */
+ movi r2, EINVAL
+
+ subi r5, r5, 8 /* Reserve argument save space. */
+ stw r4, 4(r5) /* Save function pointer. */
+ stw r7, 0(r5) /* Save argument pointer. */
+
+ /* Load arguments. */
+ mov r4, r6
+ ldw r6, 0(sp)
+ ldw r7, 8(sp)
+ ldw r8, 4(sp)
+
+ /* Do the system call. */
+ movi r2, SYS_ify (clone)
+
trap
-
-CLONE_ERROR_LABEL:
- movi r3,-4096
- sub r16,zero,r2
- bgeu r3,r2,CLONE_OK
-
- /* store errno */
- call __errno_location
- stw r16,0(r2)
- movi r2,-1
-
-CLONE_OK:
- ldw ra,4(sp)
- ldw r16,0(sp)
- addi sp,sp,8
+
+ /* See if we're on the newly created thread. */
+ beq r2, zero, thread_start
+ /* Successful return from the parent */
ret
-.size clone,.-clone
+thread_start:
+ /* We expect the argument registers to be preserved across system
+ calls and across task cloning, so flags should be in r4 here. */
+ andi r2, r4, CLONE_VM
+ bne r2, zero, 2f
+ DO_CALL (getpid, 0)
+#ifdef RESET_PID
+ stw r2, PID_OFFSET(r23)
+ stw r2, TID_OFFSET(r23)
+#endif
+2:
+ ldw r5, 4(sp) /* Function pointer. */
+ ldw r4, 0(sp) /* Argument pointer. */
+ addi sp, sp, 8
+
+ /* Call the user's function. */
+ callr r5
+ /* _exit with the result. */
+ mov r4, r2
+#ifdef __PIC__
+ nextpc r22
+1: movhi r8, %hiadj(_gp_got - 1b)
+ addi r8, r8, %lo(_gp_got - 1b)
+ add r22, r22, r8
+ ldw r8, %call(HIDDEN_JUMPTARGET(_exit))(r22)
+ jmp r8
+#else
+ jmpi _exit
#endif
+
+END(__clone)
+libc_hidden_def (__clone)
+weak_alias (__clone, clone)
diff --git a/libc/sysdeps/linux/nios2/clone.c b/libc/sysdeps/linux/nios2/clone.c
deleted file mode 100644
index eec9f42..0000000
--- a/libc/sysdeps/linux/nios2/clone.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * libc/sysdeps/linux/nios2/clone.c -- `clone' syscall for linux/nios2
- * Copyright (C) 2000-2006 Erik Andersen <andersen(a)uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- *
- *
- * Copyright (C) 2004,05 Microtronix Datacom Ltd
- * Copyright (C) 2002,03 NEC Electronics Corporation
- * Copyright (C) 2002,03 Miles Bader <miles(a)gnu.org>
- *
- * Written by Miles Bader <miles(a)gnu.org>
- * Nios2 port by Wentao Xu
- */
-
-#include <errno.h>
-#include <sched.h>
-#include <sys/syscall.h>
-
-int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
-{
- register unsigned long rval __asm__ ("r2") = -EINVAL;
-
- if (fn && child_stack) {
- register unsigned long syscall __asm__ ("r3");
- register unsigned long arg0 __asm__ ("r4");
- register unsigned long arg1 __asm__ ("r5");
-
- /* Clone this thread. */
- rval = TRAP_ID_SYSCALL;
- syscall = __NR_clone;
- arg0 = flags;
- arg1 = (unsigned long)child_stack;
- __asm__ __volatile__ ("trap "
- : "=r" (rval), "=r" (syscall)
- : "0" (rval),"1" (syscall), "r" (arg0), "r" (arg1)
- );
-
- if (rval == 0) {
- /* In child thread, call fn and exit. */
- arg0 = (*fn) (arg);
- syscall = __NR_exit;
- __asm__ __volatile__ ("trap "
- : "=r" (rval), "=r" (syscall)
- : "1" (syscall), "r" (arg0));
- }
- }
-
- __syscall_return (int, rval);
-}
diff --git a/libc/sysdeps/linux/nios2/crt1.S b/libc/sysdeps/linux/nios2/crt1.S
index c178452..e13d595 100644
--- a/libc/sysdeps/linux/nios2/crt1.S
+++ b/libc/sysdeps/linux/nios2/crt1.S
@@ -1,20 +1,40 @@
-/*
- * libc/sysdeps/linux/nios2/crt0.S -- entry point for linux/nios2
- *
- * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- * Updated by Thomas Chou <thomas(a)wytron.com.tw> for crt1.S
- *
- */
+/* Startup code for Nios II
+ Copyright (C) 1995-2016 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/>. */
#include <features.h>
#include <asm/unistd.h>
-#define TRAP_ID_SYSCALL 0
.global _start
.type _start,@function
@@ -27,45 +47,64 @@
.type main,@function
.type __uClibc_main,@function
.text
- .balign 4
+
_start:
- nop
- br 0f
-0:
- /* load gp */
- movhi gp, %hiadj(_gp)
- addi gp, gp, %lo(_gp)
-
- /* load main, argc, argv from stack */
- movhi r4, %hi(main)
- ori r4, r4, %lo(main) /* main */
- ldw r5, 0(sp) /* argc */
- ldw r6, 4(sp) /* argv */
-
- /* load the 4th arg */
- movhi r7, %hi(_init)
- ori r7, r7, %lo(_init)
-
- /* Allocate space on the stack for 6-7th arg, reuse 5th space */
- addi sp,sp,-8
- /* push 5-7th args on stack */
- movhi r8, %hi(_fini)
- ori r8, r8, %lo(_fini)
- stw r8, 0(sp)
-
- stw r2, 4(sp) /* rtld_fini */
- stw sp, 8(sp) /* stack_end */
-
- /* call uClibc_main, shouldn't return */
-#ifdef __PIC__
- /* just pray 16 bit offset is enough */
- br __uClibc_main
-#else
- call __uClibc_main
-#endif
+ /* Set up the global pointer. */
+ movhi gp, %hiadj(_gp)
+ addi gp, gp, %lo(_gp)
+
+ /* Save the stack pointer. */
+ mov r2, sp
+
+ /* Create room on the stack for the fini, rtld_fini and stack_end args
+ to __uClibc_main. */
+ subi sp, sp, 12
+
+ /* Push stack_end */
+ stw r2, 8(sp)
+
+ /* Push rtld_fini */
+ stw r4, 4(sp)
+
+ /* Set up the GOT pointer. */
+ nextpc r22
+1: movhi r2, %hiadj(_gp_got - 1b)
+ addi r2, r2, %lo(_gp_got - 1b)
+ add r22, r22, r2
+
+ /* r6 == argv */
+ addi r6, sp, 16
+
+ /* r5 == argc */
+ ldw r5, 12(sp)
+
+ /* r4 == main */
+ movhi r4, %call_hiadj(main)
+ addi r4, r4, %call_lo(main)
+ add r4, r4, r22
+ ldw r4, 0(r4)
+
+ /* fp == 0 */
+ mov fp, zero
+
+ /* Let the libc call main and exit with its return code. */
+ movhi r2, %call_hiadj(__uClibc_main)
+ addi r2, r2, %call_lo(__uClibc_main)
+ add r2, r2, r22
+ ldw r2, 0(r2)
+ callr r2
+
+ /* should never get here....*/
+ movhi r2, %call_hiadj(abort)
+ addi r2, r2, %call_lo(abort)
+ add r2, r2, r22
+ ldw r2, 0(r2)
+ callr r2
- /* crash in the event of return */
-__exit:
- movui r2, TRAP_ID_SYSCALL
- movui r3, __NR_exit
- trap
+/* 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
diff --git a/libc/sysdeps/linux/nios2/fpu_control.h b/libc/sysdeps/linux/nios2/fpu_control.h
deleted file mode 100644
index 4ba51b5..0000000
--- a/libc/sysdeps/linux/nios2/fpu_control.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* FPU control word bits. Nios2 version.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 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
-
-/* MIPS FPU floating point control register bits.
- *
- * 31-25 -> floating point conditions code bits 7-1. These bits are only
- * available in MIPS IV.
- * 24 -> flush denormalized results to zero instead of
- * causing unimplemented operation exception. This bit is only
- * available for MIPS III and newer.
- * 23 -> Condition bit
- * 22-18 -> reserved (read as 0, write with 0)
- * 17 -> cause bit for unimplemented operation
- * 16 -> cause bit for invalid exception
- * 15 -> cause bit for division by zero exception
- * 14 -> cause bit for overflow exception
- * 13 -> cause bit for underflow exception
- * 12 -> cause bit for inexact exception
- * 11 -> enable exception for invalid exception
- * 10 -> enable exception for division by zero exception
- * 9 -> enable exception for overflow exception
- * 8 -> enable exception for underflow exception
- * 7 -> enable exception for inexact exception
- * 6 -> flag invalid exception
- * 5 -> flag division by zero exception
- * 4 -> flag overflow exception
- * 3 -> flag underflow exception
- * 2 -> flag inexact exception
- * 1-0 -> rounding control
- *
- *
- * 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)
- */
-
-#include <features.h>
-
-/* masking of interrupts */
-#define _FPU_MASK_V 0x0800 /* Invalid operation */
-#define _FPU_MASK_Z 0x0400 /* Division by zero */
-#define _FPU_MASK_O 0x0200 /* Overflow */
-#define _FPU_MASK_U 0x0100 /* Underflow */
-#define _FPU_MASK_I 0x0080 /* Inexact operation */
-
-/* flush denormalized numbers to zero */
-#define _FPU_FLUSH_TZ 0x1000000
-
-/* rounding control */
-#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
-#define _FPU_RC_ZERO 0x1
-#define _FPU_RC_UP 0x2
-#define _FPU_RC_DOWN 0x3
-
-#define _FPU_RESERVED 0xfe3c0000 /* Reserved bits in cw */
-
-
-/* The fdlibm code requires strict IEEE double precision arithmetic,
- and no interrupts for exceptions, rounding to nearest. */
-
-#define _FPU_DEFAULT 0x00000000
-
-/* IEEE: same as above, but exceptions */
-#define _FPU_IEEE 0x00000F80
-
-/* Type of the control word. */
-typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
-
-/* Macros for accessing the hardware control word. */
-#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
-#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
-
-#if 0
-/* Default control word set at startup. */
-extern fpu_control_t __fpu_control;
-#endif
-
-#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/nios2/jmpbuf-offsets.h b/libc/sysdeps/linux/nios2/jmpbuf-offsets.h
index b7d19ca..20482b3 100644
--- a/libc/sysdeps/linux/nios2/jmpbuf-offsets.h
+++ b/libc/sysdeps/linux/nios2/jmpbuf-offsets.h
@@ -6,12 +6,16 @@
#include <features.h>
-#define JB_REGS 0
-#define JB_PC 32
-#define JB_SP 36
-#define JB_FP 40
-#define JB_GP 44
-#define JB_FPREGS 48
+#define JB_R16 0
+#define JB_R17 1
+#define JB_R18 2
+#define JB_R19 3
+#define JB_R20 4
+#define JB_R21 5
+#define JB_R22 6
+#define JB_FP 7
+#define JB_RA 8
+#define JB_SP 9
#ifdef __UCLIBC_HAS_FPU__
# define JB_SIZE 304
diff --git a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
index c22ab24..fe0028b 100644
--- a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
@@ -1,12 +1,39 @@
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen(a)uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
+/* Examine __jmp_buf for unwinding frames. Nios II version.
+ Copyright (C) 2005-2016 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 <jmpbuf-offsets.h>
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
+
#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)->__sp)
+ ((void *) (address) < (void *) (jmpbuf[JB_SP]))
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+
+#endif
diff --git a/libc/sysdeps/linux/nios2/setjmp.S b/libc/sysdeps/linux/nios2/setjmp.S
index 6071685..8050dba 100644
--- a/libc/sysdeps/linux/nios2/setjmp.S
+++ b/libc/sysdeps/linux/nios2/setjmp.S
@@ -1,49 +1,56 @@
-/*
- * libc/sysdeps/linux/nios2/setjmp.S
- *
- * Copyright (C) 2004,05,06 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- *
- */
-
-#include <features.h>
+/* setjmp for Nios II.
+ Copyright (C) 1991-2016 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 <jmpbuf-offsets.h>
-.globl __sigsetjmp
-.type __sigsetjmp,@function
-.balign 4
-
-__sigsetjmp:
- stw r16, (JB_REGS+ 0)(r4)
- stw r17, (JB_REGS+ 4)(r4)
- stw r18, (JB_REGS+ 8)(r4)
- stw r19, (JB_REGS+12)(r4)
- stw r20, (JB_REGS+16)(r4)
- stw r21, (JB_REGS+20)(r4)
- stw r22, (JB_REGS+24)(r4)
- stw r23, (JB_REGS+28)(r4)
-
- stw ra, JB_PC(r4)
- stw sp, JB_SP(r4)
- stw fp, JB_FP(r4)
- stw gp, JB_GP(r4)
-
-#ifdef __UCLIBC_HAS_FPU__
- SAVE_FPU r4 JB_FPREGS
-#endif
-
-#ifdef __PIC__
- /* just pray 16 bit offset is enough */
- br __sigjmp_save
-#else
- movhi r8, %hi(__sigjmp_save)
- ori r8, r8, %lo(__sigjmp_save)
- jmp r8
-#endif
-
-.size __sigsetjmp,.-__sigsetjmp
+ .text
+ENTRY(setjmp)
+ movi r5, 1
+ br __sigsetjmp
+END(setjmp)
+libc_hidden_def(setjmp)
+
+ENTRY(_setjmp)
+ mov r5, zero
+ br __sigsetjmp
+END(_setjmp)
+libc_hidden_def(_setjmp)
+
+/* Save the current program position in ENV and return 0. */
+ENTRY(__sigsetjmp)
+ stw r16, (JB_R16*4)(r4)
+ stw r17, (JB_R17*4)(r4)
+ stw r18, (JB_R18*4)(r4)
+ stw r19, (JB_R19*4)(r4)
+ stw r20, (JB_R20*4)(r4)
+ stw r21, (JB_R21*4)(r4)
+ stw r22, (JB_R22*4)(r4)
+ stw fp, (JB_FP*4)(r4)
+ stw ra, (JB_RA*4)(r4)
+ stw sp, (JB_SP*4)(r4)
+ /* Save the signal mask if requested. */
+ nextpc r2
+
+1: movhi r3, %hiadj(__sigjmp_save - 1b)
+ addi r3, r3, %lo(__sigjmp_save - 1b)
+ add r2, r2, r3
+ jmp r2
+
+END(__sigsetjmp)
+libc_hidden_def(__sigsetjmp)
diff --git a/libc/sysdeps/linux/nios2/syscall.c b/libc/sysdeps/linux/nios2/syscall.c
deleted file mode 100644
index 60ddd02..0000000
--- a/libc/sysdeps/linux/nios2/syscall.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * libc/sysdeps/linux/nios2/syscall.c -- generic syscall function for linux/nios2
- *
- * Copyright (C) 2004 Microtronix Datacom Ltd.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program 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 Library General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#include <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-
-long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
-{
- register long _r2 __asm__("r2")=(long)TRAP_ID_SYSCALL;
- register long _r3 __asm__("r3")=(long)sysnum;
-
- register long _r4 __asm__("r4")=(long)(a);
- register long _r5 __asm__("r5")=(long)(b);
- register long _r6 __asm__("r6")=(long)(c);
- register long _r7 __asm__("r7")=(long)(d);
- register long _r8 __asm__("r8")=(long)(e);
- register long _r9 __asm__("r9")=(long)(f);
- __asm__ __volatile__(
- "trap "
- : "=r"(_r2), "=r"(_r3)
- : "0"(_r2), "1"(_r3),
- "r"(_r4), "r"(_r5), "r"(_r6), "r"(_r7), "r"(_r8), "r"(_r9)
- : "memory");
-
- __syscall_return (long, _r2);
-}
-
diff --git a/libpthread/nptl/sysdeps/microblaze/dl-tls.h b/libc/sysdeps/linux/nios2/sysdep.h
similarity index 64%
copy from libpthread/nptl/sysdeps/microblaze/dl-tls.h
copy to libc/sysdeps/linux/nios2/sysdep.h
index 5613e21..6813818 100644
--- a/libpthread/nptl/sysdeps/microblaze/dl-tls.h
+++ b/libc/sysdeps/linux/nios2/sysdep.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2005-2016 Free Software Foundation, Inc.
-
+/* Assembler macros for Nios II.
+ Copyright (C) 2015-2016 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
@@ -16,11 +16,19 @@
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;
+#include <common/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ .type C_SYMBOL_NAME(name),%function; \
+ C_LABEL(name)
+
+#undef END
+#define END(name) \
+ ASM_SIZE_DIRECTIVE(name)
-extern void *__tls_get_addr (tls_index *ti);
+#endif /* __ASSEMBLER__ */
diff --git a/libc/sysdeps/linux/nios2/vfork.S b/libc/sysdeps/linux/nios2/vfork.S
index 2aee81e..99e4a73 100644
--- a/libc/sysdeps/linux/nios2/vfork.S
+++ b/libc/sysdeps/linux/nios2/vfork.S
@@ -1,50 +1,54 @@
-/*
- * libc/sysdeps/linux/nios2/vfork.S -- `vfork' syscall for linux/nios2
- *
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao(a)microtronix.com>
- */
-
-#include <sys/syscall.h>
-
-#define __NR_vfork 1071
-
-.text
-.global __vfork
-.hidden __vfork
-.type __vfork,%function
-.align 4
-__vfork:
- movui r2, TRAP_ID_SYSCALL
- movui r3, __NR_vfork
- trap
- movi r8, -4096
- bltu r8, r2, fix_errno
- ret
-fix_errno:
- sub r8, r0, r2
-
- addi sp, sp, -8
- stw ra, 4(sp)
- stw r8, 0(sp)
-#ifndef __PIC__
- call __errno_location
-#else
-
+/* vfork for Nios II Linux.
+ Copyright (C) 2005-2016 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>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <tcb-offsets.h>
+#endif
+
+ENTRY(__vfork)
+
+#ifdef RESET_PID
+ ldw r6, PID_OFFSET(r23)
+ sub r7, zero, r6
+ bne r7, zero, 2f
+ movhi r7, %hi(0x80000000)
+2:
+ stw r7, PID_OFFSET(r23)
#endif
- ldw ra, 4(sp)
- ldw r8, 0(sp)
- stw r8, 0(r2)
-
- addi r2, r0, -1
- addi sp, sp, 8
- ret
-
-.size __vfork,.-__vfork
-weak_alias(__vfork,vfork)
+
+ movi r4, 0x4111 /* (CLONE_VM | CLONE_VFORK | SIGCHLD) */
+ mov r5, zero
+
+ /* Do the system call. */
+ movi r2, SYS_ify(clone)
+
+ trap
+
+ beq r2, zero, 1f
+#ifdef RESET_PID
+ stw r6, PID_OFFSET(r23)
+#endif
+1:
+ ret
+
+END(__vfork)
+
+weak_alias(__vfork, vfork)
libc_hidden_def(vfork)
diff --git a/libpthread/nptl/pthread_create.c b/libpthread/nptl/pthread_create.c
index d42a6e7..49497fe 100644
--- a/libpthread/nptl/pthread_create.c
+++ b/libpthread/nptl/pthread_create.c
@@ -454,7 +454,7 @@ __pthread_create_2_1 (
performed in 'get_cached_stack'. This way we avoid doing this if
the stack freshly allocated with 'mmap'. */
-#ifdef TLS_TCB_AT_TP
+#if TLS_TCB_AT_TP
/* Reference to the TCB itself. */
pd->header.self = pd;
diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/nios2/Makefile.arch
similarity index 58%
copy from libpthread/nptl/sysdeps/powerpc/Makefile.arch
copy to libpthread/nptl/sysdeps/nios2/Makefile.arch
index 18ddc28..fbb560b 100644
--- a/libpthread/nptl/sysdeps/powerpc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/nios2/Makefile.arch
@@ -1,7 +1,4 @@
# Makefile for uClibc NPTL
-#
-# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc(a)uclibc.org>
-#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
+libc_arch_a_CSRC = libc-tls.c
diff --git a/libpthread/nptl/sysdeps/mips/dl-tls.h b/libpthread/nptl/sysdeps/nios2/dl-tls.h
similarity index 73%
copy from libpthread/nptl/sysdeps/mips/dl-tls.h
copy to libpthread/nptl/sysdeps/nios2/dl-tls.h
index e26aa38..cd79461 100644
--- a/libpthread/nptl/sysdeps/mips/dl-tls.h
+++ b/libpthread/nptl/sysdeps/nios2/dl-tls.h
@@ -1,5 +1,5 @@
-/* Thread-local storage handling in the ELF dynamic linker. MIPS version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+/* Thread-local storage handling in the ELF dynamic linker. Nios II version.
+ Copyright (C) 2012-2016 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
@@ -13,7 +13,7 @@
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
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
@@ -32,14 +32,17 @@ typedef struct
#define TLS_DTV_OFFSET 0x8000
/* Compute the value for a GOTTPREL reloc. */
-#define TLS_TPREL_VALUE(sym_map, sym_val) \
- ((sym_map)->l_tls_offset + sym_val - TLS_TP_OFFSET)
+#define TLS_TPREL_VALUE(sym_map, sym) \
+ ((sym_map)->l_tls_offset + (sym)->st_value - TLS_TP_OFFSET)
/* Compute the value for a DTPREL reloc. */
-#define TLS_DTPREL_VALUE(sym_val) \
- (sym_val - TLS_DTV_OFFSET)
+#define TLS_DTPREL_VALUE(sym) \
+ ((sym)->st_value - TLS_DTV_OFFSET)
extern void *__tls_get_addr (tls_index *ti);
# define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET)
# define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET)
+
+/* Value used for dtv entries for which the allocation is delayed. */
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
diff --git a/libpthread/nptl/sysdeps/mips/libc-tls.c b/libpthread/nptl/sysdeps/nios2/libc-tls.c
similarity index 79%
copy from libpthread/nptl/sysdeps/mips/libc-tls.c
copy to libpthread/nptl/sysdeps/nios2/libc-tls.c
index d6ac875..d677979 100644
--- a/libpthread/nptl/sysdeps/mips/libc-tls.c
+++ b/libpthread/nptl/sysdeps/nios2/libc-tls.c
@@ -1,5 +1,5 @@
-/* Thread-local storage handling in the ELF dynamic linker. MIPS version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+/* Thread-local storage handling in the ELF dynamic linker. Nios II version.
+ Copyright (C) 2005-2016 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
@@ -13,15 +13,13 @@
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
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
#include <sysdeps/generic/libc-tls.c>
#include <dl-tls.h>
-#if USE_TLS
-
-/* On MIPS, linker optimizations are not required, so __tls_get_addr
+/* On Nios II, 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. */
@@ -32,5 +30,3 @@ __tls_get_addr (tls_index *ti)
dtv_t *dtv = THREAD_DTV ();
return (char *) dtv[1].pointer.val + GET_ADDR_OFFSET;
}
-
-#endif
diff --git a/libpthread/nptl/sysdeps/arm/pthread_spin_lock.c b/libpthread/nptl/sysdeps/nios2/pthread_spin_lock.c
similarity index 100%
copy from libpthread/nptl/sysdeps/arm/pthread_spin_lock.c
copy to libpthread/nptl/sysdeps/nios2/pthread_spin_lock.c
diff --git a/libpthread/nptl/sysdeps/microblaze/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/nios2/pthread_spin_trylock.c
similarity index 100%
copy from libpthread/nptl/sysdeps/microblaze/pthread_spin_trylock.c
copy to libpthread/nptl/sysdeps/nios2/pthread_spin_trylock.c
diff --git a/libpthread/nptl/sysdeps/mips/pthreaddef.h b/libpthread/nptl/sysdeps/nios2/pthreaddef.h
similarity index 84%
copy from libpthread/nptl/sysdeps/mips/pthreaddef.h
copy to libpthread/nptl/sysdeps/nios2/pthreaddef.h
index 6929882..4268252 100644
--- a/libpthread/nptl/sysdeps/mips/pthreaddef.h
+++ b/libpthread/nptl/sysdeps/nios2/pthreaddef.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+/* pthread machine parameter definitions, Nios II version.
+ Copyright (C) 2002-2016 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
@@ -12,27 +13,24 @@
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
+ 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 16
+#define STACK_ALIGN 4
/* Minimal stack size after allocating thread descriptor and guard size. */
#define MINIMAL_REST_STACK 2048
/* Alignment requirement for TCB. */
-#define TCB_ALIGNMENT 16
-
+#define TCB_ALIGNMENT 4
/* Location of current stack frame. */
#define CURRENT_STACK_FRAME __builtin_frame_address (0)
-
/* XXX Until we have a better place keep the definitions here. */
-
#define __exit_thread_inline(val) \
INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym b/libpthread/nptl/sysdeps/nios2/tcb-offsets.sym
similarity index 50%
copy from libpthread/nptl/sysdeps/mips/tcb-offsets.sym
copy to libpthread/nptl/sysdeps/nios2/tcb-offsets.sym
index e0e71dc..d9ae952 100644
--- a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/nios2/tcb-offsets.sym
@@ -4,8 +4,11 @@
--
-- Abuse tls.h macros to derive offsets relative to the thread register.
-#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+# undef __thread_self
+# define __thread_self ((void *) 0)
+# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
+POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/libpthread/nptl/sysdeps/mips/tls.h b/libpthread/nptl/sysdeps/nios2/tls.h
similarity index 73%
copy from libpthread/nptl/sysdeps/mips/tls.h
copy to libpthread/nptl/sysdeps/nios2/tls.h
index 09baf12..9785670 100644
--- a/libpthread/nptl/sysdeps/mips/tls.h
+++ b/libpthread/nptl/sysdeps/nios2/tls.h
@@ -1,5 +1,5 @@
-/* Definition for thread-local data handling. NPTL/MIPS version.
- Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+/* Definition for thread-local data handling. NPTL/Nios II version.
+ Copyright (C) 2012-2016 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
@@ -13,7 +13,7 @@
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
+ License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _TLS_H
@@ -35,28 +35,14 @@ typedef union dtv
} pointer;
} dtv_t;
-/* Note: rd must be $v1 to be ABI-conformant. */
-# define READ_THREAD_POINTER() \
- ({ void *__result; \
- __asm__ __volatile__ (".set\tpush\n\t.set\tmips32r2\n\t" \
- "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \
- __result; })
-
#else /* __ASSEMBLER__ */
# include <tcb-offsets.h>
-
-# define READ_THREAD_POINTER(rd) \
- .set push; \
- .set mips32r2; \
- rdhwr rd, $29; \
- .set pop
#endif /* __ASSEMBLER__ */
-
/* We require TLS support in the tools. */
-#define HAVE_TLS_SUPPORT 1
-#define HAVE_TLS_MODEL_ATTRIBUTE 1
-#define HAVE___THREAD 1
+#define HAVE_TLS_SUPPORT 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+#define HAVE___THREAD 1
/* Signal that TLS support is available. */
#define USE_TLS 1
@@ -70,14 +56,19 @@ typedef union dtv
# define TLS_DTV_AT_TP 1
/* Get the thread descriptor definition. */
-#include <../../descr.h>
+# include <../../descr.h>
typedef struct
{
dtv_t *dtv;
- void *private;
+ uintptr_t pointer_guard;
+ unsigned spare[6];
} tcbhead_t;
+register struct pthread *__thread_self __asm__("r23");
+
+#define READ_THREAD_POINTER() ((void *) __thread_self)
+
/* This is the size of the initial TCB. Because our TCB is before the thread
pointer, we don't need this. */
# define TLS_INIT_TCB_SIZE 0
@@ -97,10 +88,9 @@ typedef struct
(sizeof (struct pthread) \
+ ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
-/* The thread pointer (in hardware register $29) points to the end of
- the TCB + 0x7000, as for PowerPC. The pthread_descr structure is
- immediately in front of the TCB. */
-# define TLS_TCB_OFFSET 0x7000
+/* The thread pointer (in hardware register r23) points to the end of
+ the TCB + 0x7000, as for PowerPC and MIPS. */
+# define TLS_TCB_OFFSET 0x7000
/* Install the dtv pointer. The pointer passed is to the element with
index -1 which contain the length. */
@@ -115,16 +105,13 @@ typedef struct
# define GET_DTV(tcbp) \
(((tcbhead_t *) (tcbp))[-1].dtv)
-/* 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. */
+/* Code to initially initialize the thread pointer. */
# define TLS_INIT_TP(tcbp, secondcall) \
- ({ INTERNAL_SYSCALL_DECL (err); \
- long result_var attribute_unused; \
- result_var = INTERNAL_SYSCALL (set_thread_area, err, 1, \
- (char *) (tcbp) + TLS_TCB_OFFSET); \
- INTERNAL_SYSCALL_ERROR_P (result_var, err) \
- ? "unknown error" : NULL; })
+ (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), NULL)
+
+/* Value passed to 'clone' for initialization of the thread register. */
+# define TLS_DEFINE_INIT_TP(tp, pd) \
+ void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
@@ -137,7 +124,7 @@ typedef struct
/* Magic for libthread_db to know how to do THREAD_SELF. */
# define DB_THREAD_SELF \
- CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+ REGISTER (32, 32, 23 * 4, -TLS_PRE_TCB_SIZE - TLS_TCB_OFFSET)
/* Access to data in the thread descriptor is easy. */
# define THREAD_GETMEM(descr, member) \
@@ -149,9 +136,20 @@ typedef struct
# define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
-/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
+# define THREAD_GET_POINTER_GUARD() \
+ (((tcbhead_t *) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET))[-1].pointer_guard)
+# define THREAD_SET_POINTER_GUARD(value) \
+ (THREAD_GET_POINTER_GUARD () = (value))
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ (((tcbhead_t *) ((void *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].pointer_guard \
+ = THREAD_GET_POINTER_GUARD())
+
+/* l_tls_offset == 0 is perfectly valid on Nios II, so we have to use some
different value to mean unset l_tls_offset. */
# define NO_TLS_OFFSET -1
+
/* Get and set the global scope generation counter in struct pthread. */
#define THREAD_GSCOPE_FLAG_UNUSED 0
#define THREAD_GSCOPE_FLAG_USED 1
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile
similarity index 81%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile
index 43a6fad..8415283 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile
@@ -1,9 +1,5 @@
# Makefile for uClibc NPTL
-#
-# Copyright (C) 2005 Steven J. Hill <sjhill(a)uclibc.org>
-#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
top_srcdir=../../../../../../../
top_builddir=../../../../../../../
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch
similarity index 71%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch
index 2abb1d2..26f51fb 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch
@@ -1,15 +1,9 @@
# Makefile for uClibc NPTL
-#
-# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc(a)uclibc.org>
-#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
libc_linux_arch_SSRC = clone.S vfork.S
-
-ASFLAGS += -DUSE___THREAD
-
+libc_linux_arch_SSRC-OMIT = waitpid.S
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/bits/pthreadtypes.h
similarity index 89%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/bits/pthreadtypes.h
index 5e44020..76076d0 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/bits/pthreadtypes.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002-2012 Free Software Foundation, Inc.
+/* Machine-specific pthread type layouts. Nios II version.
+ Copyright (C) 2012-2016 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
@@ -24,7 +25,6 @@
#define __SIZEOF_PTHREAD_MUTEX_T 24
#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
#define __SIZEOF_PTHREAD_COND_T 48
-#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
#define __SIZEOF_PTHREAD_CONDATTR_T 4
#define __SIZEOF_PTHREAD_RWLOCK_T 32
#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -32,8 +32,8 @@
#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
-/* Thread identifiers. The structure of the attribute type is not
- exposed on purpose. */
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
typedef unsigned long int pthread_t;
@@ -55,7 +55,7 @@ typedef struct __pthread_internal_slist
/* Data structures for mutex handling. The structure of the attribute
- type is not exposed on purpose. */
+ type is deliberately not exposed. */
typedef union
{
struct __pthread_mutex_s
@@ -83,9 +83,12 @@ typedef union
long int __align;
} pthread_mutexattr_t;
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
+#define __PTHREAD_SPINS 0
+
/* Data structure for conditional variable handling. The structure of
- the attribute type is not exposed on purpose. */
+ the attribute type is deliberately not exposed. */
typedef union
{
struct
@@ -120,7 +123,7 @@ typedef int pthread_once_t;
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
/* Data structure for read-write lock variable handling. The
- structure of the attribute type is not exposed on purpose. */
+ structure of the attribute type is deliberately not exposed. */
typedef union
{
struct
@@ -152,6 +155,8 @@ typedef union
long int __align;
} pthread_rwlock_t;
+#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
+
typedef union
{
char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/bits/semaphore.h
similarity index 89%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/bits/semaphore.h
index 9da293a..d877316 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/bits/semaphore.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Machine-specific POSIX semaphore type layouts. Nios II version.
+ Copyright (C) 2002-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper(a)redhat.com>, 2002.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -20,14 +20,11 @@
# 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];
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S
new file mode 100644
index 0000000..544974f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S
@@ -0,0 +1,3 @@
+#define RESET_PID
+#include <tcb-offsets.h>
+#include "../../../../../../../libc/sysdeps/linux/nios2/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/createthread.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/createthread.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/createthread.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/fork.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/fork.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/fork.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/lowlevellock.h
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.h
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/lowlevellock.h
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/pt-gettimeofday.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/pt-gettimeofday.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/pthread_once.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/pthread_once.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/pthread_once.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
new file mode 100644
index 0000000..25382dd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
@@ -0,0 +1,140 @@
+/* Assembler macros with cancellation support, Nios II version.
+ Copyright (C) 2003-2016 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 <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __ASSEMBLER__
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .type __##syscall_name##_nocancel, @function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ cfi_startproc; \
+ DO_CALL (syscall_name, args); \
+ ret; \
+ cfi_endproc; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name) \
+ SINGLE_THREAD_P(r2); \
+ bne r2, zero, pseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ ret; \
+ pseudo_cancel: \
+ SAVESTK_##args; /* save syscall args and adjust stack */ \
+ SAVEREG(ra, 0); /* save return address */ \
+ SAVEREG(r22, 4); /* save GOT pointer */ \
+ nextpc r22; \
+1: movhi r2, %hiadj(_gp_got - 1b); \
+ addi r2, r2, %lo(_gp_got - 1b); \
+ add r22, r22, r2; \
+ CENABLE; \
+ callr r3; \
+ stw r2, 8(sp); /* save mask */ \
+ LOADARGS_##args; \
+ movi r2, SYS_ify(syscall_name); \
+ trap; \
+ stw r2, 12(sp); /* save syscall result */ \
+ stw r7, 16(sp); /* save syscall error flag */ \
+ ldw r4, 8(sp); /* pass mask as argument 1 */ \
+ CDISABLE; \
+ callr r3; \
+ ldw r7, 16(sp); /* restore syscall error flag */ \
+ ldw r2, 12(sp); /* restore syscall result */ \
+ ldw ra, 0(sp); /* restore return address */ \
+ ldw r22, 4(sp); /* restore GOT pointer */ \
+ RESTORESTK_##args; \
+
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) \
+ END (sym)
+
+#define SAVEREG(REG, LOC) stw REG, LOC(sp); cfi_rel_offset (REG, LOC)
+#define SAVESTK(X) subi sp, sp, X; cfi_adjust_cfa_offset(X)
+#define SAVESTK_0 SAVESTK(20)
+#define SAVEARG_1 SAVEREG(r4, 20)
+#define SAVESTK_1 SAVESTK(24); SAVEARG_1
+#define SAVEARG_2 SAVEREG(r5, 24); SAVEARG_1
+#define SAVESTK_2 SAVESTK(28); SAVEARG_2
+#define SAVEARG_3 SAVEREG(r6, 28); SAVEARG_2
+#define SAVESTK_3 SAVESTK(32); SAVEARG_3
+#define SAVEARG_4 SAVEREG(r7, 32); SAVEARG_3
+#define SAVESTK_4 SAVESTK(36); SAVEARG_4
+#define SAVESTK_5 SAVESTK_4
+#define SAVESTK_6 SAVESTK_5
+
+#define LOADARGS_0
+#define LOADARGS_1 ldw r4, 20(sp)
+#define LOADARGS_2 LOADARGS_1; ldw r5, 24(sp)
+#define LOADARGS_3 LOADARGS_2; ldw r6, 28(sp)
+#define LOADARGS_4 LOADARGS_3; ldw r7, 32(sp)
+#define LOADARGS_5 LOADARGS_4; ldw r8, 36(sp)
+#define LOADARGS_6 LOADARGS_5; ldw r9, 40(sp)
+
+#define RESTORESTK(X) addi sp, sp, X; cfi_adjust_cfa_offset(-X)
+#define RESTORESTK_0 RESTORESTK(20)
+#define RESTORESTK_1 RESTORESTK(24)
+#define RESTORESTK_2 RESTORESTK(28)
+#define RESTORESTK_3 RESTORESTK(32)
+#define RESTORESTK_4 RESTORESTK(36)
+#define RESTORESTK_5 RESTORESTK(36)
+#define RESTORESTK_6 RESTORESTK(36)
+
+# endif
+
+# ifdef IS_IN_libpthread
+# define CENABLE ldw r3, %call(__pthread_enable_asynccancel)(r22)
+# define CDISABLE ldw r3, %call(__pthread_disable_asynccancel)(r22)
+# elif defined IS_IN_librt
+# define CENABLE ldw r3, %call(__librt_enable_asynccancel)(r22)
+# define CDISABLE ldw r3, %call(__librt_disable_asynccancel)(r22)
+# elif !defined NOT_IN_libc
+# define CENABLE ldw r3, %call(__libc_enable_asynccancel)(r22)
+# define CDISABLE ldw r3, %call(__libc_disable_asynccancel)(r22)
+# else
+# error Unsupported library
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) \
+ == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ ldw reg, MULTIPLE_THREADS_OFFSET(r23)
+# endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S
similarity index 95%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
copy to libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S
index b9e8cf8..6ee414c 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S
@@ -35,4 +35,4 @@
cmp r0, #0; /* If we are the parent... */ \
strne r3, [r2, #PID_OFFSET] /* ... restore the saved PID. */
-#include "../../../../../../../libc/sysdeps/linux/arm/vfork.S"
+#include "../../../../../../../libc/sysdeps/linux/nios2/vfork.S"
diff --git a/utils/ldd.c b/utils/ldd.c
index 5b41e2e..e7430fc 100644
--- a/utils/ldd.c
+++ b/utils/ldd.c
@@ -103,6 +103,11 @@
#define ELFCLASSM ELFCLASS32
#endif
+#if defined(__nios2__)
+#define MATCH_MACHINE(x) (x == EM_NIOS32)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#if defined(__powerpc__)
#define MATCH_MACHINE(x) (x == EM_PPC)
#define ELFCLASSM ELFCLASS32
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, master has been updated
via 191739597c6d380692885cfdd8dd8aa4f31f029d (commit)
via 7825930078208462655e107677656c45014e91b4 (commit)
via a7f8986f6e81b912b35b46dcad4b8258f75c8b29 (commit)
from 99ef2719fb3d703fe38c4113cd7f5adec516dd3a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 191739597c6d380692885cfdd8dd8aa4f31f029d
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Mon Oct 31 18:05:44 2016 +0100
microblaze: add NPTL/TLS support from GNU libc
Not perfect, but a starting point.
Some tests of the test suite are failing.
commit 7825930078208462655e107677656c45014e91b4
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Wed Jul 20 23:41:10 2016 +0200
microblaze: use assembly version of clone, fix vfork
Signed-off-by: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
commit a7f8986f6e81b912b35b46dcad4b8258f75c8b29
Author: Waldemar Brodkorb <wbx(a)uclibc-ng.org>
Date: Sun Jul 24 19:15:09 2016 +0200
ldso: remove useless debug output, too much noise
-----------------------------------------------------------------------
Summary of changes:
extra/Configs/Config.in | 1 -
include/elf.h | 55 +++----
ldso/ldso/dl-startup.c | 2 -
ldso/ldso/microblaze/dl-debug.h | 8 ++
ldso/ldso/microblaze/dl-startup.h | 3 -
ldso/ldso/microblaze/dl-sysdep.h | 28 ++--
ldso/ldso/microblaze/elfinterp.c | 22 +--
libc/sysdeps/linux/microblaze/Makefile.arch | 4 +-
.../linux/{xtensa => microblaze}/__syscall_error.c | 0
.../linux/microblaze/bits/uClibc_arch_features.h | 3 +-
libc/sysdeps/linux/microblaze/clone.S | 77 ++++++++++
libc/sysdeps/linux/microblaze/clone.c | 47 ------
libc/sysdeps/linux/microblaze/jmpbuf-offsets.h | 6 -
libc/sysdeps/linux/microblaze/jmpbuf-unwind.h | 25 ++++
libc/sysdeps/linux/microblaze/sysdep.h | 83 ++++++++++-
libc/sysdeps/linux/microblaze/vfork.S | 73 +++++-----
.../nptl/sysdeps/{arc => microblaze}/Makefile.arch | 4 -
.../nptl/sysdeps/{sh => microblaze}/dl-tls.h | 12 +-
.../nptl/sysdeps/{arm => microblaze}/libc-tls.c | 16 +--
.../{arm => microblaze}/pthread_spin_lock.c | 4 -
.../{arm => microblaze}/pthread_spin_trylock.c | 0
.../nptl/sysdeps/{mips => microblaze}/pthreaddef.h | 26 ++--
.../sysdeps/{mips => microblaze}/tcb-offsets.sym | 4 +-
libpthread/nptl/sysdeps/microblaze/tls.h | 159 +++++++++++++++++++++
.../unix/sysv/linux/{metag => microblaze}/Makefile | 0
.../sysv/linux/{arc => microblaze}/Makefile.arch | 6 -
.../{xtensa => microblaze}/bits/pthreadtypes.h | 75 +++++-----
.../linux/{arm => microblaze}/bits/semaphore.h | 8 +-
.../sysdeps/unix/sysv/linux/microblaze/clone.S | 4 +
.../sysv/linux/{arm => microblaze}/createthread.c | 0
.../unix/sysv/linux/{xtensa => microblaze}/fork.c | 0
.../sysv/linux/{arc => microblaze}/lowlevellock.h | 24 ++--
.../linux/{xtensa => microblaze}/pthread_once.c | 0
.../unix/sysv/linux/microblaze/sysdep-cancel.h | 139 ++++++++++++++++++
.../sysdeps/unix/sysv/linux/microblaze/vfork.S | 5 +
35 files changed, 673 insertions(+), 250 deletions(-)
copy libc/sysdeps/linux/{xtensa => microblaze}/__syscall_error.c (100%)
create mode 100644 libc/sysdeps/linux/microblaze/clone.S
delete mode 100644 libc/sysdeps/linux/microblaze/clone.c
delete mode 100644 libc/sysdeps/linux/microblaze/jmpbuf-offsets.h
copy libpthread/nptl/sysdeps/{arc => microblaze}/Makefile.arch (69%)
copy libpthread/nptl/sysdeps/{sh => microblaze}/dl-tls.h (69%)
copy libpthread/nptl/sysdeps/{arm => microblaze}/libc-tls.c (70%)
copy libpthread/nptl/sysdeps/{arm => microblaze}/pthread_spin_lock.c (88%)
copy libpthread/nptl/sysdeps/{arm => microblaze}/pthread_spin_trylock.c (100%)
copy libpthread/nptl/sysdeps/{mips => microblaze}/pthreaddef.h (62%)
copy libpthread/nptl/sysdeps/{mips => microblaze}/tcb-offsets.sym (52%)
create mode 100644 libpthread/nptl/sysdeps/microblaze/tls.h
copy libpthread/nptl/sysdeps/unix/sysv/linux/{metag => microblaze}/Makefile (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arc => microblaze}/Makefile.arch (71%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{xtensa => microblaze}/bits/pthreadtypes.h (77%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => microblaze}/bits/semaphore.h (90%)
create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arm => microblaze}/createthread.c (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{xtensa => microblaze}/fork.c (100%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{arc => microblaze}/lowlevellock.h (93%)
copy libpthread/nptl/sysdeps/unix/sysv/linux/{xtensa => microblaze}/pthread_once.c (100%)
create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
create mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index b259464..cb2d4d1 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -521,7 +521,6 @@ config UCLIBC_HAS_THREADS_NATIVE
!TARGET_hppa && \
!TARGET_ia64 && \
!TARGET_m68k && \
- !TARGET_microblaze && \
!TARGET_nds32 && \
!TARGET_nios2 && \
!TARGET_or1k && \
diff --git a/include/elf.h b/include/elf.h
index 17a6143..cca3d38 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -3234,30 +3234,37 @@ typedef Elf32_Addr Elf32_Conflict;
#define DT_C6000_NUM 4
-/* microblaze specific relocs */
-#define R_MICROBLAZE_NONE 0
-#define R_MICROBLAZE_32 1
-#define R_MICROBLAZE_32_PCREL 2
-#define R_MICROBLAZE_64_PCREL 3
-#define R_MICROBLAZE_32_PCREL_LO 4
-#define R_MICROBLAZE_64 5
-#define R_MICROBLAZE_32_LO 6
-#define R_MICROBLAZE_SRO32 7
-#define R_MICROBLAZE_SRW32 8
-#define R_MICROBLAZE_64_NONE 9
-#define R_MICROBLAZE_32_SYM_OP_SYM 10
-#define R_MICROBLAZE_GNU_VTINHERIT 11
-#define R_MICROBLAZE_GNU_VTENTRY 12
-#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset */
-#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset */
-#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative */
-#define R_MICROBLAZE_REL 16 /* adjust by program base */
-#define R_MICROBLAZE_JUMP_SLOT 17 /* create PLT entry */
-#define R_MICROBLAZE_GLOB_DAT 18 /* create GOT entry */
-#define R_MICROBLAZE_GOTOFF_64 19 /* offset relative to GOT */
-#define R_MICROBLAZE_GOTOFF_32 20 /* offset relative to GOT */
-#define R_MICROBLAZE_COPY 21 /* runtime copy */
-#define R_MICROBLAZE_NUM 22
+/* MicroBlaze relocations */
+#define R_MICROBLAZE_NONE 0 /* No reloc. */
+#define R_MICROBLAZE_32 1 /* Direct 32 bit. */
+#define R_MICROBLAZE_32_PCREL 2 /* PC relative 32 bit. */
+#define R_MICROBLAZE_64_PCREL 3 /* PC relative 64 bit. */
+#define R_MICROBLAZE_32_PCREL_LO 4 /* Low 16 bits of PCREL32. */
+#define R_MICROBLAZE_64 5 /* Direct 64 bit. */
+#define R_MICROBLAZE_32_LO 6 /* Low 16 bit. */
+#define R_MICROBLAZE_SRO32 7 /* Read-only small data area. */
+#define R_MICROBLAZE_SRW32 8 /* Read-write small data area. */
+#define R_MICROBLAZE_64_NONE 9 /* No reloc. */
+#define R_MICROBLAZE_32_SYM_OP_SYM 10 /* Symbol Op Symbol relocation. */
+#define R_MICROBLAZE_GNU_VTINHERIT 11 /* GNU C++ vtable hierarchy. */
+#define R_MICROBLAZE_GNU_VTENTRY 12 /* GNU C++ vtable member usage. */
+#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset. */
+#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset. */
+#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative). */
+#define R_MICROBLAZE_REL 16 /* Adjust by program base. */
+#define R_MICROBLAZE_JUMP_SLOT 17 /* Create PLT entry. */
+#define R_MICROBLAZE_GLOB_DAT 18 /* Create GOT entry. */
+#define R_MICROBLAZE_GOTOFF_64 19 /* 64 bit offset to GOT. */
+#define R_MICROBLAZE_GOTOFF_32 20 /* 32 bit offset to GOT. */
+#define R_MICROBLAZE_COPY 21 /* Runtime copy. */
+#define R_MICROBLAZE_TLS 22 /* TLS Reloc. */
+#define R_MICROBLAZE_TLSGD 23 /* TLS General Dynamic. */
+#define R_MICROBLAZE_TLSLD 24 /* TLS Local Dynamic. */
+#define R_MICROBLAZE_TLSDTPMOD32 25 /* TLS Module ID. */
+#define R_MICROBLAZE_TLSDTPREL32 26 /* TLS Offset Within TLS Block. */
+#define R_MICROBLAZE_TLSDTPREL64 27 /* TLS Offset Within TLS Block. */
+#define R_MICROBLAZE_TLSGOTTPREL32 28 /* TLS Offset From Thread Pointer. */
+#define R_MICROBLAZE_TLSTPREL32 29 /* TLS Offset From Thread Pointer. */
/* Meta relocations */
#define R_METAG_HIADDR16 0
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index 18a39ce..87f564f 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -319,8 +319,6 @@ DL_START(unsigned long args)
SEND_STDERR_DEBUG(strtab + sym->st_name);
SEND_STDERR_DEBUG("\n");
#endif
- } else {
- SEND_STDERR_DEBUG("relocating unknown symbol\n");
}
/* Use this machine-specific macro to perform the actual relocation. */
PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
diff --git a/ldso/ldso/microblaze/dl-debug.h b/ldso/ldso/microblaze/dl-debug.h
index 6fd7bd5..30b27bb 100644
--- a/ldso/ldso/microblaze/dl-debug.h
+++ b/ldso/ldso/microblaze/dl-debug.h
@@ -51,4 +51,12 @@ static const char * const _dl_reltypes_tab[] =
"R_MICROBLAZE_GOTOFF_64",
"R_MICROBLAZE_GOTOFF_32",
"R_MICROBLAZE_COPY",
+ "R_MICROBLAZE_TLS",
+ "R_MICROBLAZE_TLSGD",
+ "R_MICROBLAZE_TLSLD",
+ "R_MICROBLAZE_TLSDTPMOD32",
+ "R_MICROBLAZE_TLSDTPREL32",
+ "R_MICROBLAZE_TLSDTPREL64",
+ "R_MICROBLAZE_TLSGOTTPREL32",
+ "R_MICROBLAZE_TLSTPREL32",
};
diff --git a/ldso/ldso/microblaze/dl-startup.h b/ldso/ldso/microblaze/dl-startup.h
index ba15a87..720c53a 100644
--- a/ldso/ldso/microblaze/dl-startup.h
+++ b/ldso/ldso/microblaze/dl-startup.h
@@ -78,9 +78,6 @@ _dl_start_user:\n\
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
-/* The ld.so library requires relocations */
-#define ARCH_NEEDS_BOOTSTRAP_RELOCS
-
static __always_inline
void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
diff --git a/ldso/ldso/microblaze/dl-sysdep.h b/ldso/ldso/microblaze/dl-sysdep.h
index b293d27..4320027 100644
--- a/ldso/ldso/microblaze/dl-sysdep.h
+++ b/ldso/ldso/microblaze/dl-sysdep.h
@@ -1,5 +1,3 @@
-/* elf reloc code for the microblaze platform, based on glibc 2.3.6, dl-machine.h */
-
/*
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -15,37 +13,41 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-/* Use reloca */
#define ELF_USES_RELOCA
#include <elf.h>
-
/* Initialise the GOT */
-#define INIT_GOT(GOT_BASE,MODULE) \
-do { \
- GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
- GOT_BASE[1] = (unsigned long) MODULE; \
+#define INIT_GOT(GOT_BASE,MODULE) \
+do { \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+ GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
} while(0)
/* Here we define the magic numbers that this dynamic loader should accept */
-
#define MAGIC1 EM_MICROBLAZE
#undef MAGIC2
/* Used for error messages */
#define ELF_TARGET "microblaze"
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
struct elf_resolve;
unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#define elf_machine_type_class(type) \
- (((type) == R_MICROBLAZE_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT \
+ (((type) == R_MICROBLAZE_JUMP_SLOT || \
+ (type) == R_MICROBLAZE_TLSDTPREL32 || \
+ (type) == R_MICROBLAZE_TLSDTPMOD32 || \
+ (type) == R_MICROBLAZE_TLSTPREL32) \
+ * ELF_RTYPE_CLASS_PLT \
| ((type) == R_MICROBLAZE_COPY) * ELF_RTYPE_CLASS_COPY)
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
-static inline Elf32_Addr
+static __always_inline Elf32_Addr __attribute__ ((unused))
elf_machine_dynamic (void)
{
Elf32_Addr got_entry_0;
@@ -56,7 +58,6 @@ elf_machine_dynamic (void)
return got_entry_0;
}
-
/* Return the run-time load address of the shared object. */
static inline Elf32_Addr
elf_machine_load_address (void)
@@ -64,6 +65,7 @@ elf_machine_load_address (void)
/* Compute the difference between the runtime address of _DYNAMIC as seen
by a GOTOFF reference, and the link-time address found in the special
unrelocated first GOT entry. */
+
Elf32_Addr dyn;
__asm__ __volatile__ (
"addik %0,r20,_DYNAMIC@GOTOFF"
@@ -72,8 +74,6 @@ elf_machine_load_address (void)
return dyn - elf_machine_dynamic ();
}
-
-
static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
diff --git a/ldso/ldso/microblaze/elfinterp.c b/ldso/ldso/microblaze/elfinterp.c
index 1f6aeff..33aef2f 100644
--- a/ldso/ldso/microblaze/elfinterp.c
+++ b/ldso/ldso/microblaze/elfinterp.c
@@ -214,16 +214,13 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
case R_MICROBLAZE_NONE:
case R_MICROBLAZE_64_NONE:
break;
-
case R_MICROBLAZE_64:
*reloc_addr = symbol_addr + rpnt->r_addend;
break;
-
case R_MICROBLAZE_32:
case R_MICROBLAZE_32_LO:
*reloc_addr = symbol_addr + rpnt->r_addend;
break;
-
case R_MICROBLAZE_32_PCREL:
case R_MICROBLAZE_32_PCREL_LO:
case R_MICROBLAZE_64_PCREL:
@@ -231,16 +228,25 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
case R_MICROBLAZE_SRW32:
*reloc_addr = symbol_addr + rpnt->r_addend;
break;
-
case R_MICROBLAZE_GLOB_DAT:
case R_MICROBLAZE_JUMP_SLOT:
*reloc_addr = symbol_addr + rpnt->r_addend;
break;
-/* Handled by elf_machine_relative */
case R_MICROBLAZE_REL:
*reloc_addr = (unsigned long)tpnt->loadaddr + rpnt->r_addend;
break;
-
+#if defined USE_TLS && USE_TLS
+ case R_MICROBLAZE_TLSDTPMOD32:
+ *reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+ case R_MICROBLAZE_TLSDTPREL32:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_MICROBLAZE_TLSTPREL32:
+ CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
+ *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend;
+ break;
+#endif
case R_MICROBLAZE_COPY:
if (symbol_addr) {
#if defined (__SUPPORT_LD_DEBUG__)
@@ -250,7 +256,6 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
symname, sym_ref.sym->st_size,
symbol_addr, reloc_addr);
#endif
-
_dl_memcpy((char *)reloc_addr,
(char *)symbol_addr,
sym_ref.sym->st_size);
@@ -260,7 +265,6 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
_dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
#endif
break;
-
default:
return -1; /* Calls _dl_exit(1). */
}
@@ -279,14 +283,12 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
- int symtab_index;
ElfW(Addr) *reloc_addr;
#if defined (__SUPPORT_LD_DEBUG__)
ElfW(Addr) old_val;
#endif
(void)scope;
- symtab_index = ELF_R_SYM(rpnt->r_info);
(void)strtab;
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
diff --git a/libc/sysdeps/linux/microblaze/Makefile.arch b/libc/sysdeps/linux/microblaze/Makefile.arch
index 6f1e9fb..b89f7f9 100644
--- a/libc/sysdeps/linux/microblaze/Makefile.arch
+++ b/libc/sysdeps/linux/microblaze/Makefile.arch
@@ -5,5 +5,5 @@
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-CSRC-y := clone.c
-SSRC-y := setjmp.S __longjmp.S vfork.S
+CSRC-y := __syscall_error.c
+SSRC-y := setjmp.S __longjmp.S vfork.S clone.S
diff --git a/libc/sysdeps/linux/xtensa/__syscall_error.c b/libc/sysdeps/linux/microblaze/__syscall_error.c
similarity index 100%
copy from libc/sysdeps/linux/xtensa/__syscall_error.c
copy to libc/sysdeps/linux/microblaze/__syscall_error.c
diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
index ea767ab..321d699 100644
--- a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
@@ -6,8 +6,7 @@
#define _BITS_UCLIBC_ARCH_FEATURES_H
/* instruction used when calling abort() to kill yourself */
-/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
-#undef __UCLIBC_ABORT_INSTRUCTION__
+#define __UCLIBC_ABORT_INSTRUCTION__ "brki r0, -1"
/* can your target use syscall6() for mmap ? */
#define __UCLIBC_MMAP_HAS_6_ARGS__
diff --git a/libc/sysdeps/linux/microblaze/clone.S b/libc/sysdeps/linux/microblaze/clone.S
new file mode 100644
index 0000000..69c2045
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/clone.S
@@ -0,0 +1,77 @@
+/* Copyright (C) 1996-2016 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>
+
+#if defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_HAS_LINUXTHREADS__
+#include <sysdep-cancel.h>
+#endif
+
+/* int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ pid_t *ptid, struct user_desc *tls, pid_t *ctid);
+
+ INCOMING: r5 (fn), r6 (child_stack), r7 (flags), r8 (arg), r9 (ptid)
+ r10 (tls), 28 (r1) ctid
+
+ OUTGOING:
+
+ linux: arch/microblaze/entry.S: sys_clone expects
+ r5 (flags) r6 (child stack) r7 (stack_size) r8 (ptid)r9 (ctid)
+ r10 (tls)
+*/
+
+ .text
+ENTRY (__clone)
+ addik r3,r0,-EINVAL
+ beqi r5,SYSCALL_ERROR_LABEL ; // Invalid func
+ beqi r6,SYSCALL_ERROR_LABEL ; // Invalid stack
+ addik r6,r6,-8
+ swi r5,r6,0 ; // Push fn onto child's stack
+ swi r8,r6,4 ; // Push arg for child
+ addk r5,r0,r7 ; // flags for clone() syscall
+ addk r7,r0,r0
+ addk r8,r0,r9 ; // parent tid ptr
+ lwi r9,r1,28 ; // child tid ptr
+ addik r12,r0,SYS_ify(clone)
+ brki r14,8
+ addk r0,r0,r0
+ addik r4,r0,-4095
+ cmpu r4,r4,r3
+ bgei r4,SYSCALL_ERROR_LABEL
+ beqi r3,L(thread_start)
+ rtsd r15,8
+ nop
+
+L(thread_start):
+ lwi r12,r1,0 ; // fn
+ lwi r5,r1,4 ; // arg
+ brald r15,r12
+ nop
+ addk r5,r0,r3
+ addik r12,r0,SYS_ify(exit)
+ brki r14,8
+ nop
+PSEUDO_END(__clone)
+
+libc_hidden_def (__clone)
+weak_alias (__clone,clone)
diff --git a/libc/sysdeps/linux/microblaze/clone.c b/libc/sysdeps/linux/microblaze/clone.c
deleted file mode 100644
index d921008..0000000
--- a/libc/sysdeps/linux/microblaze/clone.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2004 Atmel Corporation
- *
- * This file is subject to the terms and conditions of the GNU Lesser General
- * Public License. See the file "COPYING.LIB" in the main directory of this
- * archive for more details.
- */
-#include <sched.h>
-#include <errno.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
-{
- int rval = -EINVAL;
- if (fn && child_stack)
- rval = INTERNAL_SYSCALL(clone, 0, 2, flags, child_stack);
-
- if (rval == 0)
- {
- int exitCode = fn(arg);
- rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode);
- }
-
- return rval;
-}
-
-#ifdef __NR_clone2
-int
-__clone2(int (*fn)(void *arg), void *child_stack, size_t stack_size,
- int flags, void *arg, ...)
-{
- int rval = -EINVAL;
- if (fn && child_stack)
- {
- rval = INTERNAL_SYSCALL(clone2, 0, 3, flags, child_stack, stack_size);
- }
-
- if (rval == 0)
- {
- int exitCode = fn(arg);
- rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode);
- }
-
- return rval;
-}
-#endif
diff --git a/libc/sysdeps/linux/microblaze/jmpbuf-offsets.h b/libc/sysdeps/linux/microblaze/jmpbuf-offsets.h
deleted file mode 100644
index c6cccc7..0000000
--- a/libc/sysdeps/linux/microblaze/jmpbuf-offsets.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen(a)uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-#define JB_SIZE (4 * 18)
diff --git a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
index 2c1c079..155792b 100644
--- a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
+++ b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
@@ -10,3 +10,28 @@
containing a local variable at ADDRESS. */
#define _JMPBUF_UNWINDS(jmpbuf, address) \
((void *) (address) < (void *) (jmpbuf)[0].__sp)
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#undef _JMPBUF_UNWINDS
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[0].__sp)
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+static inline uintptr_t __attribute__ ((unused))
+_jmpbuf_sp (__jmp_buf regs)
+{
+ void *sp = (void *) regs[0].__sp;
+ return (uintptr_t) sp;
+}
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
+
+#endif
diff --git a/libc/sysdeps/linux/microblaze/sysdep.h b/libc/sysdeps/linux/microblaze/sysdep.h
index 1f01a2a..a463d33 100644
--- a/libc/sysdeps/linux/microblaze/sysdep.h
+++ b/libc/sysdeps/linux/microblaze/sysdep.h
@@ -1,9 +1,25 @@
+/* Copyright (C) 2000-2016 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 <common/sysdep.h>
#ifdef __ASSEMBLER__
-/* Syntactic details of assembler. */
-
# define ALIGNARG(log2) log2
# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
@@ -22,4 +38,67 @@
# define L(name) $L##name
# endif
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+# ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 0f
+# else
+# define SYSCALL_ERROR_LABEL __syscall_error
+# endif
+
+# define DO_CALL(syscall_name, args) \
+ addik r12,r0,SYS_ify (syscall_name); \
+ brki r14,8; \
+ addk r0,r0,r0;
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ addik r12,r0,-4095; \
+ cmpu r12,r12,r3; \
+ bgei r12,SYSCALL_ERROR_LABEL;
+
+# undef PSEUDO_END
+# define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER; \
+ END (name)
+
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL_DCL 0
+# if defined _LIBC_REENTRANT
+# define SYSCALL_ERROR_HANDLER \
+SYSCALL_ERROR_LABEL_DCL: \
+ addik r1,r1,-16; \
+ swi r15,r1,0; \
+ swi r20,r1,8; \
+ rsubk r3,r3,r0; \
+ swi r3,r1,12; \
+ mfs r20,rpc; \
+ addik r20,r20,_GLOBAL_OFFSET_TABLE_+8; \
+ brlid r15,__errno_location@PLT; \
+ nop; \
+ lwi r4,r1,12; \
+ swi r4,r3,0; \
+ lwi r20,r1,8; \
+ lwi r15,r1,0; \
+ addik r1,r1,16; \
+ rtsd r15,8; \
+ addik r3,r0,-1;
+# else /* !_LIBC_REENTRANT. */
+# define SYSCALL_ERROR_HANDLER \
+SYSCALL_ERROR_LABEL_DCL: \
+ mfs r12,rpc; \
+ addik r12,r12,_GLOBAL_OFFSET_TABLE_+8; \
+ lwi r12,r12,errno@GOT; \
+ rsubk r3,r3,r0; \
+ swi r3,r12,0; \
+ rtsd r15,8; \
+ addik r3,r0,-1;
+# endif /* _LIBC_REENTRANT. */
+#else
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+#endif /* PIC. */
+
#endif
diff --git a/libc/sysdeps/linux/microblaze/vfork.S b/libc/sysdeps/linux/microblaze/vfork.S
index cd60128..11b9e27 100644
--- a/libc/sysdeps/linux/microblaze/vfork.S
+++ b/libc/sysdeps/linux/microblaze/vfork.S
@@ -1,47 +1,44 @@
-/*
- * libc/sysdeps/linux/microblaze/vfork.S -- `vfork' syscall for linux/microblaze
- *
- * Copyright (C) 2003 John Williams <jwilliams(a)itee.uq.edu.au>
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles(a)gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles(a)gnu.org>
- * Microblaze port by John Williams
- */
-
-#include <sys/syscall.h>
+/* Copyright (C) 2005-2016 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
- .globl __vfork
- .hidden __vfork
- .align 4
-__vfork:
- addi r12, r0, SYS_vfork
- brki r14, 0x08;
- addi r4, r3, 125 /* minimum err value */
- blti r4, 1f /* is r3 < -125? */
- bri 2f /* normal return */
-1: sub r3, r3, r0 /* r3 = -r3 */
-#ifdef __PIC__
- mfs r3,rpc
- addik r3,r3,_GLOBAL_OFFSET_TABLE_+8
- lwi r3,r3,C_SYMBOL_NAME(errno)@GOT
- sw r3, r0, r3
-#else
- swi r3, r0, C_SYMBOL_NAME(errno);
-#endif
- /* state restore etc */
-2: rtsd r15, 8 /* error return */
+ENTRY(__vfork)
+
+ DO_CALL (vfork, 0)
+ addik r12,r0,-4095
+ cmpu r12,r12,r3
+ bgei r12,1f
+ rtsd r15,8
nop
- .size __vfork, .-__vfork
-weak_alias(__vfork,vfork)
+1: rsubk r3,r3,r0
+ rtsd r15,8
+ addik r3,r0,-1 /* delay slot. */
+
+END(__vfork)
+
+weak_alias(__vfork, vfork)
libc_hidden_def(vfork)
diff --git a/libpthread/nptl/sysdeps/arc/Makefile.arch b/libpthread/nptl/sysdeps/microblaze/Makefile.arch
similarity index 69%
copy from libpthread/nptl/sysdeps/arc/Makefile.arch
copy to libpthread/nptl/sysdeps/microblaze/Makefile.arch
index 08ec7e7..b69fb48 100644
--- a/libpthread/nptl/sysdeps/arc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/microblaze/Makefile.arch
@@ -1,8 +1,4 @@
# Makefile for uClibc NPTL
-#
-# Copyright (C) 2005 Steven J. Hill <sjhill(a)uclibc.org>
-#
# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
-#
libc_arch_a_CSRC = libc-tls.c
diff --git a/libpthread/nptl/sysdeps/sh/dl-tls.h b/libpthread/nptl/sysdeps/microblaze/dl-tls.h
similarity index 69%
copy from libpthread/nptl/sysdeps/sh/dl-tls.h
copy to libpthread/nptl/sysdeps/microblaze/dl-tls.h
index f5f90be..5613e21 100644
--- a/libpthread/nptl/sysdeps/sh/dl-tls.h
+++ b/libpthread/nptl/sysdeps/microblaze/dl-tls.h
@@ -1,11 +1,11 @@
-/* Thread-local storage handling in the ELF dynamic linker. SH version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2016 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.
+ 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
@@ -16,7 +16,6 @@
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
{
@@ -24,5 +23,4 @@ typedef struct
unsigned long int ti_offset;
} tls_index;
-
extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/arm/libc-tls.c b/libpthread/nptl/sysdeps/microblaze/libc-tls.c
similarity index 70%
copy from libpthread/nptl/sysdeps/arm/libc-tls.c
copy to libpthread/nptl/sysdeps/microblaze/libc-tls.c
index 6576072..7f440fb 100644
--- a/libpthread/nptl/sysdeps/arm/libc-tls.c
+++ b/libpthread/nptl/sysdeps/microblaze/libc-tls.c
@@ -1,11 +1,11 @@
-/* Thread-local storage handling in the ELF dynamic linker. ARM version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2016 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.
+ 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
@@ -19,13 +19,13 @@
#include <sysdeps/generic/libc-tls.c>
#include <dl-tls.h>
-#if defined(USE_TLS) && USE_TLS
-
-/* On ARM, linker optimizations are not required, so __tls_get_addr
+/* On Microblaze, 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. */
+#if defined(USE_TLS) && USE_TLS
+
void *
__tls_get_addr (tls_index *ti)
{
diff --git a/libpthread/nptl/sysdeps/arm/pthread_spin_lock.c b/libpthread/nptl/sysdeps/microblaze/pthread_spin_lock.c
similarity index 88%
copy from libpthread/nptl/sysdeps/arm/pthread_spin_lock.c
copy to libpthread/nptl/sysdeps/microblaze/pthread_spin_lock.c
index 77f5f50..e393a73 100644
--- a/libpthread/nptl/sysdeps/arm/pthread_spin_lock.c
+++ b/libpthread/nptl/sysdeps/microblaze/pthread_spin_lock.c
@@ -19,10 +19,6 @@
#include <atomic.h>
#include "pthreadP.h"
-/* A machine-specific version can define SPIN_LOCK_READS_BETWEEN_CMPXCHG
- to the number of plain reads that it's optimal to spin on between uses
- of atomic_compare_and_exchange_val_acq. If spinning forever is optimal
- then use -1. If no plain reads here would ever be optimal, use 0. */
#define SPIN_LOCK_READS_BETWEEN_CMPXCHG 1000
int
diff --git a/libpthread/nptl/sysdeps/arm/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/microblaze/pthread_spin_trylock.c
similarity index 100%
copy from libpthread/nptl/sysdeps/arm/pthread_spin_trylock.c
copy to libpthread/nptl/sysdeps/microblaze/pthread_spin_trylock.c
diff --git a/libpthread/nptl/sysdeps/mips/pthreaddef.h b/libpthread/nptl/sysdeps/microblaze/pthreaddef.h
similarity index 62%
copy from libpthread/nptl/sysdeps/mips/pthreaddef.h
copy to libpthread/nptl/sysdeps/microblaze/pthreaddef.h
index 6929882..47e87dd 100644
--- a/libpthread/nptl/sysdeps/mips/pthreaddef.h
+++ b/libpthread/nptl/sysdeps/microblaze/pthreaddef.h
@@ -1,10 +1,11 @@
-/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2016 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.
+ 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
@@ -15,24 +16,25 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <stdlib.h>
+#include <string.h>
+
/* Default stack size. */
-#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
/* Required stack pointer alignment at beginning. */
-#define STACK_ALIGN 16
+#define STACK_ALIGN 16
/* Minimal stack size after allocating thread descriptor and guard size. */
-#define MINIMAL_REST_STACK 2048
+#define MINIMAL_REST_STACK 2048
/* Alignment requirement for TCB. */
-#define TCB_ALIGNMENT 16
-
+#define TCB_ALIGNMENT 16
/* Location of current stack frame. */
-#define CURRENT_STACK_FRAME __builtin_frame_address (0)
-
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
/* XXX Until we have a better place keep the definitions here. */
#define __exit_thread_inline(val) \
- INLINE_SYSCALL (exit, 1, (val))
+INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym b/libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym
similarity index 52%
copy from libpthread/nptl/sysdeps/mips/tcb-offsets.sym
copy to libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym
index e0e71dc..18afbee 100644
--- a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym
@@ -4,8 +4,8 @@
--
-- Abuse tls.h macros to derive offsets relative to the thread register.
-#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+#define thread_offsetof(mem) (long)(offsetof (struct pthread, mem) - sizeof (struct pthread))
-MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/microblaze/tls.h b/libpthread/nptl/sysdeps/microblaze/tls.h
new file mode 100644
index 0000000..b5bcde9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/microblaze/tls.h
@@ -0,0 +1,159 @@
+/* Copyright (C) 2005-2016 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>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT 1
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#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
+
+/* Get the thread descriptor definition. */
+# include <../../descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+#define READ_THREAD_POINTER() \
+ ({ register void *__microblaze_thread_area __asm__ ("r21"); \
+ __microblaze_thread_area; })
+
+/* 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 16
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN 16
+
+/* 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)
+
+/* Code to initially initialize the thread pointer.
+ r21 is reserved for thread pointer. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ __asm__ __volatile__ ("or r21,r0,%0" : : "r" ((void *)tcbp)); NULL; })
+
+# define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) READ_THREAD_POINTER())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ (((struct pthread *) READ_THREAD_POINTER()) - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Read member of the thread descriptor directly. */
+# define THREAD_GETMEM(descr, member) (descr->member)
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ (descr->member[idx])
+
+/* Set member of the thread descriptor directly. */
+# define THREAD_SETMEM(descr, member, value) \
+ (descr->member = (value))
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
+# 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_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. */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch
similarity index 71%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch
index fa5d530..77707a0 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch
@@ -1,14 +1,8 @@
# Makefile for uClibc NPTL
-#
-# Copyright (C) 2006 Steven J. Hill <sjhill(a)uclibc.org>
-#
# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
-#
libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
libc_linux_arch_SSRC = clone.S vfork.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/bits/pthreadtypes.h
similarity index 77%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/bits/pthreadtypes.h
index 5e44020..9e9e307 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/bits/pthreadtypes.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002-2012 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2016 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
@@ -12,48 +13,46 @@
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
+ License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _BITS_PTHREADTYPES_H
-#define _BITS_PTHREADTYPES_H 1
+# define _BITS_PTHREADTYPES_H 1
-#include <endian.h>
+# 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_COND_COMPAT_T 12
-#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
+# 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_COND_COMPAT_T 12
+# 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
/* Thread identifiers. The structure of the attribute type is not
exposed on purpose. */
typedef unsigned long int pthread_t;
-
union pthread_attr_t
{
char __size[__SIZEOF_PTHREAD_ATTR_T];
long int __align;
};
-#ifndef __have_pthread_attr_t
-typedef union pthread_attr_t pthread_attr_t;
-# define __have_pthread_attr_t 1
-#endif
+# ifndef __have_pthread_attr_t
+typedef union pthread_attr_t pthread_attr_t;
+# define __have_pthread_attr_t 1
+# endif
typedef struct __pthread_internal_slist
{
struct __pthread_internal_slist *__next;
} __pthread_slist_t;
-
/* Data structures for mutex handling. The structure of the attribute
type is not exposed on purpose. */
typedef union
@@ -77,13 +76,15 @@ typedef union
long int __align;
} pthread_mutex_t;
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */
+#define __PTHREAD_SPINS 0
+
typedef union
{
char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
- long int __align;
+ int __align;
} pthread_mutexattr_t;
-
/* Data structure for conditional variable handling. The structure of
the attribute type is not exposed on purpose. */
typedef union
@@ -106,19 +107,16 @@ typedef union
typedef union
{
char __size[__SIZEOF_PTHREAD_CONDATTR_T];
- long int __align;
+ int __align;
} pthread_condattr_t;
-
-/* Keys for thread-specific data */
+/* Keys for thread-specific data. */
typedef unsigned int pthread_key_t;
-
-/* Once-only execution */
+/* Once-only execution. */
typedef int pthread_once_t;
-
-#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+# if defined __USE_UNIX98 || defined __USE_XOPEN2K
/* Data structure for read-write lock variable handling. The
structure of the attribute type is not exposed on purpose. */
typedef union
@@ -131,40 +129,40 @@ typedef union
unsigned int __writer_wakeup;
unsigned int __nr_readers_queued;
unsigned int __nr_writers_queued;
-#if __BYTE_ORDER == __BIG_ENDIAN
+# if __BYTE_ORDER == __BIG_ENDIAN
unsigned char __pad1;
unsigned char __pad2;
unsigned char __shared;
/* FLAGS must stay at this position in the structure to maintain
binary compatibility. */
unsigned char __flags;
-#else
+# else
/* FLAGS must stay at this position in the structure to maintain
binary compatibility. */
unsigned char __flags;
unsigned char __shared;
unsigned char __pad1;
unsigned char __pad2;
-#endif
+# endif
int __writer;
} __data;
char __size[__SIZEOF_PTHREAD_RWLOCK_T];
long int __align;
} pthread_rwlock_t;
+#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
+
typedef union
{
char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
long int __align;
} pthread_rwlockattr_t;
-#endif
-
+# endif
-#ifdef __USE_XOPEN2K
+# ifdef __USE_XOPEN2K
/* POSIX spinlock data type. */
typedef volatile int pthread_spinlock_t;
-
/* POSIX barriers data type. The structure of the type is
deliberately not exposed. */
typedef union
@@ -178,7 +176,6 @@ typedef union
char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
int __align;
} pthread_barrierattr_t;
-#endif
-
+# endif
-#endif /* bits/pthreadtypes.h */
+#endif /* bits/pthreadtypes.h. */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/bits/semaphore.h
similarity index 90%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/bits/semaphore.h
index e68fbcc..ea05026 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/bits/semaphore.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2016 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
@@ -19,13 +20,10 @@
# 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)
-
+#define SEM_FAILED ((sem_t *) 0)
typedef union
{
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S
new file mode 100644
index 0000000..faa78d9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S
@@ -0,0 +1,4 @@
+#define RESET_PID
+#include <tls.h>
+#include <tcb-offsets.h>
+#include "../../../../../../../libc/sysdeps/linux/microblaze/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/createthread.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arm/createthread.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/createthread.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/fork.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/fork.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/fork.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/lowlevellock.h
similarity index 93%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/lowlevellock.h
index 44a1ac0..e8dce9d 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/lowlevellock.h
@@ -79,21 +79,21 @@
#define lll_futex_timed_wait(futexp, val, timespec, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
- long int __ret; \
- __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ long int __sysret; \
+ __sysret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
__lll_private_flag (FUTEX_WAIT, private), \
(val), (timespec)); \
- __ret; \
+ __sysret; \
})
#define lll_futex_wake(futexp, nr, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
- long int __ret; \
- __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ long int __sysret; \
+ __sysret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
__lll_private_flag (FUTEX_WAKE, private), \
(nr), 0); \
- __ret; \
+ __sysret; \
})
#define lll_robust_dead(futexv, private) \
@@ -109,11 +109,11 @@
#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
- long int __ret; \
- __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ long int __sysret; \
+ __sysret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
__lll_private_flag (FUTEX_CMP_REQUEUE, private),\
(nr_wake), (nr_move), (mutex), (val)); \
- INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ INTERNAL_SYSCALL_ERROR_P (__sysret, __err); \
})
@@ -121,12 +121,12 @@
#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
- long int __ret; \
- __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ long int __sysret; \
+ __sysret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
__lll_private_flag (FUTEX_WAKE_OP, private), \
(nr_wake), (nr_wake2), (futexp2), \
FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
- INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ INTERNAL_SYSCALL_ERROR_P (__sysret, __err); \
})
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/pthread_once.c
similarity index 100%
copy from libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pthread_once.c
copy to libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/pthread_once.c
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
new file mode 100644
index 0000000..2af79ca
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
@@ -0,0 +1,139 @@
+/* Copyright (C) 2014-2016 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 <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __ASSEMBLER__
+
+#undef ret
+#define ret
+
+# if !IS_IN_librt || !defined(PIC)
+# define AC_STACK_SIZE 16 /* space for r15, async_cancel arg and 2 temp words */
+# define AC_SET_GOT /* empty */
+# define AC_RESTORE_GOT /* empty */
+# else
+# define AC_STACK_SIZE 20 /* extra 4 bytes for r20 */
+# define AC_SET_GOT \
+ swi r20, r1, AC_STACK_SIZE-4; \
+ mfs r20, rpc; \
+ addik r20, r20, _GLOBAL_OFFSET_TABLE_+8;
+# define AC_RESTORE_GOT \
+ lwi r20, r1, AC_STACK_SIZE-4;
+# endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P(r12); \
+ bnei r12, L(pseudo_cancel); \
+ .globl __##syscall_name##_nocancel; \
+ .type __##syscall_name##_nocancel,@function; \
+__##syscall_name##_nocancel: \
+ DO_CALL (syscall_name, args); \
+ addik r4, r0, -4095; \
+ cmpu r4, r4, r3; \
+ rsubk r3,r3,r0; \
+ rtsd r15,8; \
+ addik r3,r0,-1; \
+ rtsd r15, 8; \
+ nop; \
+ .size __##syscall_name##_nocancel, .-__##syscall_name##_nocancel; \
+L(pseudo_cancel): \
+ addik r1, r1, -AC_STACK_SIZE; \
+ swi r15, r1, 0; \
+ AC_SET_GOT \
+ DOCARGS_##args \
+ CENABLE; \
+ swi r3, r1, 8; \
+ UNDOCARGS_##args \
+ DO_CALL (syscall_name, args); \
+ swi r3, r1, 12; \
+ lwi r5, r1, 8; \
+ CDISABLE; \
+ lwi r3, r1, 12; \
+ lwi r15, r1, 0; \
+ AC_RESTORE_GOT \
+ addik r1, r1, AC_STACK_SIZE; \
+ addik r4, r0, -4095; \
+ cmpu r4, r4, r3; \
+ rsubk r3,r3,r0; \
+ rtsd r15,8; \
+ addik r3,r0,-1; \
+ rtsd r15, 8; \
+ nop;
+
+/*
+ * Macros to save/restore syscall arguments across CENABLE
+ * The arguments are saved into the caller's stack (original r1 + 4)
+ */
+
+# define DOCARGS_0
+# define DOCARGS_1 swi r5, r1, AC_STACK_SIZE + 4;
+# define DOCARGS_2 swi r6, r1, AC_STACK_SIZE + 8; DOCARGS_1
+# define DOCARGS_3 swi r7, r1, AC_STACK_SIZE + 12; DOCARGS_2
+# define DOCARGS_4 swi r8, r1, AC_STACK_SIZE + 16; DOCARGS_3
+# define DOCARGS_5 swi r9, r1, AC_STACK_SIZE + 20; DOCARGS_4
+# define DOCARGS_6 swi r10, r1, AC_STACK_SIZE + 24; DOCARGS_5
+
+# define UNDOCARGS_0
+# define UNDOCARGS_1 lwi r5, r1, AC_STACK_SIZE + 4;
+# define UNDOCARGS_2 UNDOCARGS_1 lwi r6, r1, AC_STACK_SIZE + 8;
+# define UNDOCARGS_3 UNDOCARGS_2 lwi r7, r1, AC_STACK_SIZE + 12;
+# define UNDOCARGS_4 UNDOCARGS_3 lwi r8, r1, AC_STACK_SIZE + 16;
+# define UNDOCARGS_5 UNDOCARGS_4 lwi r9, r1, AC_STACK_SIZE + 20;
+# define UNDOCARGS_6 UNDOCARGS_5 lwi r10, r1, AC_STACK_SIZE + 24;
+
+# ifdef PIC
+# define PSEUDO_JMP(sym) brlid r15, sym##@PLTPC; addk r0, r0, r0
+# else
+# define PSEUDO_JMP(sym) brlid r15, sym; addk r0, r0, r0
+# endif
+
+# if defined IS_IN_libpthread
+# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
+# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
+# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
+# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
+# else
+# error Unsupported library
+# endif
+
+#define SINGLE_THREAD_P(reg) \
+ lwi reg, r0, MULTIPLE_THREADS_OFFSET(reg)
+
+#else /* !__ASSEMBLER__ */
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+
+#endif /* __ASSEMBLER__ */
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S
new file mode 100644
index 0000000..4336717
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S
@@ -0,0 +1,5 @@
+#define SAVE_PID
+#define RESTORE_PID
+#include <tls.h>
+#include <tcb-offsets.h>
+#include <libc/sysdeps/linux/microblaze/vfork.S>
hooks/post-receive
--
uClibc-ng - small C library for embedded systems
It seems as if static libc is missing symbols for libdl in uclibc-ng
1.0.19. When trying to static link I get the typical 'undefined to
dl....' errors, but dynamic linking is successful.
Thanks,
Lance