[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commits] r22525 - in /fsf/trunk/libc: ./ csu/ ports/ ports/sysdeps/mips/ ports/sysdeps/mips/bits/ ports/sysdeps/mips/fpu/ ports/sysde...



Author: eglibc
Date: Thu Feb 28 00:02:44 2013
New Revision: 22525

Log:
Import glibc-mainline for 2013-02-28

Added:
    fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/
    fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/Versions
    fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/fpu_control.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/add_n.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/addmul_1.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/fpu/
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/fpu/Makefile
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/lshift.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/mul_1.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/rshift.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/sub_n.c
    fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/submul_1.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Makefile
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Versions
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall0.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall1.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall2.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall3.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall4.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall5.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall6.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall7.c
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/Makeconfig
    fsf/trunk/libc/csu/gmon-start.c
    fsf/trunk/libc/ports/ChangeLog.mips
    fsf/trunk/libc/ports/sysdeps/mips/__longjmp.c
    fsf/trunk/libc/ports/sysdeps/mips/abort-instr.h
    fsf/trunk/libc/ports/sysdeps/mips/bits/atomic.h
    fsf/trunk/libc/ports/sysdeps/mips/bsd-_setjmp.S
    fsf/trunk/libc/ports/sysdeps/mips/bsd-setjmp.S
    fsf/trunk/libc/ports/sysdeps/mips/dl-machine.h
    fsf/trunk/libc/ports/sysdeps/mips/dl-trampoline.c
    fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrt.c
    fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrtf.c
    fsf/trunk/libc/ports/sysdeps/mips/fpu_control.h
    fsf/trunk/libc/ports/sysdeps/mips/machine-gmon.h
    fsf/trunk/libc/ports/sysdeps/mips/memset.S
    fsf/trunk/libc/ports/sysdeps/mips/mips32/crti.S
    fsf/trunk/libc/ports/sysdeps/mips/mips32/crtn.S
    fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crti.S
    fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crtn.S
    fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crti.S
    fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crtn.S
    fsf/trunk/libc/ports/sysdeps/mips/nptl/tls.h
    fsf/trunk/libc/ports/sysdeps/mips/preconfigure
    fsf/trunk/libc/ports/sysdeps/mips/setjmp.S
    fsf/trunk/libc/ports/sysdeps/mips/setjmp_aux.c
    fsf/trunk/libc/ports/sysdeps/mips/start.S
    fsf/trunk/libc/ports/sysdeps/mips/sys/tas.h
    fsf/trunk/libc/ports/sysdeps/mips/tls-macros.h
    fsf/trunk/libc/ports/sysdeps/unix/mips/mips32/sysdep.h
    fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
    fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
    fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.S
    fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.h
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/brk.c
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/clone.S
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/getcontext.S
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/makecontext.S
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/setcontext.S
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S
    fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/vfork.S
    fsf/trunk/libc/scripts/config.guess
    fsf/trunk/libc/scripts/config.sub
    fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan.c
    fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan2.c
    fsf/trunk/libc/sysdeps/ieee754/dbl-64/mplog.c
    fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpsqrt.c
    fsf/trunk/libc/sysdeps/ieee754/dbl-64/mptan.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Thu Feb 28 00:02:44 2013
@@ -1,3 +1,29 @@
+2013-02-27  Roland McGrath  <roland@xxxxxxxxxxxxx>
+
+	* csu/gmon-start.c: Add special exception to license text.
+
+2013-02-27  Richard Henderson  <rth@xxxxxxxxxx>
+
+	* scripts/config.guess: Update from config.git.
+	* scripts/config.sub: Likewise.
+
+2013-02-27  Siddhesh Poyarekar  <siddhesh@xxxxxxxxxx>
+
+	* sysdeps/ieee754/dbl-64/mpsqrt.c: Reformat.
+
+	* sysdeps/ieee754/dbl-64/mpatan2.c: Reformat.
+
+	* sysdeps/ieee754/dbl-64/mpatan.c: Reformat.
+
+	* sysdeps/ieee754/dbl-64/mptan.c: Reformat.
+
+	* sysdeps/ieee754/dbl-64/mplog.c: Reformat.
+
+2013-02-26  Roland McGrath  <roland@xxxxxxxxxxxxx>
+
+	* Makeconfig (%.v.i, %.v): Move these pattern rules outside of
+	[$(build-shared = yes].
+
 2013-02-26  Siddhesh Poyarekar  <siddhesh@xxxxxxxxxx>
 
 	* sysdeps/ieee754/dbl-64/mpa.c: Include alloca.h.

Modified: fsf/trunk/libc/Makeconfig
==============================================================================
--- fsf/trunk/libc/Makeconfig (original)
+++ fsf/trunk/libc/Makeconfig Thu Feb 28 00:02:44 2013
@@ -868,8 +868,6 @@
 subdir-srcdirs = $(foreach dir,$(subdirs),\
 			   $(firstword $($(dir)-srcdir) $(..)$(dir)))
 
-ifeq (yes, $(build-shared))
-
 # This is a pair of implicit rules to preprocess a file with # comments,
 # %ifdef et al, based on config.h settings or other %include'd files.
 # We use chained rules instead of a pipeline here so that we can properly
@@ -887,6 +885,8 @@
 %.v: %.v.i
 	sed '/^[ 	]*#/d;/^[ 	]*$$/d' $< > $@T
 	mv -f $@T $@
+
+ifeq (yes, $(build-shared))
 
 # To generate a header to support more than one ABI for different
 # architecture variants, the CPU/Makefile defines abi-variants to be a

Modified: fsf/trunk/libc/csu/gmon-start.c
==============================================================================
--- fsf/trunk/libc/csu/gmon-start.c (original)
+++ fsf/trunk/libc/csu/gmon-start.c Thu Feb 28 00:02:44 2013
@@ -6,6 +6,23 @@
    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

Modified: fsf/trunk/libc/ports/ChangeLog.mips
==============================================================================
--- fsf/trunk/libc/ports/ChangeLog.mips (original)
+++ fsf/trunk/libc/ports/ChangeLog.mips Thu Feb 28 00:02:44 2013
@@ -1,3 +1,109 @@
+2013-02-27  Chung-Lin Tang  <cltang@xxxxxxxxxxxxxxxx>
+            Maciej W. Rozycki  <macro@xxxxxxxxxxxxxxxx>
+            Maxim Kuvyrkov  <maxim@xxxxxxxxxxxxxxxx>
+
+	* 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@xxxxxxxxxxxxxxxx>
 
 	* sysdeps/mips/bits/nan.h [!__GNUC__] (__nan_union): Change

Modified: fsf/trunk/libc/ports/sysdeps/mips/__longjmp.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/__longjmp.c (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/__longjmp.c Thu Feb 28 00:02:44 2013
@@ -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 @@
   /* Avoid `volatile function does return' warnings.  */
   for (;;);
 }
+
+strong_alias (____longjmp, __longjmp);

Modified: fsf/trunk/libc/ports/sysdeps/mips/abort-instr.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/abort-instr.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/abort-instr.h Thu Feb 28 00:02:44 2013
@@ -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

Modified: fsf/trunk/libc/ports/sysdeps/mips/bits/atomic.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/bits/atomic.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/bits/atomic.h Thu Feb 28 00:02:44 2013
@@ -78,9 +78,12 @@
 #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 @@
 # 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))
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval)	\
+  (!__sync_bool_compare_and_swap ((mem), (oldval), (newval)))
+
+# define atomic_exchange_acq(mem, newval)				\
+  __sync_lock_test_and_set ((mem), (newval))
+
+# define atomic_exchange_and_add(mem, val)				\
+  __sync_fetch_and_add ((mem), (val))
+
+# define atomic_bit_test_set(mem, bit)					\
+  ({ __typeof (bit) __bit = (bit);					\
+     (__sync_fetch_and_or ((mem), 1 << (__bit)) & (1 << (__bit))); })
+
+# define atomic_and(mem, mask) (void) __sync_fetch_and_and ((mem), (mask))
+# define atomic_and_val(mem, mask) __sync_fetch_and_and ((mem), (mask))
+
+# define atomic_or(mem, mask) (void) __sync_fetch_and_or ((mem), (mask))
+# define atomic_or_val(mem, mask) __sync_fetch_and_or ((mem), (mask))
+
+#else /* !__mips16 && !__GNUC_PREREQ (4, 8) */
 /* This implementation using inline assembly will be removed once glibc
    requires GCC 4.8 or later to build.  */
 
@@ -443,15 +472,21 @@
 # define atomic_exchange_and_add_rel(mem, value)			\
   __atomic_val_bysize (__arch_exchange_and_add, int, mem, value,	\
 		       MIPS_SYNC_STR, "")
-#endif /* __GNUC_PREREQ (4, 8) */
+
+#endif /* !__mips16 && !__GNUC_PREREQ (4, 8) */
 
 /* TODO: More atomic operations could be implemented efficiently; only the
    basic requirements are done.  */
 
-#define atomic_full_barrier() \
+#ifdef __mips16
+# define atomic_full_barrier() __sync_synchronize ()
+
+#else /* !__mips16 */
+# define atomic_full_barrier() \
   __asm__ __volatile__ (".set push\n\t"					      \
 			MIPS_PUSH_MIPS2					      \
 			MIPS_SYNC_STR "\n\t"				      \
 			".set pop" : : : "memory")
+#endif /* !__mips16 */
 
 #endif /* bits/atomic.h */

Modified: fsf/trunk/libc/ports/sysdeps/mips/bsd-_setjmp.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/bsd-_setjmp.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/bsd-_setjmp.S Thu Feb 28 00:02:44 2013
@@ -22,6 +22,8 @@
 
 #include <sysdep.h>
 
+	.set	nomips16
+
 #ifdef __PIC__
 	.option pic2
 #endif

Modified: fsf/trunk/libc/ports/sysdeps/mips/bsd-setjmp.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/bsd-setjmp.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/bsd-setjmp.S Thu Feb 28 00:02:44 2013
@@ -22,6 +22,8 @@
 
 #include <sysdep.h>
 
+	.set	nomips16
+
 #ifdef __PIC__
 	.option pic2
 #endif

Modified: fsf/trunk/libc/ports/sysdeps/mips/dl-machine.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/dl-machine.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/dl-machine.h Thu Feb 28 00:02:44 2013
@@ -119,6 +119,7 @@
 elf_machine_load_address (void)
 {
   ElfW(Addr) addr;
+#ifndef __mips16
   asm ("	.set noreorder\n"
        "	" STRINGXP (PTR_LA) " %0, 0f\n"
        "	bltzal $0, 0f\n"
@@ -128,6 +129,19 @@
        :	"=r" (addr)
        :	/* No inputs */
        :	"$31");
+#else
+  ElfW(Addr) tmp;
+  asm ("	.set noreorder\n"
+       "	move %1,$gp\n"
+       "	lw %1,%%got(0f)(%1)\n"
+       "0:	.fill 0\n"		/* Clear the ISA bit on 0:.  */
+       "	la %0,0b\n"
+       "	addiu %1,%%lo(0b)\n"
+       "	subu %0,%1\n"
+       "	.set reorder\n"
+       :	"=d" (addr), "=d" (tmp)
+       :	/* No inputs */);
+#endif
   return addr;
 }
 
@@ -210,7 +224,8 @@
    2) That under Unix the entry is named __start
       and not just plain _start.  */
 
-#define RTLD_START asm (\
+#ifndef __mips16
+# define RTLD_START asm (\
 	".text\n\
 	" _RTLD_PROLOGUE(ENTRY_POINT) "\
 	" STRINGXV(SETUP_GPX($25)) "\n\
@@ -283,6 +298,91 @@
 	".previous"\
 );
 
+#else /* __mips16 */
+/* MIPS16 version.  We currently only support O32 under MIPS16; the proper
+   assembly preprocessor abstractions will need to be added if other ABIs
+   are to be supported.  */
+
+# define RTLD_START asm (\
+	".text\n\
+	.set mips16\n\
+	" _RTLD_PROLOGUE (ENTRY_POINT) "\
+	# Construct GP value in $3.\n\
+	li $3, %hi(_gp_disp)\n\
+	addiu $4, $pc, %lo(_gp_disp)\n\
+	sll $3, 16\n\
+	addu $3, $4\n\
+	move $28, $3\n\
+	lw $4, %got(_DYNAMIC)($3)\n\
+	sw $4, -0x7ff0($3)\n\
+	move $4, $sp\n\
+	addiu $sp, -16\n\
+	# _dl_start() is sufficiently near to use pc-relative\n\
+	# load address.\n\
+	la $3, _dl_start\n\
+	move $25, $3\n\
+	jalr $3\n\
+	addiu $sp, 16\n\
+	" _RTLD_EPILOGUE (ENTRY_POINT) "\
+	\n\
+	\n\
+	" _RTLD_PROLOGUE (_dl_start_user) "\
+	li $16, %hi(_gp_disp)\n\
+	addiu $4, $pc, %lo(_gp_disp)\n\
+	sll $16, 16\n\
+	addu $16, $4\n\
+	move $17, $2\n\
+	move $28, $16\n\
+	lw $4, %got(_dl_skip_args)($16)\n\
+	lw $4, 0($4)\n\
+	beqz $4, 1f\n\
+	# Load the original argument count.\n\
+	lw $5, 0($sp)\n\
+	# Subtract _dl_skip_args from it.\n\
+	subu $5, $4\n\
+	# Adjust the stack pointer to skip _dl_skip_args words.\n\
+	sll $4, " STRINGXP (PTRLOG) "\n\
+	move $6, $sp\n\
+	addu $6, $4\n\
+	move $sp, $6\n\
+	# Save back the modified argument count.\n\
+	sw $5, 0($sp)\n\
+1:	# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
+	lw $4, %got(_rtld_local)($16)\n\
+	lw $4, 0($4)\n\
+	lw $5, 0($sp)\n\
+	addiu $6, $sp, " STRINGXP (PTRSIZE) "\n\
+	sll $7, $5, " STRINGXP (PTRLOG) "\n\
+	addu $7, $6\n\
+	addu $7, " STRINGXP (PTRSIZE) "\n\
+	# Make sure the stack pointer is aligned for _dl_init_internal.\n\
+	li $2, 2 * " STRINGXP (SZREG) "\n\
+	neg $2, $2\n\
+	move $3, $sp\n\
+	and $2, $3\n\
+	sw $3, -" STRINGXP (SZREG) "($2)\n\
+	addiu $2, -32\n\
+	move $sp, $2\n\
+	sw $16, 16($sp)\n\
+	# Call the function to run the initializers.\n\
+	lw $2, %call16(_dl_init_internal)($16)\n\
+	move $25, $2\n\
+	jalr $2\n\
+	# Restore the stack pointer for _start.\n\
+	lw $2, 32-" STRINGXP (SZREG) "($sp)\n\
+	move $sp, $2\n\
+	move $28, $16\n\
+	# Pass our finalizer function to the user in $2 as per ELF ABI.\n\
+	lw $2, %call16(_dl_fini)($16)\n\
+	# Jump to the user entry point.\n\
+	move $25, $17\n\
+	jr $17\n\t"\
+	_RTLD_EPILOGUE (_dl_start_user)\
+	".previous"\
+);
+
+#endif /* __mips16 */
+
 /* Names of the architecture-specific auditing callback functions.  */
 # if _MIPS_SIM == _ABIO32
 #  define ARCH_LA_PLTENTER mips_o32_gnu_pltenter

Modified: fsf/trunk/libc/ports/sysdeps/mips/dl-trampoline.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/dl-trampoline.c (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/dl-trampoline.c Thu Feb 28 00:02:44 2013
@@ -292,9 +292,11 @@
 
 #endif
 
+#ifndef __mips16
 asm ("\n\
 	.text\n\
 	.align	2\n\
+	.set	nomips16\n\
 	.globl	_dl_runtime_resolve\n\
 	.type	_dl_runtime_resolve,@function\n\
 	.ent	_dl_runtime_resolve\n\
@@ -351,6 +353,7 @@
 asm ("\n\
 	.text\n\
 	.align	2\n\
+	.set	nomips16\n\
 	.globl	_dl_runtime_pltresolve\n\
 	.type	_dl_runtime_pltresolve,@function\n\
 	.ent	_dl_runtime_pltresolve\n\
@@ -381,3 +384,130 @@
 	.previous\n\
 ");
 
+#elif _MIPS_SIM == _ABIO32 /* __mips16 */
+/* MIPS16 version, O32 only.  */
+asm ("\n\
+	.text\n\
+	.align	2\n\
+	.set	mips16\n\
+	.globl	_dl_runtime_resolve\n\
+	.type	_dl_runtime_resolve,@function\n\
+	.ent	_dl_runtime_resolve\n\
+_dl_runtime_resolve:\n\
+	.frame	$29, " STRINGXP (ELF_DL_FRAME_SIZE) ", $31\n\
+	# Save arguments and sp value in stack.\n\t"
+# if _MIPS_ISA >= _MIPS_ISA_MIPS32
+	"save	" STRINGXP (ELF_DL_FRAME_SIZE) ", $4-$7, $ra\n\t"
+# else
+	"addiu	$sp, -" STRINGXP (ELF_DL_FRAME_SIZE) "\n\
+	sw	$7, 32($sp)\n\
+	sw	$6, 28($sp)\n\
+	sw	$5, 24($sp)\n\
+	sw	$4, 20($sp)\n\t"
+# endif
+	"# Preserve caller's $ra, for RESTORE instruction below.\n\
+	move	$5, $15\n\
+	sw	$5, 36($sp)\n\
+	# Compute GP into $2.\n\
+	li	$2, %hi(_gp_disp)\n\
+	addiu	$3, $pc, %lo(_gp_disp)\n\
+	sll	$2, 16\n\
+	addu	$2, $3\n\
+	lw	$3, %got(__dl_runtime_resolve)($2)\n\
+	move	$4, $24\n\
+	addiu	$3, %lo(__dl_runtime_resolve)\n\
+	move	$7, $ra\n\
+	move	$6, $28\n\
+	move	$25, $3\n\
+	jalr	$3\n\t"
+# if _MIPS_ISA >= _MIPS_ISA_MIPS32
+	"restore " STRINGXP(ELF_DL_FRAME_SIZE) ", $4-$7, $ra\n\t"
+# else
+	"# Restore $ra, move placed further down to hide latency.\n\
+	lw	$4, 36($sp)\n\
+	lw	$5, 24($sp)\n\
+	lw	$6, 28($sp)\n\
+	lw	$7, 32($sp)\n\
+	move	$ra, $4\n\
+	lw	$4, 20($sp)\n\
+	addiu	$sp, " STRINGXP(ELF_DL_FRAME_SIZE) "\n\t"
+# endif
+	"move	$25, $2\n\
+	jr	$2\n\
+	.end	_dl_runtime_resolve\n\
+	.previous\n\
+");
+
+asm ("\n\
+	.text\n\
+	.align	2\n\
+	.set	mips16\n\
+	.globl	_dl_runtime_pltresolve\n\
+	.type	_dl_runtime_pltresolve,@function\n\
+	.ent	_dl_runtime_pltresolve\n\
+_dl_runtime_pltresolve:\n\
+	.frame	$29, " STRINGXP(ELF_DL_PLT_FRAME_SIZE) ", $31\n\
+	# Save arguments and sp value in stack.\n\t"
+# if _MIPS_ISA >= _MIPS_ISA_MIPS32
+	"save	" STRINGXP(ELF_DL_PLT_FRAME_SIZE) ", $4-$7, $ra\n\t"
+# else
+	"addiu	$sp, -" STRINGXP(ELF_DL_PLT_FRAME_SIZE) "\n\
+	sw	$7, 40($sp)\n\
+	sw	$6, 36($sp)\n\
+	sw	$5, 32($sp)\n\
+	sw	$4, 28($sp)\n\t"
+# endif
+	"# Preserve MIPS16 stub function arguments.\n\
+	sw	$3, 20($sp)\n\
+	sw	$2, 16($sp)\n\
+	# Preserve caller's $ra, for RESTORE instruction below.\n\
+	move	$3, $15\n\
+	sw	$3, 44($sp)\n\
+	# Compute GP into $2.\n\
+	li	$2, %hi(_gp_disp)\n\
+	addiu	$3, $pc, %lo(_gp_disp)\n\
+	sll	$2, 16\n\
+	addu	$2, $3\n\
+	# Save GP value in slot.\n\
+	sw	$2, 24($sp)\n\
+	# Load _dl_fixup address.\n\
+	lw	$6, %call16(_dl_fixup)($2)\n\
+	# Load link map address.\n\
+	move	$3, $28\n\
+	lw	$4, " STRINGXP (PTRSIZE) "($3)\n\
+	move	$5, $24\n\
+	sll	$5, " STRINGXP (PTRLOG) " + 1\n\
+	# Call _dl_fixup.\n\
+	move	$25, $6\n\
+	jalr	$6\n\
+	move	$25, $2\n\
+	# Reload GP value into $28.\n\
+	lw	$3, 24($sp)\n\
+	move	$28, $3\n\
+	lw	$3, 16($sp)\n\
+	move	$15, $3\n\
+	lw	$3, 20($sp)\n\t"
+# if _MIPS_ISA >= _MIPS_ISA_MIPS32
+	"restore " STRINGXP (ELF_DL_PLT_FRAME_SIZE) ", $4-$7, $ra\n\t"
+# else
+	"# Restore $ra, move placed further down to hide latency.\n\
+	lw	$4, 44($sp)\n\
+	lw	$5, 32($sp)\n\
+	lw	$6, 36($sp)\n\
+	lw	$7, 40($sp)\n\
+	move	$ra, $4\n\
+	lw	$4, 28($sp)\n\
+	addiu	$sp, " STRINGXP (ELF_DL_PLT_FRAME_SIZE) "\n\t"
+# endif
+	".set	noreorder\n\
+	jr	$2\n\
+	 move	$2, $15\n\
+	.set	reorder\n\
+	.end	_dl_runtime_pltresolve\n\
+	.previous\n\
+");
+
+#else /* __mips16 && _MIPS_SIM != _ABIO32 */
+# error "MIPS16 support for N32/N64 not implemented"
+
+#endif /* __mips16 */

Modified: fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrt.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrt.c (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrt.c Thu Feb 28 00:02:44 2013
@@ -22,7 +22,7 @@
 
 #if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
 
-double
+double __attribute__ ((nomips16))
 __ieee754_sqrt (double x)
 {
   double z;

Modified: fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrtf.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrtf.c (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/fpu/e_sqrtf.c Thu Feb 28 00:02:44 2013
@@ -22,7 +22,7 @@
 
 #if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
 
-float
+float __attribute__ ((nomips16))
 __ieee754_sqrtf (float x)
 {
   float z;

Modified: fsf/trunk/libc/ports/sysdeps/mips/fpu_control.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/fpu_control.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/fpu_control.h Thu Feb 28 00:02:44 2013
@@ -99,8 +99,15 @@
 typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
 
 /* Macros for accessing the hardware control word.  */
-#define _FPU_GETCW(cw) __asm__ volatile ("cfc1 %0,$31" : "=r" (cw))
-#define _FPU_SETCW(cw) __asm__ volatile ("ctc1 %0,$31" : : "r" (cw))
+extern fpu_control_t __mips_fpu_getcw (void) __THROW;
+extern void __mips_fpu_setcw (fpu_control_t) __THROW;
+#ifdef __mips16
+# define _FPU_GETCW(cw) do { (cw) = __mips_fpu_getcw (); } while (0)
+# define _FPU_SETCW(cw) __mips_fpu_setcw (cw)
+#else
+# define _FPU_GETCW(cw) __asm__ volatile ("cfc1 %0,$31" : "=r" (cw))
+# define _FPU_SETCW(cw) __asm__ volatile ("ctc1 %0,$31" : : "r" (cw))
+#endif
 
 /* Default control word set at startup.  */
 extern fpu_control_t __fpu_control;

Modified: fsf/trunk/libc/ports/sysdeps/mips/machine-gmon.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/machine-gmon.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/machine-gmon.h Thu Feb 28 00:02:44 2013
@@ -37,6 +37,8 @@
 #define MCOUNT asm(\
 	".globl _mcount;\n\t" \
 	".align 2;\n\t" \
+	".set push;\n\t" \
+	".set nomips16;\n\t" \
 	".type _mcount,@function;\n\t" \
 	".ent _mcount\n\t" \
         "_mcount:\n\t" \
@@ -67,9 +69,8 @@
         "addu $29,$29,56;\n\t" \
         "j $31;\n\t" \
         "move $31,$1;\n\t" \
-        ".set reorder;\n\t" \
-        ".set at\n\t" \
-        ".end _mcount");
+	".end _mcount;\n\t" \
+	".set pop");
 
 #else
 
@@ -94,6 +95,8 @@
 #define MCOUNT asm(\
 	".globl _mcount;\n\t" \
 	".align 3;\n\t" \
+	".set push;\n\t" \
+	".set nomips16;\n\t" \
 	".type _mcount,@function;\n\t" \
 	".ent _mcount\n\t" \
         "_mcount:\n\t" \
@@ -132,8 +135,7 @@
         PTR_ADDU_STRING " $29,$29,96;\n\t" \
         "j $31;\n\t" \
         "move $31,$1;\n\t" \
-        ".set reorder;\n\t" \
-        ".set at\n\t" \
-        ".end _mcount");
+	".end _mcount;\n\t" \
+	".set pop");
 
 #endif

Modified: fsf/trunk/libc/ports/sysdeps/mips/memset.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/memset.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/memset.S Thu Feb 28 00:02:44 2013
@@ -18,6 +18,7 @@
 
 #include <sysdep.h>
 
+	.set	nomips16
 
 /* void *memset(void *s, int c, size_t n).  */
 

Modified: fsf/trunk/libc/ports/sysdeps/mips/mips32/crti.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/crti.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/crti.S Thu Feb 28 00:02:44 2013
@@ -54,6 +54,8 @@
 	.hidden PREINIT_FUNCTION
 #endif
 
+	.set nomips16
+
 	.section .init,"ax",@progbits
 	.p2align 2
 	.globl _init

Modified: fsf/trunk/libc/ports/sysdeps/mips/mips32/crtn.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/crtn.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/crtn.S Thu Feb 28 00:02:44 2013
@@ -36,6 +36,8 @@
 /* crtn.S puts function epilogues in the .init and .fini sections
    corresponding to the prologues in crti.S. */
 
+	.set nomips16
+
 	.section .init,"ax",@progbits
 	lw $31,28($sp)
 	.set noreorder

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/Versions
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/Versions (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/Versions Thu Feb 28 00:02:44 2013
@@ -1,0 +1,5 @@
+libc {
+  GLIBC_2.18 {
+    __mips_fpu_getcw; __mips_fpu_setcw;
+  }
+}

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/fpu_control.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/fpu_control.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/fpu/fpu_control.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,34 @@
+/* FPU control word handling, MIPS version, needed by MIPS16 callers.
+   Copyright (C) 1996-2013 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 <math/fpu_control.c>
+
+fpu_control_t
+__mips_fpu_getcw (void)
+{
+  fpu_control_t cw;
+
+  _FPU_GETCW (cw);
+  return cw;
+}
+
+void
+__mips_fpu_setcw (fpu_control_t cw)
+{
+  _FPU_SETCW (cw);
+}

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/add_n.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/add_n.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/add_n.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/add_n.c>

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/addmul_1.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/addmul_1.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/addmul_1.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/addmul_1.c>

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/fpu/Makefile
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/fpu/Makefile (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/fpu/Makefile Thu Feb 28 00:02:44 2013
@@ -1,0 +1,5 @@
+# Building hard-float libm as MIPS16 actually produces larger code size,
+# so avoid doing so.
+ifeq ($(subdir),math)
+sysdep-CFLAGS += -mno-mips16
+endif

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/lshift.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/lshift.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/lshift.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/lshift.c>

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/mul_1.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/mul_1.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/mul_1.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/mul_1.c>

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/rshift.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/rshift.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/rshift.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/rshift.c>

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/sub_n.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/sub_n.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/sub_n.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/sub_n.c>

Added: fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/submul_1.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/submul_1.c (added)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips32/mips16/submul_1.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,1 @@
+#include <stdlib/submul_1.c>

Modified: fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crti.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crti.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crti.S Thu Feb 28 00:02:44 2013
@@ -54,6 +54,8 @@
 	.hidden PREINIT_FUNCTION
 #endif
 
+	.set nomips16
+
 	.section .init,"ax",@progbits
 	.p2align 2
 	.globl _init

Modified: fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crtn.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crtn.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips64/n32/crtn.S Thu Feb 28 00:02:44 2013
@@ -36,6 +36,8 @@
 /* crtn.S puts function epilogues in the .init and .fini sections
    corresponding to the prologues in crti.S. */
 
+	.set nomips16
+
 	.section .init,"ax",@progbits
 	ld $31,8($sp)
 	ld $28,0($sp)

Modified: fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crti.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crti.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crti.S Thu Feb 28 00:02:44 2013
@@ -54,6 +54,8 @@
 	.hidden PREINIT_FUNCTION
 #endif
 
+	.set nomips16
+
 	.section .init,"ax",@progbits
 	.p2align 2
 	.globl _init

Modified: fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crtn.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crtn.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/mips64/n64/crtn.S Thu Feb 28 00:02:44 2013
@@ -36,6 +36,8 @@
 /* crtn.S puts function epilogues in the .init and .fini sections
    corresponding to the prologues in crti.S. */
 
+	.set nomips16
+
 	.section .init,"ax",@progbits
 	ld $31,8($sp)
 	ld $28,0($sp)

Modified: fsf/trunk/libc/ports/sysdeps/mips/nptl/tls.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/nptl/tls.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/nptl/tls.h Thu Feb 28 00:02:44 2013
@@ -37,12 +37,17 @@
   } pointer;
 } dtv_t;
 
+#ifdef __mips16
+/* MIPS16 uses GCC builtin to access the TP.  */
+# define READ_THREAD_POINTER() (__builtin_thread_pointer ())
+#else
 /* 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; })
+#endif
 
 #else /* __ASSEMBLER__ */
 # include <tcb-offsets.h>

Modified: fsf/trunk/libc/ports/sysdeps/mips/preconfigure
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/preconfigure (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/preconfigure Thu Feb 28 00:02:44 2013
@@ -25,5 +25,10 @@
 		  CPPFLAGS="$CPPFLAGS -mabi=$mips_config_abi"
 		fi
 		;;
-mips*)		base_machine=mips machine=mips/mips32/$machine ;;
+mips*)		base_machine=mips
+		case "$CC $CFLAGS $CPPFLAGS " in
+		*" -mips16 "*) machine=mips/mips32/mips16/$machine ;;
+		*) machine=mips/mips32/$machine ;;
+		esac
+		;;
 esac

Modified: fsf/trunk/libc/ports/sysdeps/mips/setjmp.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/setjmp.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/setjmp.S Thu Feb 28 00:02:44 2013
@@ -16,6 +16,8 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
+
+	.set	nomips16
 
 /* The function __sigsetjmp_aux saves all the registers, but it can't
    reliably access the stack or frame pointers, so we pass them in as

Modified: fsf/trunk/libc/ports/sysdeps/mips/setjmp_aux.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/setjmp_aux.c (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/setjmp_aux.c Thu Feb 28 00:02:44 2013
@@ -23,7 +23,7 @@
    pointer.  We do things this way because it's difficult to reliably
    access them in C.  */
 
-int
+int __attribute__ ((nomips16))
 __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
 {
 #ifdef __mips_hard_float

Modified: fsf/trunk/libc/ports/sysdeps/mips/start.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/start.S (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/start.S Thu Feb 28 00:02:44 2013
@@ -74,14 +74,15 @@
 	.text
 	.globl ENTRY_POINT
 	.type ENTRY_POINT,@function
+#ifndef __mips16
 ENTRY_POINT:
-#ifdef __PIC__
+# ifdef __PIC__
 	SETUP_GPX($0)
 	SETUP_GPX64($25,$0)
-#else
+# else
 	PTR_LA $28, _gp		/* Setup GP correctly if we're non-PIC.  */
 	move $31, $0
-#endif
+# endif
 
 	PTR_LA $4, main		/* main */
 	PTR_L $5, 0($29)		/* argc */
@@ -92,21 +93,84 @@
 	   on o32 and quad words (16 bytes) on n32 and n64.  */
 	
 	and $29, -2 * SZREG
-#if _MIPS_SIM == _ABIO32
+# if _MIPS_SIM == _ABIO32
 	PTR_SUBIU $29, 32
-#endif
+# endif
 	PTR_LA $7, __libc_csu_init		/* init */
 	PTR_LA $8, __libc_csu_fini
-#if _MIPS_SIM == _ABIO32
+# if _MIPS_SIM == _ABIO32
 	PTR_S $8, 16($29)		/* fini */
 	PTR_S $2, 20($29)		/* rtld_fini */
 	PTR_S $29, 24($29)		/* stack_end */
-#else
+# else
 	move $9, $2		/* rtld_fini */
 	move $10, $29		/* stack_end */
-#endif
+# endif
 	jal __libc_start_main
 hlt:	b hlt			/* Crash if somehow it does return.  */
+
+#elif _MIPS_SIM == _ABIO32 /* __mips16 */
+	/* MIPS16 entry point.  */
+	.set	mips16
+ENTRY_POINT:
+# ifdef __PIC__
+	li	$3, %hi(_gp_disp)
+	addiu	$4, $pc, %lo(_gp_disp)
+	sll	$3, 16
+	addu	$3, $4
+	move	$gp, $3
+# else
+	li	$3, %hi(_gp)
+	sll	$3, 16
+	addiu	$3, %lo(_gp)
+	move	$gp, $3
+# endif
+	/* Tie end of stack frames.  */
+	li	$4, 0
+	move	$31, $4
+	/* Create new SP value in $7, including alignment.  */
+	li	$4, 2 * SZREG
+	neg	$4, $4
+	move	$7, $sp
+	and	$7, $4
+	addiu	$7, -32
+	/* Load arguments with original SP.  */
+	lw	$5, 0($sp)
+	addiu	$6, $sp, PTRSIZE
+	/* Update SP.  */
+	move	$sp, $7
+	/* Lay out last arguments, and call __libc_start_main().  */
+# ifdef __PIC__
+	sw	$7, 24($sp)			/* stack_end */
+	lw	$4, %got(__libc_csu_fini)($3)
+	lw	$7, %got(__libc_csu_init)($3)	/* init */
+	sw	$4, 16($sp)			/* fini */
+	lw	$4, %got(main)($3)		/* main */
+	lw	$3, %call16(__libc_start_main)($3)
+	sw	$2, 20($sp)			/* rtld_fini */
+	move	$25, $3
+	jalr	$3
+# else
+	lw	$4, 1f
+	sw	$7, 24($sp)			/* stack_end */
+	lw	$7, 2f				/* init */
+	sw	$4, 16($sp)			/* fini */
+	lw	$4, 3f				/* main */
+	sw	$2, 20($sp)			/* rtld_fini */
+	jal	__libc_start_main
+# endif
+hlt:	b	hlt		/* Crash if somehow it does return.  */
+# ifndef __PIC__
+	.align	2
+1:	.word	__libc_csu_fini
+2:	.word	__libc_csu_init
+3:	.word	main
+# endif
+
+#else /* __mips16 && _MIPS_SIM != _ABIO32 */
+# error "MIPS16 support for N32/N64 not implemented"
+
+#endif /* __mips16 */
 
 /* Define a symbol for the first piece of initialized data.  */
 	.data

Modified: fsf/trunk/libc/ports/sysdeps/mips/sys/tas.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/sys/tas.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/sys/tas.h Thu Feb 28 00:02:44 2013
@@ -24,7 +24,8 @@
 
 __BEGIN_DECLS
 
-extern int _test_and_set (int *__p, int __v) __THROW;
+extern int _test_and_set (int *__p, int __v)
+     __THROW __attribute__ ((__nomips16__));
 
 #ifdef __USE_EXTERN_INLINES
 
@@ -32,7 +33,7 @@
 #  define _EXTERN_INLINE __extern_inline
 # endif
 
-_EXTERN_INLINE int
+_EXTERN_INLINE int __attribute__ ((__nomips16__))
 __NTH (_test_and_set (int *__p, int __v))
 {
   int __r, __t;

Modified: fsf/trunk/libc/ports/sysdeps/mips/tls-macros.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/mips/tls-macros.h (original)
+++ fsf/trunk/libc/ports/sysdeps/mips/tls-macros.h Thu Feb 28 00:02:44 2013
@@ -12,16 +12,33 @@
    (abicalls pic0) function.  */
 #ifndef __PIC__
 # if _MIPS_SIM != _ABI64
-#  define LOAD_GP "move %[tmp], $28\n\tla $28, __gnu_local_gp\n\t"
+#  ifndef __mips16
+#   define LOAD_GP "move %[tmp], $28\n\tla $28, __gnu_local_gp\n\t"
+#  else
+#   define LOAD_GP					\
+           "li %[tmp], %%hi(__gnu_local_gp)\n\t"	\
+           "sll %[tmp], 16\n\t"				\
+           "addiu %[tmp], %%lo(__gnu_local_gp)\n\t"
+#  endif
 # else
 #  define LOAD_GP "move %[tmp], $28\n\tdla $28, __gnu_local_gp\n\t"
 # endif
 # define UNLOAD_GP "\n\tmove $28, %[tmp]"
 #else
-# define LOAD_GP
+/* MIPS16 (re)creates the GP value using PC-relative instructions.  */
+# ifdef __mips16
+#  define LOAD_GP					\
+           "li %[tmp], %%hi(_gp_disp)\n\t"		\
+           "addiu %0, $pc, %%lo(_gp_disp)\n\t"		\
+           "sll %[tmp], 16\n\t"				\
+           "addu %[tmp], %0\n\t"
+# else
+#  define LOAD_GP
+# endif
 # define UNLOAD_GP
 #endif
 
+#ifndef __mips16
 # define TLS_GD(x)					\
   ({ void *__result, *__tmp;				\
      extern void *__tls_get_addr (void *);		\
@@ -62,3 +79,45 @@
 	  ADDU " %0,%0,$3"				\
 	  : "+r" (__result) : : "$3");			\
      __result; })
+
+#else /* __mips16 */
+/* MIPS16 version.  */
+# define TLS_GD(x)					\
+  ({ void *__result, *__tmp;				\
+     extern void *__tls_get_addr (void *);		\
+     asm (LOAD_GP ADDIU " %1, %%tlsgd(" #x ")"		\
+	  "\n\tmove %0, %1"				\
+	  : "=d" (__result), [tmp] "=&d" (__tmp));	\
+     (int *) __tls_get_addr (__result); })
+# define TLS_LD(x)					\
+  ({ void *__result, *__tmp;				\
+     extern void *__tls_get_addr (void *);		\
+     asm (LOAD_GP ADDIU " %1, %%tlsldm(" #x ")"		\
+	  "\n\tmove %0, %1"				\
+	  : "=d" (__result), [tmp] "=&d" (__tmp));	\
+     __result = __tls_get_addr (__result);		\
+     asm ("li $3,%%dtprel_hi(" #x ")\n\t"		\
+	  "sll $3,16\n\t"				\
+	  "addiu $3,%%dtprel_lo(" #x ")\n\t"		\
+	  ADDU " %0,%0,$3"				\
+	  : "+d" (__result) : : "$3");			\
+     __result; })
+# define TLS_IE(x)					\
+  ({ void *__result, *__tmp, *__tp;			\
+     __tp = __builtin_thread_pointer ();		\
+     asm (LOAD_GP LW " $3,%%gottprel(" #x ")(%1)\n\t"	\
+	  ADDU " %0,%[tp],$3"				\
+	  : "=&d" (__result), [tmp] "=&d" (__tmp)	\
+	  : [tp] "d" (__tp) : "$3");			\
+     __result; })
+# define TLS_LE(x)					\
+  ({ void *__result, *__tp;				\
+     __tp = __builtin_thread_pointer ();		\
+     asm ("li $3,%%tprel_hi(" #x ")\n\t"		\
+	  "sll $3,16\n\t"				\
+	  "addiu $3,%%tprel_lo(" #x ")\n\t"		\
+	  ADDU " %0,%[tp],$3"				\
+	  : "=d" (__result) : [tp] "d" (__tp) : "$3");	\
+     __result; })
+
+#endif /* __mips16 */

Modified: fsf/trunk/libc/ports/sysdeps/unix/mips/mips32/sysdep.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/mips/mips32/sysdep.h (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/mips/mips32/sysdep.h Thu Feb 28 00:02:44 2013
@@ -24,6 +24,7 @@
 #ifdef __PIC__
 #define PSEUDO(name, syscall_name, args) \
   .align 2;								      \
+  .set nomips16;							      \
   cfi_startproc;							      \
   99: la t9,__syscall_error;						      \
   jr t9;								      \
@@ -39,6 +40,7 @@
 #else
 #define PSEUDO(name, syscall_name, args) \
   .set noreorder;							      \
+  .set nomips16;							      \
   .align 2;								      \
   cfi_startproc;							      \
   99: j __syscall_error;						      \

Modified: fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n32/sysdep.h (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n32/sysdep.h Thu Feb 28 00:02:44 2013
@@ -26,6 +26,7 @@
 #ifdef __PIC__
 #define PSEUDO(name, syscall_name, args) \
   .align 2;								      \
+  .set nomips16;							      \
   cfi_startproc;							      \
   99:;									      \
   .set noat;								      \
@@ -46,6 +47,7 @@
 #define PSEUDO(name, syscall_name, args) \
   .set noreorder;							      \
   .align 2;								      \
+  .set nomips16;							      \
   cfi_startproc;							      \
   99: j __syscall_error;						      \
   nop;                                                                        \

Modified: fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n64/sysdep.h (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/mips/mips64/n64/sysdep.h Thu Feb 28 00:02:44 2013
@@ -26,6 +26,7 @@
 #ifdef __PIC__
 #define PSEUDO(name, syscall_name, args) \
   .align 2;								      \
+  .set nomips16;							      \
   cfi_startproc;							      \
   99:;									      \
   .set noat;								      \
@@ -46,6 +47,7 @@
 #define PSEUDO(name, syscall_name, args) \
   .set noreorder;							      \
   .align 2;								      \
+  .set nomips16;							      \
   cfi_startproc;							      \
   99: j __syscall_error;						      \
   nop;                                                                        \

Modified: fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.S Thu Feb 28 00:02:44 2013
@@ -20,6 +20,8 @@
 #define _ERRNO_H
 #include <bits/errno.h>
 #include <sys/asm.h>
+
+	.set	nomips16
 
 #ifdef _LIBC_REENTRANT
 

Modified: fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.h (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/mips/sysdep.h Thu Feb 28 00:02:44 2013
@@ -44,6 +44,7 @@
 #define PSEUDO_NOERRNO(name, syscall_name, args)	\
   .align 2;						\
   ENTRY(name)						\
+  .set nomips16;					\
   .set noreorder;					\
   li v0, SYS_ify(syscall_name);				\
   syscall
@@ -56,6 +57,7 @@
 #define PSEUDO_ERRVAL(name, syscall_name, args)	\
   .align 2;						\
   ENTRY(name)						\
+  .set nomips16;					\
   .set noreorder;					\
   li v0, SYS_ify(syscall_name);				\
   syscall

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/brk.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/brk.c (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/brk.c Thu Feb 28 00:02:44 2013
@@ -30,19 +30,10 @@
 int
 __brk (void *addr)
 {
+  INTERNAL_SYSCALL_DECL (err);
   void *newbrk;
 
-  {
-    register long int res __asm__ ("$2");
-
-    asm ("move\t$4,%2\n\t"
-	 "li\t%0,%1\n\t"
-	 "syscall"		/* Perform the system call.  */
-	 : "=r" (res)
-	 : "I" (SYS_ify (brk)), "r" (addr)
-	 : "$4", "$7", __SYSCALL_CLOBBERS);
-    newbrk = (void *) res;
-  }
+  newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
   __curbrk = newbrk;
 
   if (newbrk < addr)

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/clone.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/clone.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/clone.S Thu Feb 28 00:02:44 2013
@@ -34,6 +34,7 @@
 	     void *parent_tidptr, void *tls, void *child_tidptr) */
 
 	.text
+	.set		nomips16
 #if _MIPS_SIM == _ABIO32
 # define EXTRA_LOCALS 1
 #else

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/getcontext.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/getcontext.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/getcontext.S Thu Feb 28 00:02:44 2013
@@ -27,6 +27,7 @@
 /* int getcontext (ucontext_t *ucp) */
 
 	.text
+	.set	nomips16
 LOCALSZ = 0
 MASK = 0x00000000
 #ifdef __PIC__

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/makecontext.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/makecontext.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/makecontext.S Thu Feb 28 00:02:44 2013
@@ -27,6 +27,7 @@
 /* int makecontext (ucontext_t *ucp, (void *func) (), int argc, ...) */
 
 	.text
+	.set	nomips16
 LOCALSZ = 0
 ARGSZ = 0
 MASK = 0x00000000

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Makefile
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Makefile (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Makefile Thu Feb 28 00:02:44 2013
@@ -1,0 +1,13 @@
+ifeq ($(subdir),misc)
+sysdep_routines += mips16-syscall0 mips16-syscall1 mips16-syscall2
+sysdep_routines += mips16-syscall3 mips16-syscall4 mips16-syscall5
+sysdep_routines += mips16-syscall6 mips16-syscall7
+CFLAGS-mips16-syscall0.c += -fexceptions
+CFLAGS-mips16-syscall1.c += -fexceptions
+CFLAGS-mips16-syscall2.c += -fexceptions
+CFLAGS-mips16-syscall3.c += -fexceptions
+CFLAGS-mips16-syscall4.c += -fexceptions
+CFLAGS-mips16-syscall5.c += -fexceptions
+CFLAGS-mips16-syscall6.c += -fexceptions
+CFLAGS-mips16-syscall7.c += -fexceptions
+endif

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Versions
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Versions (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/Versions Thu Feb 28 00:02:44 2013
@@ -1,0 +1,6 @@
+libc {
+  GLIBC_PRIVATE {
+    __mips16_syscall0; __mips16_syscall1; __mips16_syscall2; __mips16_syscall3;
+    __mips16_syscall4; __mips16_syscall5; __mips16_syscall6; __mips16_syscall7;
+  }
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall.h Thu Feb 28 00:02:44 2013
@@ -1,0 +1,89 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 MIPS16_SYSCALL_H
+#define MIPS16_SYSCALL_H 1
+
+#define __nomips16 __attribute__ ((nomips16))
+
+union __mips16_syscall_return
+  {
+    long long val;
+    struct
+      {
+	long v0;
+	long v1;
+      }
+    reg;
+  };
+
+long long __nomips16 __mips16_syscall0 (long number);
+#define __mips16_syscall0(dummy, number)				\
+	__mips16_syscall0 ((long) (number))
+
+long long __nomips16 __mips16_syscall1 (long a0,
+					long number);
+#define __mips16_syscall1(a0, number)					\
+	__mips16_syscall1 ((long) (a0),					\
+			   (long) (number))
+
+long long __nomips16 __mips16_syscall2 (long a0, long a1,
+					long number);
+#define __mips16_syscall2(a0, a1, number)				\
+	__mips16_syscall2 ((long) (a0), (long) (a1),			\
+			   (long) (number))
+
+long long __nomips16 __mips16_syscall3 (long a0, long a1, long a2,
+					long number);
+#define __mips16_syscall3(a0, a1, a2, number)				\
+	__mips16_syscall3 ((long) (a0), (long) (a1), (long) (a2),	\
+			   (long) (number))
+
+long long __nomips16 __mips16_syscall4 (long a0, long a1, long a2, long a3,
+					long number);
+#define __mips16_syscall4(a0, a1, a2, a3, number)			\
+	__mips16_syscall4 ((long) (a0), (long) (a1), (long) (a2),	\
+			   (long) (a3),					\
+			   (long) (number))
+
+long long __nomips16 __mips16_syscall5 (long a0, long a1, long a2, long a3,
+					long a4,
+					long number);
+#define __mips16_syscall5(a0, a1, a2, a3, a4, number)			\
+	__mips16_syscall5 ((long) (a0), (long) (a1), (long) (a2),	\
+			   (long) (a3), (long) (a4),			\
+			   (long) (number))
+
+long long __nomips16 __mips16_syscall6 (long a0, long a1, long a2, long a3,
+					long a4, long a5,
+					long number);
+#define __mips16_syscall6(a0, a1, a2, a3, a4, a5, number)		\
+	__mips16_syscall6 ((long) (a0), (long) (a1), (long) (a2),	\
+			   (long) (a3), (long) (a4), (long) (a5),	\
+			   (long) (number))
+
+long long __nomips16 __mips16_syscall7 (long a0, long a1, long a2, long a3,
+					long a4, long a5, long a6,
+					long number);
+#define __mips16_syscall7(a0, a1, a2, a3, a4, a5, a6, number)		\
+	__mips16_syscall7 ((long) (a0), (long) (a1), (long) (a2),	\
+			   (long) (a3), (long) (a4), (long) (a5),	\
+			   (long) (a6),					\
+			   (long) (number))
+
+#endif

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall0.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall0.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall0.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,30 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall0
+
+long long __nomips16
+__mips16_syscall0 (long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 0);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall1.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall1.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall1.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,32 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall1
+
+long long __nomips16
+__mips16_syscall1 (long a0,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 1,
+					a0);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall2.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall2.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall2.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,32 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall2
+
+long long __nomips16
+__mips16_syscall2 (long a0, long a1,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 2,
+					a0, a1);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall3.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall3.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall3.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,32 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall3
+
+long long __nomips16
+__mips16_syscall3 (long a0, long a1, long a2,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 3,
+					a0, a1, a2);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall4.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall4.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall4.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,32 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall4
+
+long long __nomips16
+__mips16_syscall4 (long a0, long a1, long a2, long a3,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 4,
+					a0, a1, a2, a3);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall5.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall5.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall5.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,33 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall5
+
+long long __nomips16
+__mips16_syscall5 (long a0, long a1, long a2, long a3,
+		   long a4,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 5,
+					a0, a1, a2, a3, a4);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall6.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall6.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall6.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,33 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall6
+
+long long __nomips16
+__mips16_syscall6 (long a0, long a1, long a2, long a3,
+		   long a4, long a5,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 6,
+					a0, a1, a2, a3, a4, a5);
+  return ret.val;
+}

Added: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall7.c
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall7.c (added)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/mips16/mips16-syscall7.c Thu Feb 28 00:02:44 2013
@@ -1,0 +1,33 @@
+/* MIPS16 syscall wrappers.
+   Copyright (C) 2013 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 <mips16-syscall.h>
+
+#undef __mips16_syscall7
+
+long long __nomips16
+__mips16_syscall7 (long a0, long a1, long a2, long a3,
+		   long a4, long a5, long a6,
+		   long number)
+{
+  union __mips16_syscall_return ret;
+  ret.reg.v0 = INTERNAL_SYSCALL_MIPS16 (number, ret.reg.v1, 7,
+					a0, a1, a2, a3, a4, a5, a6);
+  return ret.val;
+}

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/nptl/libc.abilist Thu Feb 28 00:02:44 2013
@@ -1401,6 +1401,8 @@
 GLIBC_2.18
  GLIBC_2.18 A
  __cxa_thread_atexit_impl F
+ __mips_fpu_getcw F
+ __mips_fpu_setcw F
 GLIBC_2.2
  GLIBC_2.2 A
  _Exit F

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h Thu Feb 28 00:02:44 2013
@@ -95,16 +95,45 @@
 #endif
 
 #undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...)			\
+#undef INTERNAL_SYSCALL_NCS
+
+#ifdef __mips16
+/* There's no MIPS16 syscall instruction, so we go through out-of-line
+   standard MIPS wrappers.  These do use inline snippets below though,
+   through INTERNAL_SYSCALL_MIPS16.  Spilling the syscall number to
+   memory gives the best code in that case, avoiding the need to save
+   and restore a static register.  */
+
+# include <mips16-syscall.h>
+
+# define INTERNAL_SYSCALL(name, err, nr, args...)			\
+	INTERNAL_SYSCALL_NCS (SYS_ify (name), err, nr, args)
+
+# define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
+({									\
+	union __mips16_syscall_return ret;				\
+	ret.val = __mips16_syscall##nr (args, number);			\
+	err = ret.reg.v1;						\
+	ret.reg.v0;							\
+})
+
+# define INTERNAL_SYSCALL_MIPS16(number, err, nr, args...)		\
+	internal_syscall##nr ("lw\t%0, %2\n\t",				\
+			      "R" (number),				\
+			      0, err, args)
+
+#else /* !__mips16 */
+# define INTERNAL_SYSCALL(name, err, nr, args...)			\
 	internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t",	\
 			      "IK" (SYS_ify (name)),			\
 			      0, err, args)
 
-#undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
+# define INTERNAL_SYSCALL_NCS(number, err, nr, args...)			\
 	internal_syscall##nr (MOVE32 "\t%0, %2\n\t",			\
 			      "r" (__s0),				\
 			      number, err, args)
+
+#endif /* !__mips16 */
 
 #define internal_syscall0(v0_init, input, number, err, dummy...)	\
 ({									\

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h Thu Feb 28 00:02:44 2013
@@ -39,6 +39,7 @@
 # undef PSEUDO
 # define PSEUDO(name, syscall_name, args)				      \
       .align 2;								      \
+      .set nomips16;							      \
   L(pseudo_start):							      \
       cfi_startproc;							      \
   99: PSEUDO_ERRJMP							      \

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/setcontext.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/setcontext.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/setcontext.S Thu Feb 28 00:02:44 2013
@@ -27,6 +27,7 @@
 /* int setcontext (const ucontext_t *ucp) */
 
 	.text
+	.set	nomips16
 LOCALSZ = 0
 ARGSZ = 0
 MASK = 0x00000000

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/swapcontext.S Thu Feb 28 00:02:44 2013
@@ -27,6 +27,7 @@
 /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
 
 	.text
+	.set	nomips16
 LOCALSZ = 0
 ARGSZ = 0
 MASK = 0x00000000

Modified: fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/vfork.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/vfork.S (original)
+++ fsf/trunk/libc/ports/sysdeps/unix/sysv/linux/mips/vfork.S Thu Feb 28 00:02:44 2013
@@ -34,6 +34,7 @@
 /* int vfork() */
 
 	.text
+	.set		nomips16
 LOCALSZ= 1
 FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
 GPOFF= FRAMESZ-(1*SZREG)

Modified: fsf/trunk/libc/scripts/config.guess
==============================================================================
--- fsf/trunk/libc/scripts/config.guess (original)
+++ fsf/trunk/libc/scripts/config.guess Thu Feb 28 00:02:44 2013
@@ -1,14 +1,12 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011, 2012 Free Software Foundation, Inc.
-
-timestamp='2012-09-25'
+#   Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-02-12'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -22,19 +20,17 @@
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner.  Please send patches (context
-# diff format) to <config-patches@xxxxxxx> and include a ChangeLog
-# entry.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 #
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
+# Originally written by Per Bothner.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches with a ChangeLog entry to config-patches@xxxxxxxx
+
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -54,9 +50,7 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -959,6 +953,9 @@
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 	;;
+    or1k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
     or32:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;

Modified: fsf/trunk/libc/scripts/config.sub
==============================================================================
--- fsf/trunk/libc/scripts/config.sub (original)
+++ fsf/trunk/libc/scripts/config.sub Thu Feb 28 00:02:44 2013
@@ -1,24 +1,18 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011, 2012 Free Software Foundation, Inc.
-
-timestamp='2012-08-18'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+#   Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-02-12'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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 General Public License for more details.
+# 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
+# General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
@@ -26,11 +20,12 @@
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@xxxxxxx>.  Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches with a ChangeLog entry to config-patches@xxxxxxxx
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -73,9 +68,7 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -156,7 +149,7 @@
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray | -microblaze)
+	-apple | -axis | -knuth | -cray | -microblaze*)
 		os=
 		basic_machine=$1
 		;;
@@ -259,8 +252,10 @@
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
-        | be32 | be64 \
+	| arc \
+	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+	| avr | avr32 \
+	| be32 | be64 \
 	| bfin \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
@@ -273,7 +268,7 @@
 	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore | mep | metag \
+	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -291,16 +286,17 @@
 	| mipsisa64r2 | mipsisa64r2el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipsr5900 | mipsr5900el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
 	| moxie \
 	| mt \
 	| msp430 \
 	| nds32 | nds32le | nds32be \
-	| nios | nios2 \
+	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
 	| open8 \
-	| or32 \
+	| or1k | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
@@ -389,7 +385,8 @@
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| microblaze-* | microblazeel-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -407,12 +404,13 @@
 	| mipsisa64r2-* | mipsisa64r2el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipsr5900-* | mipsr5900el-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
 	| nds32-* | nds32le-* | nds32be-* \
-	| nios-* | nios2-* \
+	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
 	| orion-* \
@@ -788,7 +786,7 @@
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-	microblaze)
+	microblaze*)
 		basic_machine=microblaze-xilinx
 		;;
 	mingw64)
@@ -1023,7 +1021,11 @@
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
-	rdos)
+	rdos | rdos64)
+		basic_machine=x86_64-pc
+		os=-rdos
+		;;
+	rdos32)
 		basic_machine=i386-pc
 		os=-rdos
 		;;
@@ -1350,7 +1352,7 @@
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-	      | -sym* | -kopensolaris* \
+	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
@@ -1496,9 +1498,6 @@
 	-aros*)
 		os=-aros
 		;;
-	-kaos*)
-		os=-kaos
-		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
@@ -1588,6 +1587,9 @@
 		os=-elf
 		;;
 	mips*-*)
+		os=-elf
+		;;
+	or1k-*)
 		os=-elf
 		;;
 	or32-*)

Modified: fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan.c (original)
+++ fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan.c Thu Feb 28 00:02:44 2013
@@ -39,63 +39,78 @@
 
 #include "mpatan.h"
 
-void __mpsqrt(mp_no *, mp_no *, int);
-
 void
 SECTION
-__mpatan(mp_no *x, mp_no *y, int p) {
+__mpatan (mp_no *x, mp_no *y, int p)
+{
 
-  int i,m,n;
+  int i, m, n;
   double dx;
-  mp_no
-    mptwoim1 = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
-		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
-		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
+  mp_no mptwoim1 =
+  {
+    0,
+    {
+      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
+    }
+  };
 
-  mp_no mps,mpsm,mpt,mpt1,mpt2,mpt3;
+  mp_no mps, mpsm, mpt, mpt1, mpt2, mpt3;
 
-		      /* Choose m and initiate mptwoim1 */
-    if      (EX>0) m=7;
-    else if (EX<0) m=0;
-    else {
-      __mp_dbl(x,&dx,p);  dx=ABS(dx);
-      for (m=6; m>0; m--)
-	{if (dx>__atan_xm[m].d) break;}
+  /* Choose m and initiate mptwoim1.  */
+  if (EX > 0)
+    m = 7;
+  else if (EX < 0)
+    m = 0;
+  else
+    {
+      __mp_dbl (x, &dx, p);
+      dx = ABS (dx);
+      for (m = 6; m > 0; m--)
+	{
+	  if (dx > __atan_xm[m].d)
+	    break;
+	}
     }
-    mptwoim1.e = 1;
-    mptwoim1.d[0] = ONE;
+  mptwoim1.e = 1;
+  mptwoim1.d[0] = ONE;
 
-				 /* Reduce x m times */
-    __sqr(x,&mpsm,p);
-    if (m==0) __cpy(x,&mps,p);
-    else {
-      for (i=0; i<m; i++) {
-	__add(&mpone,&mpsm,&mpt1,p);
-	__mpsqrt(&mpt1,&mpt2,p);
-	__add(&mpt2,&mpt2,&mpt1,p);
-	__add(&mptwo,&mpsm,&mpt2,p);
-	__add(&mpt1,&mpt2,&mpt3,p);
-	__dvd(&mpsm,&mpt3,&mpt1,p);
-	__cpy(&mpt1,&mpsm,p);
-      }
-      __mpsqrt(&mpsm,&mps,p);    mps.d[0] = X[0];
+  /* Reduce x m times.  */
+  __sqr (x, &mpsm, p);
+  if (m == 0)
+    __cpy (x, &mps, p);
+  else
+    {
+      for (i = 0; i < m; i++)
+	{
+	  __add (&mpone, &mpsm, &mpt1, p);
+	  __mpsqrt (&mpt1, &mpt2, p);
+	  __add (&mpt2, &mpt2, &mpt1, p);
+	  __add (&mptwo, &mpsm, &mpt2, p);
+	  __add (&mpt1, &mpt2, &mpt3, p);
+	  __dvd (&mpsm, &mpt3, &mpt1, p);
+	  __cpy (&mpt1, &mpsm, p);
+	}
+      __mpsqrt (&mpsm, &mps, p);
+      mps.d[0] = X[0];
     }
 
-		    /* Evaluate a truncated power series for Atan(s) */
-    n=__atan_np[p];    mptwoim1.d[1] = __atan_twonm1[p].d;
-    __dvd(&mpsm,&mptwoim1,&mpt,p);
-    for (i=n-1; i>1; i--) {
+  /* Evaluate a truncated power series for Atan(s).  */
+  n = __atan_np[p];
+  mptwoim1.d[1] = __atan_twonm1[p].d;
+  __dvd (&mpsm, &mptwoim1, &mpt, p);
+  for (i = n - 1; i > 1; i--)
+    {
       mptwoim1.d[1] -= TWO;
-      __dvd(&mpsm,&mptwoim1,&mpt1,p);
-      __mul(&mpsm,&mpt,&mpt2,p);
-      __sub(&mpt1,&mpt2,&mpt,p);
+      __dvd (&mpsm, &mptwoim1, &mpt1, p);
+      __mul (&mpsm, &mpt, &mpt2, p);
+      __sub (&mpt1, &mpt2, &mpt, p);
     }
-    __mul(&mps,&mpt,&mpt1,p);
-    __sub(&mps,&mpt1,&mpt,p);
+  __mul (&mps, &mpt, &mpt1, p);
+  __sub (&mps, &mpt1, &mpt, p);
 
-			  /* Compute Atan(x) */
-    mptwoim1.d[1] = 1 << m;
-    __mul(&mptwoim1,&mpt,y,p);
-
-  return;
+  /* Compute Atan(x).  */
+  mptwoim1.d[1] = 1 << m;
+  __mul (&mptwoim1, &mpt, y, p);
 }

Modified: fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan2.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan2.c (original)
+++ fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpatan2.c Thu Feb 28 00:02:44 2013
@@ -32,37 +32,36 @@
 /*                                                                */
 /******************************************************************/
 
-
-
 #include "mpa.h"
 
 #ifndef SECTION
 # define SECTION
 #endif
 
-void __mpsqrt(mp_no *, mp_no *, int);
-void __mpatan(mp_no *, mp_no *, int);
-
-/* Multi-Precision Atan2(y,x) function subroutine, for p >= 4.    */
-/* y=0 is not permitted if x<=0. No error messages are given.     */
+/* Multi-Precision Atan2 (y, x) function subroutine, for p >= 4.
+   y = 0 is not permitted if x <= 0. No error messages are given.  */
 void
 SECTION
-__mpatan2(mp_no *y, mp_no *x, mp_no *z, int p) {
+__mpatan2 (mp_no *y, mp_no *x, mp_no *z, int p)
+{
+  mp_no mpt1, mpt2, mpt3;
 
-  mp_no mpt1,mpt2,mpt3;
-
-
-  if (X[0] <= ZERO) {
-    __dvd(x,y,&mpt1,p);          __mul(&mpt1,&mpt1,&mpt2,p);
-    if (mpt1.d[0] != ZERO)       mpt1.d[0] = ONE;
-    __add(&mpt2,&mpone,&mpt3,p); __mpsqrt(&mpt3,&mpt2,p);
-    __add(&mpt1,&mpt2,&mpt3,p);  mpt3.d[0]=Y[0];
-    __mpatan(&mpt3,&mpt1,p);     __add(&mpt1,&mpt1,z,p);
-  }
+  if (X[0] <= ZERO)
+    {
+      __dvd (x, y, &mpt1, p);
+      __mul (&mpt1, &mpt1, &mpt2, p);
+      if (mpt1.d[0] != ZERO)
+	mpt1.d[0] = ONE;
+      __add (&mpt2, &mpone, &mpt3, p);
+      __mpsqrt (&mpt3, &mpt2, p);
+      __add (&mpt1, &mpt2, &mpt3, p);
+      mpt3.d[0] = Y[0];
+      __mpatan (&mpt3, &mpt1, p);
+      __add (&mpt1, &mpt1, z, p);
+    }
   else
-  { __dvd(y,x,&mpt1,p);
-    __mpatan(&mpt1,z,p);
-  }
-
-  return;
+    {
+      __dvd (y, x, &mpt1, p);
+      __mpatan (&mpt1, z, p);
+    }
 }

Modified: fsf/trunk/libc/sysdeps/ieee754/dbl-64/mplog.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ieee754/dbl-64/mplog.c (original)
+++ fsf/trunk/libc/sysdeps/ieee754/dbl-64/mplog.c Thu Feb 28 00:02:44 2013
@@ -1,4 +1,3 @@
-
 /*
  * IBM Accurate Mathematical Library
  * written by International Business Machines Corp.
@@ -37,27 +36,30 @@
 #include "endian.h"
 #include "mpa.h"
 
-void __mpexp(mp_no *, mp_no *, int);
+void
+__mplog (mp_no *x, mp_no *y, int p)
+{
+  int i, m;
+  static const int mp[33] =
+    {
+      0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+      4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
+    };
+  mp_no mpt1, mpt2;
 
-void __mplog(mp_no *x, mp_no *y, int p) {
-  int i,m;
-  static const int mp[33] = {0,0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
-                             4,4,4,4,4,4,4,4,4,4,4,4,4,4};
-  mp_no mpt1,mpt2;
-
-  /* Choose m */
+  /* Choose m.  */
   m = mp[p];
 
-  /* Perform m newton iterations to solve for y: exp(y)-x=0.     */
-  /* The iterations formula is:  y(n+1)=y(n)+(x*exp(-y(n))-1).   */
-  __cpy(y,&mpt1,p);
-  for (i=0; i<m; i++) {
-    mpt1.d[0]=-mpt1.d[0];
-    __mpexp(&mpt1,&mpt2,p);
-    __mul(x,&mpt2,&mpt1,p);
-    __sub(&mpt1,&mpone,&mpt2,p);
-    __add(y,&mpt2,&mpt1,p);
-    __cpy(&mpt1,y,p);
-  }
-  return;
+  /* Perform m newton iterations to solve for y: exp(y) - x = 0.  The
+     iterations formula is:  y(n + 1) = y(n) + (x * exp(-y(n)) - 1).   */
+  __cpy (y, &mpt1, p);
+  for (i = 0; i < m; i++)
+    {
+      mpt1.d[0] = -mpt1.d[0];
+      __mpexp (&mpt1, &mpt2, p);
+      __mul (x, &mpt2, &mpt1, p);
+      __sub (&mpt1, &mpone, &mpt2, p);
+      __add (y, &mpt2, &mpt1, p);
+      __cpy (&mpt1, y, p);
+    }
 }

Modified: fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpsqrt.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpsqrt.c (original)
+++ fsf/trunk/libc/sysdeps/ieee754/dbl-64/mpsqrt.c Thu Feb 28 00:02:44 2013
@@ -45,33 +45,37 @@
 /* p as integer. Routine computes sqrt(*x) and stores result in *y          */
 /****************************************************************************/
 
-static double fastiroot(double);
+static double fastiroot (double);
 
 void
 SECTION
-__mpsqrt(mp_no *x, mp_no *y, int p) {
-  int i,m,ey;
-  double dx,dy;
-  static const mp_no
-    mphalf   = {0,{1.0,8388608.0 /* 2^23 */}},
-    mp3halfs = {1,{1.0,1.0,8388608.0 /* 2^23 */}};
-  mp_no mpxn,mpz,mpu,mpt1,mpt2;
+__mpsqrt (mp_no *x, mp_no *y, int p)
+{
+  int i, m, ey;
+  double dx, dy;
+  static const mp_no mphalf = {0, {1.0, 8388608.0 /* 2^23 */}};
+  static const mp_no mp3halfs = {1, {1.0, 1.0, 8388608.0 /* 2^23 */}};
+  mp_no mpxn, mpz, mpu, mpt1, mpt2;
 
-  ey=EX/2;     __cpy(x,&mpxn,p);    mpxn.e -= (ey+ey);
-  __mp_dbl(&mpxn,&dx,p);   dy=fastiroot(dx);    __dbl_mp(dy,&mpu,p);
-  __mul(&mpxn,&mphalf,&mpz,p);
+  ey = EX / 2;
+  __cpy (x, &mpxn, p);
+  mpxn.e -= (ey + ey);
+  __mp_dbl (&mpxn, &dx, p);
+  dy = fastiroot (dx);
+  __dbl_mp (dy, &mpu, p);
+  __mul (&mpxn, &mphalf, &mpz, p);
 
-  m=__mpsqrt_mp[p];
-  for (i=0; i<m; i++) {
-    __sqr(&mpu,&mpt1,p);
-    __mul(&mpt1,&mpz,&mpt2,p);
-    __sub(&mp3halfs,&mpt2,&mpt1,p);
-    __mul(&mpu,&mpt1,&mpt2,p);
-    __cpy(&mpt2,&mpu,p);
-  }
-  __mul(&mpxn,&mpu,y,p);  EY += ey;
-
-  return;
+  m = __mpsqrt_mp[p];
+  for (i = 0; i < m; i++)
+    {
+      __sqr (&mpu, &mpt1, p);
+      __mul (&mpt1, &mpz, &mpt2, p);
+      __sub (&mp3halfs, &mpt2, &mpt1, p);
+      __mul (&mpu, &mpt1, &mpt2, p);
+      __cpy (&mpt2, &mpu, p);
+    }
+  __mul (&mpxn, &mpu, y, p);
+  EY += ey;
 }
 
 /***********************************************************/
@@ -80,22 +84,28 @@
 /***********************************************************/
 static double
 SECTION
-fastiroot(double x) {
-  union {int i[2]; double d;} p,q;
-  double y,z, t;
+fastiroot (double x)
+{
+  union
+  {
+    int i[2];
+    double d;
+  } p, q;
+  double y, z, t;
   int n;
-  static const double c0 = 0.99674, c1 = -0.53380, c2 = 0.45472, c3 = -0.21553;
+  static const double c0 = 0.99674, c1 = -0.53380;
+  static const double c2 = 0.45472, c3 = -0.21553;
 
   p.d = x;
-  p.i[HIGH_HALF] = (p.i[HIGH_HALF] & 0x3FFFFFFF ) | 0x3FE00000 ;
+  p.i[HIGH_HALF] = (p.i[HIGH_HALF] & 0x3FFFFFFF) | 0x3FE00000;
   q.d = x;
   y = p.d;
-  z = y -1.0;
-  n = (q.i[HIGH_HALF] - p.i[HIGH_HALF])>>1;
-  z = ((c3*z + c2)*z + c1)*z + c0;            /* 2**-7         */
-  z = z*(1.5 - 0.5*y*z*z);                    /* 2**-14        */
-  p.d = z*(1.5 - 0.5*y*z*z);                  /* 2**-28        */
+  z = y - 1.0;
+  n = (q.i[HIGH_HALF] - p.i[HIGH_HALF]) >> 1;
+  z = ((c3 * z + c2) * z + c1) * z + c0;	/* 2**-7         */
+  z = z * (1.5 - 0.5 * y * z * z);		/* 2**-14        */
+  p.d = z * (1.5 - 0.5 * y * z * z);		/* 2**-28        */
   p.i[HIGH_HALF] -= n;
-  t = x*p.d;
-  return p.d*(1.5 - 0.5*p.d*t);
+  t = x * p.d;
+  return p.d * (1.5 - 0.5 * p.d * t);
 }

Modified: fsf/trunk/libc/sysdeps/ieee754/dbl-64/mptan.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ieee754/dbl-64/mptan.c (original)
+++ fsf/trunk/libc/sysdeps/ieee754/dbl-64/mptan.c Thu Feb 28 00:02:44 2013
@@ -40,23 +40,25 @@
 # define SECTION
 #endif
 
-int __mpranred(double, mp_no *, int);
-void __c32(mp_no *, mp_no *, mp_no *, int);
-
 void
 SECTION
-__mptan(double x, mp_no *mpy, int p) {
+__mptan (double x, mp_no *mpy, int p)
+{
 
   int n;
   mp_no mpw, mpc, mps;
 
-  n = __mpranred(x, &mpw, p) & 0x00000001; /* negative or positive result */
-  __c32(&mpw, &mpc, &mps, p);              /* computing sin(x) and cos(x) */
-  if (n)                     /* second or fourth quarter of unit circle */
-  { __dvd(&mpc,&mps,mpy,p);
-    mpy->d[0] *= MONE;
-  }                          /* tan is negative in this area */
-  else  __dvd(&mps,&mpc,mpy,p);
-
-  return;
+  /* Negative or positive result.  */
+  n = __mpranred (x, &mpw, p) & 0x00000001;
+  /* Computing sin(x) and cos(x).  */
+  __c32 (&mpw, &mpc, &mps, p);
+  /* Second or fourth quarter of unit circle.  */
+  if (n)
+    {
+      __dvd (&mpc, &mps, mpy, p);
+      mpy->d[0] *= MONE;
+    }
+  /* tan is negative in this area.  */
+  else
+    __dvd (&mps, &mpc, mpy, p);
 }

_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits