aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@codesourcery.com>2013-02-27 23:45:07 +0000
committerMaciej W. Rozycki <macro@codesourcery.com>2013-02-27 23:45:07 +0000
commit43301bd3c281036ba97eef384c9340cc7b6130d3 (patch)
tree263f0cc7e01c33c72e626480a52b2bfc1dce78f0
parent85bd816a603a437aedeb688a60a3e0dba4439c50 (diff)
downloadglibc-43301bd3c281036ba97eef384c9340cc7b6130d3.tar.xz
glibc-43301bd3c281036ba97eef384c9340cc7b6130d3.zip
Add support for building as MIPS16 code.
-rw-r--r--ports/ChangeLog.mips106
-rw-r--r--ports/sysdeps/mips/__longjmp.c6
-rw-r--r--ports/sysdeps/mips/abort-instr.h6
-rw-r--r--ports/sysdeps/mips/bits/atomic.h45
-rw-r--r--ports/sysdeps/mips/bsd-_setjmp.S2
-rw-r--r--ports/sysdeps/mips/bsd-setjmp.S2
-rw-r--r--ports/sysdeps/mips/dl-machine.h102
-rw-r--r--ports/sysdeps/mips/dl-trampoline.c130
-rw-r--r--ports/sysdeps/mips/fpu/e_sqrt.c2
-rw-r--r--ports/sysdeps/mips/fpu/e_sqrtf.c2
-rw-r--r--ports/sysdeps/mips/fpu_control.h11
-rw-r--r--ports/sysdeps/mips/machine-gmon.h14
-rw-r--r--ports/sysdeps/mips/memset.S1
-rw-r--r--ports/sysdeps/mips/mips32/crti.S2
-rw-r--r--ports/sysdeps/mips/mips32/crtn.S2
-rw-r--r--ports/sysdeps/mips/mips32/fpu/Versions5
-rw-r--r--ports/sysdeps/mips/mips32/fpu/fpu_control.c34
-rw-r--r--ports/sysdeps/mips/mips32/mips16/add_n.c1
-rw-r--r--ports/sysdeps/mips/mips32/mips16/addmul_1.c1
-rw-r--r--ports/sysdeps/mips/mips32/mips16/fpu/Makefile5
-rw-r--r--ports/sysdeps/mips/mips32/mips16/lshift.c1
-rw-r--r--ports/sysdeps/mips/mips32/mips16/mul_1.c1
-rw-r--r--ports/sysdeps/mips/mips32/mips16/rshift.c1
-rw-r--r--ports/sysdeps/mips/mips32/mips16/sub_n.c1
-rw-r--r--ports/sysdeps/mips/mips32/mips16/submul_1.c1
-rw-r--r--ports/sysdeps/mips/mips64/n32/crti.S2
-rw-r--r--ports/sysdeps/mips/mips64/n32/crtn.S2
-rw-r--r--ports/sysdeps/mips/mips64/n64/crti.S2
-rw-r--r--ports/sysdeps/mips/mips64/n64/crtn.S2
-rw-r--r--ports/sysdeps/mips/nptl/tls.h5
-rw-r--r--ports/sysdeps/mips/preconfigure7
-rw-r--r--ports/sysdeps/mips/setjmp.S2
-rw-r--r--ports/sysdeps/mips/setjmp_aux.c2
-rw-r--r--ports/sysdeps/mips/start.S80
-rw-r--r--ports/sysdeps/mips/sys/tas.h5
-rw-r--r--ports/sysdeps/mips/tls-macros.h63
-rw-r--r--ports/sysdeps/unix/mips/mips32/sysdep.h2
-rw-r--r--ports/sysdeps/unix/mips/mips64/n32/sysdep.h2
-rw-r--r--ports/sysdeps/unix/mips/mips64/n64/sysdep.h2
-rw-r--r--ports/sysdeps/unix/mips/sysdep.S2
-rw-r--r--ports/sysdeps/unix/mips/sysdep.h2
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/brk.c13
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/clone.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/getcontext.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/makecontext.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Makefile13
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Versions6
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h89
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall0.c30
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall1.c32
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall2.c32
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall3.c32
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall4.c32
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall5.c33
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall6.c33
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall7.c33
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist2
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h35
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/setcontext.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/swapcontext.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/vfork.S1
62 files changed, 1041 insertions, 47 deletions
diff --git a/ports/ChangeLog.mips b/ports/ChangeLog.mips
index f06c986333..251806572d 100644
--- a/ports/ChangeLog.mips
+++ b/ports/ChangeLog.mips
@@ -1,3 +1,109 @@
+2013-02-27 Chung-Lin Tang <cltang@codesourcery.com>
+ Maciej W. Rozycki <macro@codesourcery.com>
+ Maxim Kuvyrkov <maxim@codesourcery.com>
+
+ * sysdeps/mips/abort-instr.h (ABORT_INSTRUCTION) [__mips16]:
+ New macro.
+ * sysdeps/mips/dl-machine.h (elf_machine_load_address): Add
+ MIPS16 version of assembly code.
+ (RTLD_START) [__mips16]: New macro.
+ * sysdeps/mips/fpu_control.h (__mips_fpu_getcw): New prototype.
+ (__mips_fpu_setcw): Likewise.
+ (_FPU_GETCW) [__mips16]: New macro.
+ (_FPU_SETCW) [__mips16]: Likewise.
+ * sysdeps/mips/machine-gmon.h (MCOUNT): Add `.set nomips16'.
+ * sysdeps/mips/tls-macros.h (LOAD_GP) [__mips16]: New macro.
+ (TLS_GD, TLS_LD, TLS_IE, TLS_LE) [__mips16]: Likewise.
+ * sysdeps/mips/bits/atomic.h: Also use __atomic_* builtins with
+ GCC 4.7 in MIPS16 code.
+ (atomic_compare_and_exchange_val_acq) [__mips16]: New macro.
+ (atomic_compare_and_exchange_bool_acq) [__mips16]: Likewise.
+ (atomic_exchange_acq) [__mips16]: Likewise.
+ (atomic_exchange_and_add) [__mips16]: Likewise.
+ (atomic_bit_test_set) [__mips16]: Likewise.
+ (atomic_and, atomic_and_val) [__mips16]: Likewise.
+ (atomic_or, atomic_or_val) [__mips16]: Likewise.
+ (atomic_full_barrier) [__mips16]: Likewise.
+ * sysdeps/mips/nptl/tls.h (READ_THREAD_POINTER) [__mips16]:
+ Likewise.
+ * sysdeps/mips/sys/tas.h (_test_and_set): Add `__nomips16__'
+ attribute.
+ * sysdeps/unix/mips/sysdep.h (PSEUDO_NOERRNO): Add
+ `.set nomips16'.
+ (PSEUDO_ERRVAL): Likewise.
+ * sysdeps/unix/mips/mips32/sysdep.h (PSEUDO): Likewise.
+ * sysdeps/unix/mips/mips64/n32/sysdep.h (PSEUDO): Likewise.
+ * sysdeps/unix/mips/mips64/n64/sysdep.h (PSEUDO): Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+ (INTERNAL_SYSCALL, INTERNAL_SYSCALL_NCS) [__mips16]: New macros.
+ (INTERNAL_SYSCALL_MIPS16) [__mips16]: Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h (PSEUDO):
+ Add `.set nomips16'.
+ * sysdeps/mips/bsd-_setjmp.S (_setjmp): Likewise.
+ * sysdeps/mips/bsd-setjmp.S (setjmp): Likewise.
+ * sysdeps/mips/memset.S (memset): Likewise.
+ * sysdeps/mips/setjmp.S (__sigsetjmp): Likewise.
+ * sysdeps/mips/start.S (ENTRY_POINT) [__mips16]: New function.
+ * sysdeps/mips/mips32/crti.S: Add `.set nomips16'.
+ * sysdeps/mips/mips32/crtn.S: Likewise.
+ * sysdeps/mips/mips64/n32/crti.S: Likewise.
+ * sysdeps/mips/mips64/n32/crtn.S: Likewise.
+ * sysdeps/mips/mips64/n64/crti.S: Likewise.
+ * sysdeps/mips/mips64/n64/crtn.S: Likewise.
+ * sysdeps/unix/mips/sysdep.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/getcontext.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/makecontext.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/setcontext.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/swapcontext.S: Likewise.
+ * sysdeps/unix/sysv/linux/mips/vfork.S: Likewise.
+ * sysdeps/mips/__longjmp.c (__longjmp): Rename function to...
+ (____longjmp): ... this. Make static and add `nomips16'
+ attribute.
+ (__longjmp): New alias.
+ * sysdeps/mips/dl-trampoline.c (_dl_runtime_resolve) [__mips16]:
+ New function.
+ (_dl_runtime_pltresolve): Likewise.
+ * sysdeps/mips/setjmp_aux.c (__sigsetjmp_aux): Add `nomips16'
+ attribute.
+ * sysdeps/mips/fpu/e_sqrt.c (__ieee754_sqrt): Likewise.
+ * sysdeps/mips/fpu/e_sqrtf.c (__ieee754_sqrtf): Likewise.
+ * sysdeps/unix/sysv/linux/mips/brk.c (__brk): Rewrite in terms
+ of INTERNAL_SYSCALL.
+ * sysdeps/mips/mips32/fpu/fpu_control.c: New file.
+ * sysdeps/mips/mips32/mips16/add_n.c: New file.
+ * sysdeps/mips/mips32/mips16/addmul_1.c: New file.
+ * sysdeps/mips/mips32/mips16/lshift.c: New file.
+ * sysdeps/mips/mips32/mips16/mul_1.c: New file.
+ * sysdeps/mips/mips32/mips16/rshift.c: New file.
+ * sysdeps/mips/mips32/mips16/sub_n.c: New file.
+ * sysdeps/mips/mips32/mips16/submul_1.c: New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall0.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall1.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall2.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall3.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall4.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall5.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall6.c:
+ New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall7.c:
+ New file.
+ * sysdeps/mips/mips32/fpu/Versions: New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/Versions: New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist: New
+ file.
+ * sysdeps/mips/mips32/mips16/fpu/Makefile: New file.
+ * sysdeps/unix/sysv/linux/mips/mips32/mips16/Makefile: New file.
+ * sysdeps/mips/preconfigure: Handle o32 MIPS16 compilation.
+
2013-02-20 Thomas Schwinge <thomas@codesourcery.com>
* sysdeps/mips/bits/nan.h [!__GNUC__] (__nan_union): Change
diff --git a/ports/sysdeps/mips/__longjmp.c b/ports/sysdeps/mips/__longjmp.c
index a9efb0dac4..67bdb86cf8 100644
--- a/ports/sysdeps/mips/__longjmp.c
+++ b/ports/sysdeps/mips/__longjmp.c
@@ -23,8 +23,8 @@
#error This file uses GNU C extensions; you must compile with GCC.
#endif
-void
-__longjmp (env_arg, val_arg)
+static void __attribute__ ((nomips16))
+____longjmp (env_arg, val_arg)
__jmp_buf env_arg;
int val_arg;
{
@@ -86,3 +86,5 @@ __longjmp (env_arg, val_arg)
/* Avoid `volatile function does return' warnings. */
for (;;);
}
+
+strong_alias (____longjmp, __longjmp);
diff --git a/ports/sysdeps/mips/abort-instr.h b/ports/sysdeps/mips/abort-instr.h
index d7d8d501b3..7ccae5736b 100644
--- a/ports/sysdeps/mips/abort-instr.h
+++ b/ports/sysdeps/mips/abort-instr.h
@@ -1,2 +1,6 @@
/* An instruction which should crash any program is a breakpoint. */
-#define ABORT_INSTRUCTION asm ("break 255")
+#ifdef __mips16
+# define ABORT_INSTRUCTION asm ("break 63")
+#else
+# define ABORT_INSTRUCTION asm ("break 255")
+#endif
diff --git a/ports/sysdeps/mips/bits/atomic.h b/ports/sysdeps/mips/bits/atomic.h
index 566b3dd2b8..bdc3acef7b 100644
--- a/ports/sysdeps/mips/bits/atomic.h
+++ b/ports/sysdeps/mips/bits/atomic.h
@@ -78,9 +78,12 @@ typedef uintmax_t uatomic_max_t;
#define MIPS_SYNC_STR_1(X) MIPS_SYNC_STR_2(X)
#define MIPS_SYNC_STR MIPS_SYNC_STR_1(MIPS_SYNC)
-#if __GNUC_PREREQ (4, 8)
+#if __GNUC_PREREQ (4, 8) || (defined __mips16 && __GNUC_PREREQ (4, 7))
/* The __atomic_* builtins are available in GCC 4.7 and later, but MIPS
- support for their efficient implementation was added only in GCC 4.8. */
+ support for their efficient implementation was added only in GCC 4.8.
+ We still want to use them even with GCC 4.7 for MIPS16 code where we
+ have no assembly alternative available and want to avoid the __sync_*
+ if at all possible. */
/* Compare and exchange.
For all "bool" routines, we return FALSE if exchange succesful. */
@@ -200,7 +203,33 @@ typedef uintmax_t uatomic_max_t;
# define atomic_exchange_and_add_rel(mem, value) \
__atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \
__ATOMIC_RELEASE)
-#else /* !__GNUC_PREREQ (4, 8) */
+
+#elif defined __mips16 /* !__GNUC_PREREQ (4, 7) */
+/* This implementation using __sync* builtins will be removed once glibc
+ requires GCC 4.7 or later to build. */
+
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ __sync_val_compare_and_swap ((mem), (oldval), (newval))
+#