summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2013-09-17 17:58:15 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2013-09-17 17:58:15 +0200
commit63d872f3a7641da98fb96f368dfe0c05cef953c7 (patch)
tree090355841930c02b8193902e716c643c8383d8dd
parent84d0570146b7bc7bd85de24e3922cdc22ac141f8 (diff)
parentf7397b4ca4094a7101db10708cd0023a0b2506e8 (diff)
Merge branch 'master' of git+ssh://openadk.org/git/openadk
-rw-r--r--mk/package.mk2
-rw-r--r--mk/pkg-bottom.mk2
-rw-r--r--package/busybox/Makefile4
-rw-r--r--package/cfgfs/Makefile2
-rw-r--r--package/dropbear/Makefile2
-rw-r--r--package/gdb/Makefile8
-rw-r--r--package/gdb/patches/patch-gdb_common_gdb_thread_db_h2
-rw-r--r--package/gdb/patches/patch-gdb_common_linux-ptrace_h2
-rw-r--r--package/gdb/patches/patch-gdb_common_signals_c2
-rw-r--r--package/gdb/patches/patch-gdb_linux-nat_c2
-rw-r--r--package/gdb/src/gdb/sgidefs.h30
-rw-r--r--package/libqb/Makefile4
-rw-r--r--package/libqb/patches/patch-Makefile_in11
-rw-r--r--package/musl/Config.in.manual1
-rw-r--r--package/musl/Makefile6
-rw-r--r--package/rsync/Makefile5
-rw-r--r--package/strace/Makefile3
-rw-r--r--package/strace/patches/patch-signal_c12
-rw-r--r--package/strace/src/sgidefs.h30
-rw-r--r--target/config/Config.in7
-rw-r--r--target/mips/sys-available/qemu-mips1
-rw-r--r--target/ppc/target.mk2
-rw-r--r--toolchain/binutils/Makefile.inc4
-rw-r--r--toolchain/binutils/patches/2.22/musl-cross.patch81
-rw-r--r--toolchain/binutils/patches/2.22/musl.patch20
-rw-r--r--toolchain/binutils/patches/2.23.2/musl-cross.patch19
-rw-r--r--toolchain/eglibc/Makefile.inc4
-rw-r--r--toolchain/eglibc/patches/eglibc-cross.patch20
-rw-r--r--toolchain/gcc/Makefile4
-rw-r--r--toolchain/gcc/patches/4.7.3/musl-cross.patch861
-rw-r--r--toolchain/gcc/patches/4.7.3/musl-ppc.patch155
-rw-r--r--toolchain/gcc/patches/4.7.3/musl.patch360
-rw-r--r--toolchain/glibc/Makefile.inc4
-rw-r--r--toolchain/glibc/patches/glibc-cross.patch22
-rw-r--r--toolchain/kernel-headers/patches/3.9.11/sortext.patch4947
-rw-r--r--toolchain/musl/Makefile15
-rw-r--r--toolchain/musl/patches/0.9.13/libgcc.patch12
-rw-r--r--toolchain/musl/patches/0.9.13/musl-git.patch8837
38 files changed, 15044 insertions, 461 deletions
diff --git a/mk/package.mk b/mk/package.mk
index e69b7866f..9e880d5ef 100644
--- a/mk/package.mk
+++ b/mk/package.mk
@@ -196,7 +196,7 @@ endif
'ramdisk location:' >&2; \
echo "$$$$x" | sed 's/^/- /' >&2; \
fi; \
- if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "eglibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libgcc" -a "${PKG_NAME}" != "libthread-db" ];then \
+ if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "eglibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libgcc" -a "${PKG_NAME}" != "libthread-db" -a "${PKG_NAME}" != "musl" ];then \
find lib \( -name lib\*.so\* -o -name lib\*.a \) \
-exec echo 'WARNING: $${IPKG_$(1)} installs files in /lib -' \
' fix this!' >&2 \; -quit 2>/dev/null; fi; \
diff --git a/mk/pkg-bottom.mk b/mk/pkg-bottom.mk
index 6704c1abc..9f92f9349 100644
--- a/mk/pkg-bottom.mk
+++ b/mk/pkg-bottom.mk
@@ -167,7 +167,7 @@ ifeq (,$(filter noremove,${PKG_OPTS}))
endif
@rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
@-cd ${WRKINST}; \
- if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "eglibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libgcc" -a "${PKG_NAME}" != "libthread-db" ];then \
+ if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "eglibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libgcc" -a "${PKG_NAME}" != "libthread-db" -a "${PKG_NAME}" != "musl" ];then \
find lib \( -name lib\*.so\* -o -name lib\*.a \) \
-exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
' fix this!' >&2 \; -quit 2>/dev/null; fi;\
diff --git a/package/busybox/Makefile b/package/busybox/Makefile
index 4d751a2b1..4a8e8ea68 100644
--- a/package/busybox/Makefile
+++ b/package/busybox/Makefile
@@ -38,12 +38,8 @@ BB_MAKE_FLAGS:= V=1 IPKG_ARCH="${CPU_ARCH}" ARCH="${ARCH}" GCC_HONOUR_COPTS=s \
HOSTCC="${CC_FOR_BUILD}" HOSTCFLAGS="$(CFLAGS_FOR_BUILD)" \
-C ${WRKBUILD}
ifneq (${ADK_NATIVE},y)
-ifeq ($(ADK_TARGET_LIB_STATIC_LIBGCC),y)
BB_MAKE_FLAGS+= CROSS_COMPILE="$(TARGET_CROSS)" EXTRA_LDFLAGS='-static-libgcc'
else
-BB_MAKE_FLAGS+= CROSS_COMPILE="$(TARGET_CROSS)"
-endif
-else
BB_MAKE_FLAGS+= EXTRA_LDFLAGS="-static-libgcc"
endif
diff --git a/package/cfgfs/Makefile b/package/cfgfs/Makefile
index 5c902fc1e..159bd229b 100644
--- a/package/cfgfs/Makefile
+++ b/package/cfgfs/Makefile
@@ -26,9 +26,7 @@ $(eval $(call PKG_template,CFGFS,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG
CONFIG_STYLE:= manual
INSTALL_STYLE:= manual
-ifeq ($(ADK_TARGET_LIB_STATIC_LIBGCC),y)
TARGET_LDFLAGS+= -static-libgcc
-endif
do-install:
${INSTALL_DIR} ${IDIR_CFGFS}/sbin
diff --git a/package/dropbear/Makefile b/package/dropbear/Makefile
index b3756a8d9..a7c2356e0 100644
--- a/package/dropbear/Makefile
+++ b/package/dropbear/Makefile
@@ -32,9 +32,7 @@ ifeq ($(ADK_STATIC),y)
TARGET_LDFLAGS+= -static
endif
-ifeq ($(ADK_TARGET_LIB_STATIC_LIBGCC),y)
TARGET_LDFLAGS+= -static-libgcc
-endif
BUILD_STYLE:= manual
INSTALL_STYLE:= manual
CONFIGURE_ARGS+= --disable-pam \
diff --git a/package/gdb/Makefile b/package/gdb/Makefile
index 85a40b195..3670f731e 100644
--- a/package/gdb/Makefile
+++ b/package/gdb/Makefile
@@ -6,7 +6,7 @@ include ${TOPDIR}/toolchain/gdb/Makefile.inc
PKG_DESCR:= GNU debugger
PKG_SECTION:= debug
-PKG_DEPENDS:= libthread-db libncurses libiconv libexpat
+PKG_DEPENDS:= libthread-db libncurses libiconv libexpat libgcc
PKG_BUILDDEP:= ncurses readline libiconv expat
PKG_NOPARALLEL:= 1
@@ -18,6 +18,7 @@ $(eval $(call PKG_template,GDB,gdb,${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},
ifeq ($(ADK_STATIC),y)
TARGET_CFLAGS+= -static
+CONFIGURE_ARGS+= --enable-static
endif
TARGET_CFLAGS:= $(filter-out -flto,$(TARGET_CFLAGS))
@@ -27,14 +28,11 @@ CONFIGURE_ARGS+= --without-uiout --enable-gdbmi \
--without-included-gettext --disable-sim \
--with-curses --disable-werror \
--disable-gdbserver \
- --enable-static --without-python
+ --without-python
XAKE_FLAGS+= LDFLAGS='${TARGET_LDFLAGS}'
# disable honour cflags stuff
XAKE_FLAGS+= GCC_HONOUR_COPTS:=s
-pre-build:
- @-rm $(STAGING_TARGET_DIR)/lib/libiberty.a $(STAGING_TARGET_DIR)/usr/lib/libiberty.a
-
post-install:
${INSTALL_DIR} ${IDIR_GDB}/usr/bin
${INSTALL_BIN} ${WRKINST}/usr/bin/gdb ${IDIR_GDB}/usr/bin/
diff --git a/package/gdb/patches/patch-gdb_common_gdb_thread_db_h b/package/gdb/patches/patch-gdb_common_gdb_thread_db_h
index 12ab8ebaf..ddcea422f 100644
--- a/package/gdb/patches/patch-gdb_common_gdb_thread_db_h
+++ b/package/gdb/patches/patch-gdb_common_gdb_thread_db_h
@@ -1,3 +1,5 @@
+* added from https://github.com/rofl0r/sabotage
+
--- gdb-7.6.orig/gdb/common/gdb_thread_db.h 2013-01-01 07:32:54.000000000 +0100
+++ gdb-7.6/gdb/common/gdb_thread_db.h 2013-08-13 16:37:40.000000000 +0200
@@ -1,17 +1,6 @@
diff --git a/package/gdb/patches/patch-gdb_common_linux-ptrace_h b/package/gdb/patches/patch-gdb_common_linux-ptrace_h
index cc6556d0a..51e2c3637 100644
--- a/package/gdb/patches/patch-gdb_common_linux-ptrace_h
+++ b/package/gdb/patches/patch-gdb_common_linux-ptrace_h
@@ -1,3 +1,5 @@
+* added from https://github.com/rofl0r/sabotage
+
--- gdb-7.6.orig/gdb/common/linux-ptrace.h 2013-01-01 07:32:54.000000000 +0100
+++ gdb-7.6/gdb/common/linux-ptrace.h 2013-08-13 17:10:13.000000000 +0200
@@ -20,6 +20,7 @@
diff --git a/package/gdb/patches/patch-gdb_common_signals_c b/package/gdb/patches/patch-gdb_common_signals_c
index 666e37430..114f5b867 100644
--- a/package/gdb/patches/patch-gdb_common_signals_c
+++ b/package/gdb/patches/patch-gdb_common_signals_c
@@ -1,3 +1,5 @@
+* added from https://github.com/rofl0r/sabotage
+
--- gdb-7.5.orig/gdb/common/signals.c 2012-05-24 18:51:37.000000000 +0200
+++ gdb-7.5/gdb/common/signals.c 2012-10-01 14:44:23.000000000 +0200
@@ -346,6 +346,8 @@ gdb_signal_from_host (int hostsig)
diff --git a/package/gdb/patches/patch-gdb_linux-nat_c b/package/gdb/patches/patch-gdb_linux-nat_c
index 50ba9bf6c..9ba7254ca 100644
--- a/package/gdb/patches/patch-gdb_linux-nat_c
+++ b/package/gdb/patches/patch-gdb_linux-nat_c
@@ -1,3 +1,5 @@
+* added from https://github.com/rofl0r/sabotage
+
--- gdb-7.6.orig/gdb/linux-nat.c 2013-02-13 15:59:49.000000000 +0100
+++ gdb-7.6/gdb/linux-nat.c 2013-08-13 17:01:09.000000000 +0200
@@ -79,6 +79,14 @@
diff --git a/package/gdb/src/gdb/sgidefs.h b/package/gdb/src/gdb/sgidefs.h
new file mode 100644
index 000000000..a6d250ab7
--- /dev/null
+++ b/package/gdb/src/gdb/sgidefs.h
@@ -0,0 +1,30 @@
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H
+
+/* MIPS ABI crap that GLIBC puts into /include
+by default, and GDB depends on it happily. */
+
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+#define _MIPS_ISA_MIPS32 6
+#define _MIPS_ISA_MIPS64 7
+
+#ifndef _ABIO32
+#define _ABIO32 1
+#endif
+#define _MIPS_SIM_ABI32 _ABIO32
+
+#ifndef _ABIN32
+#define _ABIN32 2
+#endif
+#define _MIPS_SIM_NABI32 _ABIN32
+
+#ifndef _ABI64
+#define _ABI64 3
+#endif
+#define _MIPS_SIM_ABI64 _ABI64
+
+#endif
diff --git a/package/libqb/Makefile b/package/libqb/Makefile
index 6a3ddb3f2..a2d897bcd 100644
--- a/package/libqb/Makefile
+++ b/package/libqb/Makefile
@@ -4,9 +4,9 @@
include $(TOPDIR)/rules.mk
PKG_NAME:= libqb
-PKG_VERSION:= 0.14.1
+PKG_VERSION:= 0.16.0
PKG_RELEASE:= 1
-PKG_MD5SUM:= c144a5e0cd5b69c8d46a051646609f11
+PKG_MD5SUM:= 88a256ce5217efa420598ade393879ff
PKG_DESCR:= high performance client server reusable features
PKG_SECTION:= libs
PKG_URL:= https://github.com/asalkeld/libqb/wiki#wiki-Releases
diff --git a/package/libqb/patches/patch-Makefile_in b/package/libqb/patches/patch-Makefile_in
new file mode 100644
index 000000000..f73094833
--- /dev/null
+++ b/package/libqb/patches/patch-Makefile_in
@@ -0,0 +1,11 @@
+--- libqb-0.16.0.orig/Makefile.in 2013-07-25 20:16:10.000000000 +0200
++++ libqb-0.16.0/Makefile.in 2013-09-09 06:26:09.718825909 +0200
+@@ -352,7 +352,7 @@ MAINTAINERCLEANFILES = Makefile.in acloc
+
+ ACLOCAL_AMFLAGS = -I m4
+ dist_doc_DATA = COPYING INSTALL README.markdown
+-SUBDIRS = include lib docs tools tests examples
++SUBDIRS = include lib docs tools
+ RPMBUILDOPTS = --define "_sourcedir $(abs_builddir)" \
+ --define "_specdir $(abs_builddir)" \
+ --define "_builddir $(abs_builddir)" \
diff --git a/package/musl/Config.in.manual b/package/musl/Config.in.manual
index a3881c1e8..19f590e61 100644
--- a/package/musl/Config.in.manual
+++ b/package/musl/Config.in.manual
@@ -4,7 +4,6 @@ config ADK_PACKAGE_MUSL
default y if ADK_TARGET_LIB_MUSL && !ADK_TOOLCHAIN_ONLY
default n
depends on ADK_TARGET_LIB_MUSL
- select ADK_PACKAGE_LIBGCC
help
Embedded C library.
diff --git a/package/musl/Makefile b/package/musl/Makefile
index e7526572f..86e75cc26 100644
--- a/package/musl/Makefile
+++ b/package/musl/Makefile
@@ -33,6 +33,12 @@ endif
ifeq ($(CPU_ARCH),i486)
MARCH:= i386
endif
+ifeq ($(CPU_ARCH),mipsel)
+MARCH:= mips
+endif
+ifeq ($(CPU_ARCH),ppc)
+MARCH:= powerpc
+endif
# do nothing, musl is already build in toolchain directory
do-install:
diff --git a/package/rsync/Makefile b/package/rsync/Makefile
index 63451f041..054a5d641 100644
--- a/package/rsync/Makefile
+++ b/package/rsync/Makefile
@@ -18,6 +18,11 @@ include ${TOPDIR}/mk/package.mk
$(eval $(call PKG_template,RSYNC,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
+ifeq ($(ADK_STATIC),y)
+TARGET_CFLAGS+= -static
+TARGET_LDFLAGS+= -static
+endif
+
post-install:
${INSTALL_DIR} ${IDIR_RSYNC}/usr/bin
${INSTALL_BIN} ${WRKINST}/usr/bin/rsync ${IDIR_RSYNC}/usr/bin
diff --git a/package/strace/Makefile b/package/strace/Makefile
index 98647b555..c6880faa4 100644
--- a/package/strace/Makefile
+++ b/package/strace/Makefile
@@ -5,10 +5,11 @@ include ${TOPDIR}/rules.mk
PKG_NAME:= strace
PKG_VERSION:= 4.8
-PKG_RELEASE:= 1
+PKG_RELEASE:= 2
PKG_MD5SUM:= c575ef43829586801f514fd91bfe7575
PKG_DESCR:= System call trace program
PKG_SECTION:= debug
+PKG_DEPENDS:= libgcc
PKG_SITES:= ${MASTER_SITE_SOURCEFORGE:=strace/}
DISTFILES:= ${PKG_NAME}-${PKG_VERSION}.tar.xz
diff --git a/package/strace/patches/patch-signal_c b/package/strace/patches/patch-signal_c
index 041f7177b..27e3d0d77 100644
--- a/package/strace/patches/patch-signal_c
+++ b/package/strace/patches/patch-signal_c
@@ -1,6 +1,14 @@
--- strace-4.8.orig/signal.c 2013-05-23 15:41:23.000000000 +0200
-+++ strace-4.8/signal.c 2013-08-14 08:50:16.000000000 +0200
-@@ -815,7 +815,7 @@ sys_sigreturn(struct tcb *tcp)
++++ strace-4.8/signal.c 2013-09-13 16:20:20.000000000 +0200
+@@ -61,6 +61,7 @@
+ #endif
+
+ #if defined(SPARC) || defined(SPARC64) || defined(MIPS)
++#include <asm/ptrace.h>
+ typedef struct {
+ struct pt_regs si_regs;
+ int si_mask;
+@@ -815,7 +816,7 @@ sys_sigreturn(struct tcb *tcp)
{
#if defined(ARM)
if (entering(tcp)) {
diff --git a/package/strace/src/sgidefs.h b/package/strace/src/sgidefs.h
new file mode 100644
index 000000000..a6d250ab7
--- /dev/null
+++ b/package/strace/src/sgidefs.h
@@ -0,0 +1,30 @@
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H
+
+/* MIPS ABI crap that GLIBC puts into /include
+by default, and GDB depends on it happily. */
+
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+#define _MIPS_ISA_MIPS32 6
+#define _MIPS_ISA_MIPS64 7
+
+#ifndef _ABIO32
+#define _ABIO32 1
+#endif
+#define _MIPS_SIM_ABI32 _ABIO32
+
+#ifndef _ABIN32
+#define _ABIN32 2
+#endif
+#define _MIPS_SIM_NABI32 _ABIN32
+
+#ifndef _ABI64
+#define _ABI64 3
+#endif
+#define _MIPS_SIM_ABI64 _ABI64
+
+#endif
diff --git a/target/config/Config.in b/target/config/Config.in
index fc5c8d94a..a14ef5b7a 100644
--- a/target/config/Config.in
+++ b/target/config/Config.in
@@ -564,9 +564,6 @@ config ADK_musl
config ADK_libc
boolean
-config ADK_TARGET_LIB_STATIC_LIBGCC
- boolean
-
config ADK_TARGET_LIBC
string
default "uclibc" if ADK_uclibc
@@ -588,7 +585,6 @@ config ADK_TARGET_LIB_UCLIBC
!ADK_LINUX_SPARC64 && \
!ADK_LINUX_PPC64 && \
!ADK_LINUX_NATIVE
- select ADK_TARGET_LIB_STATIC_LIBGCC
help
http://uclibc.org
@@ -609,7 +605,6 @@ config ADK_TARGET_LIB_EGLIBC
ADK_LINUX_SPARC64 || \
ADK_LINUX_X86 || \
ADK_LINUX_X86_64
- select ADK_TARGET_LIB_STATIC_LIBGCC
help
http://www.eglibc.org
@@ -630,7 +625,6 @@ config ADK_TARGET_LIB_GLIBC
ADK_LINUX_SPARC64 || \
ADK_LINUX_X86 || \
ADK_LINUX_X86_64
- select ADK_TARGET_LIB_STATIC_LIBGCC
help
http://www.gnu.org/libc
@@ -652,7 +646,6 @@ config ADK_TARGET_LIB_LIBC
prompt "Native C library"
boolean
select ADK_libc
- select ADK_TARGET_LIB_STATIC_LIBGCC
depends on ADK_LINUX_NATIVE
endchoice
diff --git a/target/mips/sys-available/qemu-mips b/target/mips/sys-available/qemu-mips
index 59d31d38c..d806d9c78 100644
--- a/target/mips/sys-available/qemu-mips
+++ b/target/mips/sys-available/qemu-mips
@@ -5,6 +5,7 @@ config ADK_TARGET_SYSTEM_QEMU_MIPS
select ADK_qemu_mips
select ADK_KERNEL_MIPS_MALTA
select ADK_KERNEL_CPU_BIG_ENDIAN
+ select ADK_KERNEL_PAGE_SIZE_4KB
select ADK_HARDWARE_QEMU
select ADK_TARGET_WITH_VGA
select ADK_TARGET_WITH_INPUT
diff --git a/target/ppc/target.mk b/target/ppc/target.mk
index 3654b0d35..bd6624fe7 100644
--- a/target/ppc/target.mk
+++ b/target/ppc/target.mk
@@ -2,4 +2,4 @@ include $(TOPDIR)/mk/kernel-ver.mk
ARCH:= powerpc
CPU_ARCH:= ppc
TARGET_OPTIMIZATION:= -Os -pipe
-TARGET_CFLAGS_ARCH:= $(ADK_TARGET_CFLAGS)
+TARGET_CFLAGS_ARCH:= $(ADK_TARGET_CFLAGS) -Wl,--secure-plt
diff --git a/toolchain/binutils/Makefile.inc b/toolchain/binutils/Makefile.inc
index 4448a7b51..06b5d3105 100644
--- a/toolchain/binutils/Makefile.inc
+++ b/toolchain/binutils/Makefile.inc
@@ -7,8 +7,8 @@ ifeq ($(ADK_LINUX_AVR32),y)
PKG_VERSION:= 2.21
PKG_MD5SUM:= c84c5acc9d266f1a7044b51c85a823f5
else
-PKG_VERSION:= 2.22
-PKG_MD5SUM:= ee0f10756c84979622b992a4a61ea3f5
+PKG_VERSION:= 2.23.2
+PKG_MD5SUM:= 4f8fa651e35ef262edc01d60fb45702e
endif
PKG_RELEASE:= 1
diff --git a/toolchain/binutils/patches/2.22/musl-cross.patch b/toolchain/binutils/patches/2.22/musl-cross.patch
new file mode 100644
index 000000000..47af7bbb8
--- /dev/null
+++ b/toolchain/binutils/patches/2.22/musl-cross.patch
@@ -0,0 +1,81 @@
+diff -Nur binutils-2.22.orig/bfd/elf32-ppc.c binutils-2.22/bfd/elf32-ppc.c
+--- binutils-2.22.orig/bfd/elf32-ppc.c 2011-11-21 10:29:21.000000000 +0100
++++ binutils-2.22/bfd/elf32-ppc.c 2013-09-14 12:51:24.000000000 +0200
+@@ -2987,10 +2987,6 @@
+ edir->elf.needs_plt |= eind->elf.needs_plt;
+ edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed;
+
+- /* If we were called to copy over info for a weak sym, that's all. */
+- if (eind->elf.root.type != bfd_link_hash_indirect)
+- return;
+-
+ if (eind->dyn_relocs != NULL)
+ {
+ if (edir->dyn_relocs != NULL)
+@@ -3022,6 +3018,16 @@
+ eind->dyn_relocs = NULL;
+ }
+
++ /* If we were called to copy over info for a weak sym, that's all.
++ You might think dyn_relocs need not be copied over; After all,
++ both syms will be dynamic or both non-dynamic so we're just
++ moving reloc accounting around. However, ELIMINATE_COPY_RELOCS
++ code in ppc_elf_adjust_dynamic_symbol needs to check for
++ dyn_relocs in read-only sections, and it does so on what is the
++ DIR sym here. */
++ if (eind->elf.root.type != bfd_link_hash_indirect)
++ return;
++
+ /* Copy over the GOT refcount entries that we may have already seen to
+ the symbol which just became indirect. */
+ edir->elf.got.refcount += eind->elf.got.refcount;
+diff -Nur binutils-2.22.orig/bfd/elf64-ppc.c binutils-2.22/bfd/elf64-ppc.c
+--- binutils-2.22.orig/bfd/elf64-ppc.c 2011-11-21 10:29:24.000000000 +0100
++++ binutils-2.22/bfd/elf64-ppc.c 2013-09-14 12:51:24.000000000 +0200
+@@ -4435,10 +4435,6 @@
+ edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak;
+ edir->elf.needs_plt |= eind->elf.needs_plt;
+
+- /* If we were called to copy over info for a weak sym, that's all. */
+- if (eind->elf.root.type != bfd_link_hash_indirect)
+- return;
+-
+ /* Copy over any dynamic relocs we may have on the indirect sym. */
+ if (eind->dyn_relocs != NULL)
+ {
+@@ -4471,6 +4467,16 @@
+ eind->dyn_relocs = NULL;
+ }
+
++ /* If we were called to copy over info for a weak sym, that's all.
++ You might think dyn_relocs need not be copied over; After all,
++ both syms will be dynamic or both non-dynamic so we're just
++ moving reloc accounting around. However, ELIMINATE_COPY_RELOCS
++ code in ppc64_elf_adjust_dynamic_symbol needs to check for
++ dyn_relocs in read-only sections, and it does so on what is the
++ DIR sym here. */
++ if (eind->elf.root.type != bfd_link_hash_indirect)
++ return;
++
+ /* Copy over got entries that we may have already seen to the
+ symbol which just became indirect. */
+ if (eind->elf.got.glist != NULL)
+diff -Nur binutils-2.22.orig/config.sub binutils-2.22/config.sub
+--- binutils-2.22.orig/config.sub 2011-06-06 12:36:06.000000000 +0200
++++ binutils-2.22/config.sub 2013-09-14 12:51:24.000000000 +0200
+@@ -125,6 +125,7 @@
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
++ linux-musl* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+@@ -1335,6 +1336,7 @@
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-uclibc* \
++ | -linux-musl* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/toolchain/binutils/patches/2.22/musl.patch b/toolchain/binutils/patches/2.22/musl.patch
deleted file mode 100644
index 4ea53c18f..000000000
--- a/toolchain/binutils/patches/2.22/musl.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff -Nur binutils-2.22.orig/config.sub binutils-2.22/config.sub
---- binutils-2.22.orig/config.sub 2011-06-06 12:36:06.000000000 +0200
-+++ binutils-2.22/config.sub 2013-08-11 14:40:22.308115171 +0200
-@@ -126,6 +126,7 @@
- case $maybe_os in
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-+ linux-musl* | \
- knetbsd*-gnu* | netbsd*-gnu* | \
- kopensolaris*-gnu* | \
- storm-chaos* | os2-emx* | rtmk-nova*)
-@@ -1334,7 +1335,7 @@
- | -chorusos* | -chorusrdb* | -cegcc* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-android* \
-- | -linux-newlib* | -linux-uclibc* \
-+ | -linux-newlib* | -linux-uclibc* | -linux-musl* \
- | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/toolchain/binutils/patches/2.23.2/musl-cross.patch b/toolchain/binutils/patches/2.23.2/musl-cross.patch
new file mode 100644
index 000000000..c1a4fbfec
--- /dev/null
+++ b/toolchain/binutils/patches/2.23.2/musl-cross.patch
@@ -0,0 +1,19 @@
+diff -Nur binutils-2.23.2.orig/config.sub binutils-2.23.2/config.sub
+--- binutils-2.23.2.orig/config.sub 2012-04-25 17:53:25.000000000 +0200
++++ binutils-2.23.2/config.sub 2013-09-15 15:10:00.000000000 +0200
+@@ -123,6 +123,7 @@
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
++ linux-musl* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+@@ -1361,6 +1362,7 @@
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-uclibc* \
++ | -linux-musl* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
diff --git a/toolchain/eglibc/Makefile.inc b/toolchain/eglibc/Makefile.inc
index 7fc25305c..e2aec51aa 100644
--- a/toolchain/eglibc/Makefile.inc
+++ b/toolchain/eglibc/Makefile.inc
@@ -2,9 +2,9 @@
# material, please see the LICENCE file in the top-level directory.
PKG_NAME:= eglibc
-PKG_VERSION:= 2.17
+PKG_VERSION:= 2.18
PKG_RELEASE:= 1
-PKG_MD5SUM:= 7bbee592be7d7fcacdc9dda931db9bec
+PKG_MD5SUM:= 2e4aad1b953daa997debe48fe10862cc
PKG_SITES:= http://openadk.org/distfiles/
EGLIBC_CONFOPTS:= --build=$(GNU_HOST_NAME) \
--without-cvs \
diff --git a/toolchain/eglibc/patches/eglibc-cross.patch b/toolchain/eglibc/patches/eglibc-cross.patch
index b77801f37..893345f2b 100644
--- a/toolchain/eglibc/patches/eglibc-cross.patch
+++ b/toolchain/eglibc/patches/eglibc-cross.patch
@@ -1,6 +1,6 @@
-diff -Nur eglibc-2.16.orig/libc/sunrpc/rpc/types.h eglibc-2.16/libc/sunrpc/rpc/types.h
---- eglibc-2.16.orig/libc/sunrpc/rpc/types.h 2012-07-31 09:00:24.000000000 +0200
-+++ eglibc-2.16/libc/sunrpc/rpc/types.h 2012-07-31 10:08:35.000000000 +0200
+diff -Nur eglibc-2.18.orig/libc/sunrpc/rpc/types.h eglibc-2.18/libc/sunrpc/rpc/types.h
+--- eglibc-2.18.orig/libc/sunrpc/rpc/types.h 2013-09-13 10:20:22.000000000 +0200
++++ eglibc-2.18/libc/sunrpc/rpc/types.h 2013-09-13 10:49:06.000000000 +0200
@@ -69,19 +69,25 @@
#include <sys/types.h>
#endif
@@ -39,9 +39,9 @@ diff -Nur eglibc-2.16.orig/libc/sunrpc/rpc/types.h eglibc-2.16/libc/sunrpc/rpc/t
# define __daddr_t_defined
#endif
-diff -Nur eglibc-2.16.orig/libc/sunrpc/rpc_main.c eglibc-2.16/libc/sunrpc/rpc_main.c
---- eglibc-2.16.orig/libc/sunrpc/rpc_main.c 2012-07-31 09:00:24.000000000 +0200
-+++ eglibc-2.16/libc/sunrpc/rpc_main.c 2012-07-31 09:22:22.000000000 +0200
+diff -Nur eglibc-2.18.orig/libc/sunrpc/rpc_main.c eglibc-2.18/libc/sunrpc/rpc_main.c
+--- eglibc-2.18.orig/libc/sunrpc/rpc_main.c 2013-09-13 10:20:22.000000000 +0200
++++ eglibc-2.18/libc/sunrpc/rpc_main.c 2013-09-13 10:49:34.000000000 +0200
@@ -38,7 +38,11 @@
#include <stdio.h>
#include <string.h>
@@ -51,9 +51,9 @@ diff -Nur eglibc-2.16.orig/libc/sunrpc/rpc_main.c eglibc-2.16/libc/sunrpc/rpc_ma
+#else
#include <libintl.h>
+#endif
+ #include <locale.h>
#include <ctype.h>
#include <sys/types.h>
- #include <sys/param.h>
@@ -958,10 +962,12 @@
abort ();
temp = rindex (cmd->infile, '.');
@@ -70,9 +70,9 @@ diff -Nur eglibc-2.16.orig/libc/sunrpc/rpc_main.c eglibc-2.16/libc/sunrpc/rpc_ma
}
else
-diff -Nur eglibc-2.16.orig/libc/sunrpc/rpc_scan.c eglibc-2.16/libc/sunrpc/rpc_scan.c
---- eglibc-2.16.orig/libc/sunrpc/rpc_scan.c 2012-07-31 09:00:24.000000000 +0200
-+++ eglibc-2.16/libc/sunrpc/rpc_scan.c 2012-07-31 09:22:22.000000000 +0200
+diff -Nur eglibc-2.18.orig/libc/sunrpc/rpc_scan.c eglibc-2.18/libc/sunrpc/rpc_scan.c
+--- eglibc-2.18.orig/libc/sunrpc/rpc_scan.c 2013-09-13 10:20:22.000000000 +0200
++++ eglibc-2.18/libc/sunrpc/rpc_scan.c 2013-09-13 10:49:06.000000000 +0200
@@ -37,7 +37,11 @@
#include <stdio.h>
#include <ctype.h>
diff --git a/toolchain/gcc/Makefile b/toolchain/gcc/Makefile
index b2ae0ea42..2bc954347 100644
--- a/toolchain/gcc/Makefile
+++ b/toolchain/gcc/Makefile
@@ -62,7 +62,7 @@ GCC_CONFOPTS+= --enable-tls
endif
ifeq ($(ARCH),powerpc)
-GCC_CONFOPTS+= --disable-target-optspace
+GCC_CONFOPTS+= --disable-target-optspace --with-long-double-64 --enable-secureplt
else
GCC_CONFOPTS+= --enable-target-optspace
endif
@@ -149,8 +149,6 @@ $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
$(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
- # -lgcc_eh workaround
- (cd $(STAGING_HOST_DIR)/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) && ln -sf libgcc.a libgcc_eh.a)
touch $@
$(GCC_BUILD_DIR_FINAL)/.configured:
diff --git a/toolchain/gcc/patches/4.7.3/musl-cross.patch b/toolchain/gcc/patches/4.7.3/musl-cross.patch
new file mode 100644
index 000000000..bbba746b0
--- /dev/null
+++ b/toolchain/gcc/patches/4.7.3/musl-cross.patch
@@ -0,0 +1,861 @@
+diff -Nur gcc-4.7.3.orig/config.sub gcc-4.7.3/config.sub
+--- gcc-4.7.3.orig/config.sub 2012-08-06 16:34:27.000000000 +0200
++++ gcc-4.7.3/config.sub 2013-09-16 15:39:42.000000000 +0200
+@@ -4,7 +4,7 @@
+ # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ # 2011 Free Software Foundation, Inc.
+
+-timestamp='2011-10-29'
++timestamp='2011-03-23'
+
+ # This file is (in principle) common to ALL GNU software.
+ # The presence of a machine in this file suggests that SOME GNU software
+@@ -125,6 +125,7 @@
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
++ linux-musl* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+@@ -251,17 +252,13 @@
+ | 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 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+- | epiphany \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+- | hexagon \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+- | le32 | le64 \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep | metag \
+@@ -295,7 +292,7 @@
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pyramid \
+- | rl78 | rx \
++ | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+@@ -304,7 +301,7 @@
+ | spu \
+ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+ | ubicom32 \
+- | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
++ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xstormy16 | xtensa \
+ | z8k | z80)
+@@ -361,7 +358,6 @@
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+- | be32-* | be64-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
+ | clipper-* | craynv-* | cydra-* \
+@@ -370,10 +366,8 @@
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+- | hexagon-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+- | le32-* | le64-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+@@ -407,7 +401,7 @@
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pyramid-* \
+- | rl78-* | romp-* | rs6000-* | rx-* \
++ | romp-* | rs6000-* | rx-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+@@ -415,11 +409,10 @@
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+ | tahoe-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+- | tile*-* \
++ | tile-* | tilegx-* \
+ | tron-* \
+ | ubicom32-* \
+- | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+- | vax-* \
++ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
+ | xstormy16-* | xtensa*-* \
+@@ -820,10 +813,6 @@
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+- nacl)
+- basic_machine=le32-unknown
+- os=-nacl
+- ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+@@ -1132,8 +1121,13 @@
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
++ # This must be matched before tile*.
++ tilegx*)
++ basic_machine=tilegx-unknown
++ os=-linux-gnu
++ ;;
+ tile*)
+- basic_machine=$basic_machine-unknown
++ basic_machine=tile-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+@@ -1346,6 +1340,7 @@
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-uclibc* \
++ | -linux-musl* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+diff -Nur gcc-4.7.3.orig/fixincludes/mkfixinc.sh gcc-4.7.3/fixincludes/mkfixinc.sh
+--- gcc-4.7.3.orig/fixincludes/mkfixinc.sh 2011-09-22 16:00:17.000000000 +0200
++++ gcc-4.7.3/fixincludes/mkfixinc.sh 2013-09-16 15:39:42.000000000 +0200
+@@ -20,7 +20,8 @@
+ powerpc-*-eabi* | \
+ powerpc-*-rtems* | \
+ powerpcle-*-eabisim* | \
+- powerpcle-*-eabi* )
++ powerpcle-*-eabi* | \
++ *-musl* )
+ # IF there is no include fixing,
+ # THEN create a no-op fixer and exit
+ (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
+diff -Nur gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h gcc-4.7.3/gcc/config/arm/linux-eabi.h
+--- gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h 2011-11-02 16:03:19.000000000 +0100
++++ gcc-4.7.3/gcc/config/arm/linux-eabi.h 2013-09-16 15:39:42.000000000 +0200
+@@ -64,6 +64,23 @@
+ #undef GLIBC_DYNAMIC_LINKER
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
+
++/* For ARM musl currently supports two dynamic linkers:
++ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
++ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI.
++ musl does not support the legacy OABI (i.e. broken) mode.
++ All the dynamic linkers live in /lib.
++ We default to soft-float, but this can be overridden by changing both
++ MUSL_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-musl-arm.so.1"
++#define MUSL_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-musl-armhf.so.1"
++#define MUSL_DYNAMIC_LINKER_DEFAULT MUSL_DYNAMIC_LINKER_SOFT_FLOAT
++
++#define MUSL_DYNAMIC_LINKER \
++ "%{mfloat-abi=hard:" MUSL_DYNAMIC_LINKER_HARD_FLOAT "} \
++ %{mfloat-abi=soft*:" MUSL_DYNAMIC_LINKER_SOFT_FLOAT "} \
++ %{!mfloat-abi=*:" MUSL_DYNAMIC_LINKER_DEFAULT "}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+diff -Nur gcc-4.7.3.orig/gcc/config/i386/linux64.h gcc-4.7.3/gcc/config/i386/linux64.h
+--- gcc-4.7.3.orig/gcc/config/i386/linux64.h 2011-07-07 17:38:34.000000000 +0200
++++ gcc-4.7.3/gcc/config/i386/linux64.h 2013-09-16 15:39:42.000000000 +0200
+@@ -31,3 +31,7 @@
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+ #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
++
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
+diff -Nur gcc-4.7.3.orig/gcc/config/i386/linux.h gcc-4.7.3/gcc/config/i386/linux.h
+--- gcc-4.7.3.orig/gcc/config/i386/linux.h 2011-06-03 20:30:39.000000000 +0200
++++ gcc-4.7.3/gcc/config/i386/linux.h 2013-09-16 15:39:42.000000000 +0200
+@@ -22,3 +22,4 @@
+
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+diff -Nur gcc-4.7.3.orig/gcc/config/linux.h gcc-4.7.3/gcc/config/linux.h
+--- gcc-4.7.3.orig/gcc/config/linux.h 2012-08-14 15:59:04.000000000 +0200
++++ gcc-4.7.3/gcc/config/linux.h 2013-09-16 15:39:42.000000000 +0200
+@@ -33,10 +33,12 @@
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -54,18 +56,21 @@
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -85,21 +90,21 @@
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+ #undef TARGET_C99_FUNCTIONS
+-#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
++#define TARGET_C99_FUNCTIONS (OPTION_GLIBC || OPTION_MUSL)
+
+ /* Whether we have sincos that follows the GNU extension. */
+ #undef TARGET_HAS_SINCOS
+@@ -108,3 +113,74 @@
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
++
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+diff -Nur gcc-4.7.3.orig/gcc/config/linux.opt gcc-4.7.3/gcc/config/linux.opt
+--- gcc-4.7.3.orig/gcc/config/linux.opt 2010-09-29 16:51:52.000000000 +0200
++++ gcc-4.7.3/gcc/config/linux.opt 2013-09-16 15:39:42.000000000 +0200
+@@ -30,3 +30,7 @@
+ muclibc
+ Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
++Use musl C library
+diff -Nur gcc-4.7.3.orig/gcc/config/mips/linux.h gcc-4.7.3/gcc/config/mips/linux.h
+--- gcc-4.7.3.orig/gcc/config/mips/linux.h 2011-07-19 20:00:27.000000000 +0200
++++ gcc-4.7.3/gcc/config/mips/linux.h 2013-09-16 15:39:43.000000000 +0200
+@@ -19,3 +19,5 @@
+ <http://www.gnu.org/licenses/>. */
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
++
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
+diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/linux64.h gcc-4.7.3/gcc/config/rs6000/linux64.h
+--- gcc-4.7.3.orig/gcc/config/rs6000/linux64.h 2012-03-12 17:16:51.000000000 +0100
++++ gcc-4.7.3/gcc/config/rs6000/linux64.h 2013-09-16 15:39:43.000000000 +0200
+@@ -362,17 +362,21 @@
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
+ #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
+ #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER32 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+
+ #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
+diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/secureplt.h gcc-4.7.3/gcc/config/rs6000/secureplt.h
+--- gcc-4.7.3.orig/gcc/config/rs6000/secureplt.h 2007-08-02 12:49:31.000000000 +0200
++++ gcc-4.7.3/gcc/config/rs6000/secureplt.h 2013-09-16 15:39:43.000000000 +0200
+@@ -18,3 +18,4 @@
+ <http://www.gnu.org/licenses/>. */
+
+ #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
+diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h gcc-4.7.3/gcc/config/rs6000/sysv4.h
+--- gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h 2012-04-30 19:39:01.000000000 +0200
++++ gcc-4.7.3/gcc/config/rs6000/sysv4.h 2013-09-16 15:39:43.000000000 +0200
+@@ -566,6 +566,9 @@
+ #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
+ #define CC1_SECURE_PLT_DEFAULT_SPEC ""
+ #endif
++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
++#define LINK_SECURE_PLT_DEFAULT_SPEC ""
++#endif
+
+ /* Pass -G xxx to the compiler and set correct endian mode. */
+ #define CC1_SPEC "%{G*} %(cc1_cpu) \
+@@ -626,7 +629,8 @@
+ %{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \
+ %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
+ %{mcall-i960-old: --oformat elf32-powerpcle} \
+- }}}}"
++ }}}} \
++%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
+
+ /* Any specific OS flags. */
+ #define LINK_OS_SPEC "\
+@@ -804,15 +808,18 @@
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+
+ #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+@@ -938,6 +945,7 @@
+ { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \
+ { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \
+ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
+ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
+ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
+ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
+diff -Nur gcc-4.7.3.orig/gcc/config.gcc gcc-4.7.3/gcc/config.gcc
+--- gcc-4.7.3.orig/gcc/config.gcc 2013-03-06 23:54:11.000000000 +0100
++++ gcc-4.7.3/gcc/config.gcc 2013-09-16 15:39:43.000000000 +0200
+@@ -522,7 +522,7 @@
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -625,6 +625,9 @@
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+@@ -2092,6 +2095,10 @@
+ powerpc*-*-linux*paired*)
+ tm_file="${tm_file} rs6000/750cl.h" ;;
+ esac
++ case ${target} in
++ *-linux*-musl*)
++ enable_secureplt=yes ;;
++ esac
+ if test x${enable_secureplt} = xyes; then
+ tm_file="rs6000/secureplt.h ${tm_file}"
+ fi
+diff -Nur gcc-4.7.3.orig/gcc/configure gcc-4.7.3/gcc/configure
+--- gcc-4.7.3.orig/gcc/configure 2013-02-06 16:23:55.000000000 +0100
++++ gcc-4.7.3/gcc/configure 2013-09-16 15:39:43.000000000 +0200
+@@ -26815,7 +26815,8 @@
+ gcc_cv_libc_provides_ssp=yes
+ fi
+ ;;
+- *-*-gnu*)
++ *-*-gnu* | \
++ *-linux-musl*)
+ # Avoid complicated tests (see
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+@@ -26902,6 +26903,9 @@
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+diff -Nur gcc-4.7.3.orig/gcc/configure.ac gcc-4.7.3/gcc/configure.ac
+--- gcc-4.7.3.orig/gcc/configure.ac 2013-02-06 16:23:55.000000000 +0100
++++ gcc-4.7.3/gcc/configure.ac 2013-09-16 15:39:43.000000000 +0200
+@@ -4692,7 +4692,8 @@
+ gcc_cv_libc_provides_ssp=yes
+ fi]
+ ;;
+- *-*-gnu*)
++ *-*-gnu* | \
++ *-linux-musl*)
+ # Avoid complicated tests (see
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+@@ -4762,6 +4763,9 @@
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+ GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+diff -Nur gcc-4.7.3.orig/gcc/ginclude/stddef.h gcc-4.7.3/gcc/ginclude/stddef.h
+--- gcc-4.7.3.orig/gcc/ginclude/stddef.h 2012-02-12 02:06:04.000000000 +0100
++++ gcc-4.7.3/gcc/ginclude/stddef.h 2013-09-16 15:39:43.000000000 +0200
+@@ -184,6 +184,7 @@
+ #ifndef _GCC_SIZE_T
+ #ifndef _SIZET_
+ #ifndef __size_t
++#ifndef __DEFINED_size_t /* musl */
+ #define __size_t__ /* BeOS */
+ #define __SIZE_T__ /* Cray Unicos/Mk */
+ #define _SIZE_T
+@@ -200,6 +201,7 @@
+ #define ___int_size_t_h
+ #define _GCC_SIZE_T
+ #define _SIZET_
++#define __DEFINED_size_t /* musl */
+ #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
+ || defined(__FreeBSD_kernel__)
+ /* __size_t is a typedef on FreeBSD 5, must not trash it. */
+@@ -215,6 +217,7 @@
+ typedef long ssize_t;
+ #endif /* __BEOS__ */
+ #endif /* !(defined (__GNUG__) && defined (size_t)) */
++#endif /* __DEFINED_size_t */
+ #endif /* __size_t */
+ #endif /* _SIZET_ */
+ #endif /* _GCC_SIZE_T */
+diff -Nur gcc-4.7.3.orig/libgcc/unwind-dw2-fde-dip.c gcc-4.7.3/libgcc/unwind-dw2-fde-dip.c
+--- gcc-4.7.3.orig/libgcc/unwind-dw2-fde-dip.c 2012-10-06 23:55:06.000000000 +0200
++++ gcc-4.7.3/libgcc/unwind-dw2-fde-dip.c 2013-09-16 15:39:43.000000000 +0200
+@@ -47,28 +47,13 @@
+ #include "unwind-compat.h"
+ #include "gthr.h"
+
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
+- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(__FreeBSD__) && __FreeBSD__ >= 7
+-# define ElfW __ElfN
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(__OpenBSD__)
+-# define ElfW(type) Elf_##type
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(TARGET_DL_ITERATE_PHDR) \
+- && defined(__sun__) && defined(__svr4__)
++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
+ # define USE_PT_GNU_EH_FRAME
++# ifdef __OpenBSD__
++# define ElfW(type) Elf_##typ
++# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
++# define ElfW __ElfN
++# endif
+ #endif
+
+ #if defined(USE_PT_GNU_EH_FRAME)
+diff -Nur gcc-4.7.3.orig/libgomp/config/posix/time.c gcc-4.7.3/libgomp/config/posix/time.c
+--- gcc-4.7.3.orig/libgomp/config/posix/time.c 2009-04-09 17:00:19.000000000 +0200
++++ gcc-4.7.3/libgomp/config/posix/time.c 2013-09-16 15:39:43.000000000 +0200
+@@ -28,6 +28,8 @@
+ The following implementation uses the most simple POSIX routines.
+ If present, POSIX 4 clocks should be used instead. */
+
++#define _POSIX_C_SOURCE 199309L /* for clocks */
++
+ #include "libgomp.h"
+ #include <unistd.h>
+ #if TIME_WITH_SYS_TIME
+diff -Nur gcc-4.7.3.orig/libitm/config/arm/hwcap.cc gcc-4.7.3/libitm/config/arm/hwcap.cc
+--- gcc-4.7.3.orig/libitm/config/arm/hwcap.cc 2011-12-15 04:24:05.000000000 +0100
++++ gcc-4.7.3/libitm/config/arm/hwcap.cc 2013-09-16 15:39:43.000000000 +0200
+@@ -40,7 +40,11 @@
+
+ #ifdef __linux__
+ #include <unistd.h>
++#ifdef __GLIBC__
+ #include <sys/fcntl.h>
++#else
++#include <fcntl.h>
++#endif
+ #include <elf.h>
+
+ static void __attribute__((constructor))
+diff -Nur gcc-4.7.3.orig/libitm/config/linux/x86/tls.h gcc-4.7.3/libitm/config/linux/x86/tls.h
+--- gcc-4.7.3.orig/libitm/config/linux/x86/tls.h 2011-11-08 12:13:41.000000000 +0100
++++ gcc-4.7.3/libitm/config/linux/x86/tls.h 2013-09-16 15:39:43.000000000 +0200
+@@ -25,16 +25,19 @@
+ #ifndef LIBITM_X86_TLS_H
+ #define LIBITM_X86_TLS_H 1
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ /* Use slots in the TCB head rather than __thread lookups.
+ GLIBC has reserved words 10 through 13 for TM. */
+ #define HAVE_ARCH_GTM_THREAD 1
+ #define HAVE_ARCH_GTM_THREAD_DISP 1
+ #endif
++#endif
+
+ #include "config/generic/tls.h"
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ namespace GTM HIDDEN {
+
+ #ifdef __x86_64__
+@@ -101,5 +104,6 @@
+
+ } // namespace GTM
+ #endif /* >= GLIBC 2.10 */
++#endif
+
+ #endif // LIBITM_X86_TLS_H
+diff -Nur gcc-4.7.3.orig/libssp/configure gcc-4.7.3/libssp/configure
+--- gcc-4.7.3.orig/libssp/configure 2012-08-06 16:34:27.000000000 +0200
++++ gcc-4.7.3/libssp/configure 2013-09-16 15:39:43.000000000 +0200
+@@ -626,6 +626,8 @@
+ ssp_have_usable_vsnprintf
+ EGREP
+ GREP
++LIBSSP_IN_LIBC_FALSE
++LIBSSP_IN_LIBC_TRUE
+ LIBSSP_USE_SYMVER_SUN_FALSE
+ LIBSSP_USE_SYMVER_SUN_TRUE
+ LIBSSP_USE_SYMVER_GNU_FALSE
+@@ -735,6 +737,7 @@
+ enable_multilib
+ enable_dependency_tracking
+ enable_symvers
++enable_ssp_in_libc
+ enable_shared
+ enable_static
+ with_pic
+@@ -1374,6 +1377,7 @@
+ --disable-dependency-tracking speeds up one-time build
+ --enable-dependency-tracking do not reject slow dependency extractors
+ --disable-symvers disable symbol versioning for libssp
++ --enable-ssp-in-libc do not build SSP, as it is in libc
+ --enable-shared[=PKGS] build shared libraries [default=yes]
+ --enable-static[=PKGS] build static libraries [default=yes]
+ --enable-fast-install[=PKGS]
+@@ -4206,6 +4210,36 @@
+ fi
+
+
++# musl provides libssp in libc
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libssp is provided in libc" >&5
++$as_echo_n "checking whether libssp is provided in libc... " >&6; }
++# Check whether --enable-ssp_in_libc was given.
++if test "${enable_ssp_in_libc+set}" = set; then :
++ enableval=$enable_ssp_in_libc; ssp_in_libc=$enableval
++else
++ ssp_in_libc=check
++fi
++
++if test "x$ssp_in_libc" = "xcheck"; then
++ case "$host" in
++ *-musl*)
++ ssp_in_libc=yes
++ ;;
++
++ *)
++ ssp_in_libc=no
++ ;;
++ esac
++fi
++ if test "x$ssp_in_libc" = xyes; then
++ LIBSSP_IN_LIBC_TRUE=
++ LIBSSP_IN_LIBC_FALSE='#'
++else
++ LIBSSP_IN_LIBC_TRUE='#'
++ LIBSSP_IN_LIBC_FALSE=
++fi
++
++
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+ $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+@@ -10650,7 +10684,7 @@
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 10653 "configure"
++#line 10687 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -10756,7 +10790,7 @@
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 10759 "configure"
++#line 10793 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -11185,6 +11219,10 @@
+ as_fn_error "conditional \"LIBSSP_USE_SYMVER_SUN\" was never defined.
+ Usually this means the macro was only invoked conditionally." "$LINENO" 5
+ fi
++if test -z "${LIBSSP_IN_LIBC_TRUE}" && test -z "${LIBSSP_IN_LIBC_FALSE}"; then
++ as_fn_error "conditional \"LIBSSP_IN_LIBC\" was never defined.
++Usually this means the macro was only invoked conditionally." "$LINENO" 5
++fi
+
+ : ${CONFIG_STATUS=./config.status}
+ ac_write_fail=0
+diff -Nur gcc-4.7.3.orig/libssp/configure.ac gcc-4.7.3/libssp/configure.ac
+--- gcc-4.7.3.orig/libssp/configure.ac 2012-05-31 20:59:34.000000000 +0200
++++ gcc-4.7.3/libssp/configure.ac 2013-09-16 15:39:43.000000000 +0200
+@@ -114,6 +114,26 @@
+ AM_CONDITIONAL(LIBSSP_USE_SYMVER_GNU, [test "x$ssp_use_symver" = xgnu])
+ AM_CONDITIONAL(LIBSSP_USE_SYMVER_SUN, [test "x$ssp_use_symver" = xsun])
+
++# musl provides libssp in libc
++AC_MSG_CHECKING([whether libssp is provided in libc])
++AC_ARG_ENABLE(ssp_in_libc,
++AC_HELP_STRING([--enable-ssp-in-libc],
++ [do not build SSP, as it is in libc]),
++ssp_in_libc=$enableval,
++ssp_in_libc=check)
++if test "x$ssp_in_libc" = "xcheck"; then
++ case "$host" in
++ *-musl*)
++ ssp_in_libc=yes
++ ;;
++
++ *)
++ ssp_in_libc=no
++ ;;
++ esac
++fi
++AM_CONDITIONAL(LIBSSP_IN_LIBC, [test "x$ssp_in_libc" = xyes])
++
+ AC_CHECK_HEADERS(alloca.h malloc.h paths.h syslog.h string.h unistd.h fcntl.h stdio.h limits.h)
+
+ if test x$gcc_no_link = xyes; then
+diff -Nur gcc-4.7.3.orig/libssp/Makefile.am gcc-4.7.3/libssp/Makefile.am
+--- gcc-4.7.3.orig/libssp/Makefile.am 2010-12-06 01:50:04.000000000 +0100
++++ gcc-4.7.3/libssp/Makefile.am 2013-09-16 15:39:43.000000000 +0200
+@@ -36,7 +36,11 @@
+
+ AM_CFLAGS = -Wall
+
++if LIBSSP_IN_LIBC
++toolexeclib_LTLIBRARIES = libssp_nonshared.la
++else
+ toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
++endif
+
+ target_noncanonical = @target_noncanonical@
+ libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
+diff -Nur gcc-4.7.3.orig/libssp/Makefile.in gcc-4.7.3/libssp/Makefile.in
+--- gcc-4.7.3.orig/libssp/Makefile.in 2011-02-13 12:45:53.000000000 +0100
++++ gcc-4.7.3/libssp/Makefile.in 2013-09-16 15:39:43.000000000 +0200
+@@ -93,12 +93,17 @@
+ libssp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libssp_la_LDFLAGS) $(LDFLAGS) -o $@
++@LIBSSP_IN_LIBC_FALSE@am_libssp_la_rpath = -rpath $(toolexeclibdir)
+ am_libssp_nonshared_la_OBJECTS = libssp_nonshared_la-ssp-local.lo
+ libssp_nonshared_la_OBJECTS = $(am_libssp_nonshared_la_OBJECTS)
+ libssp_nonshared_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+ $(libssp_nonshared_la_CFLAGS) $(CFLAGS) \
+ $(libssp_nonshared_la_LDFLAGS) $(LDFLAGS) -o $@
++@LIBSSP_IN_LIBC_FALSE@am_libssp_nonshared_la_rpath = -rpath \
++@LIBSSP_IN_LIBC_FALSE@ $(toolexeclibdir)
++@LIBSSP_IN_LIBC_TRUE@am_libssp_nonshared_la_rpath = -rpath \
++@LIBSSP_IN_LIBC_TRUE@ $(toolexeclibdir)
+ DEFAULT_INCLUDES = -I.@am__isrc@
+ depcomp = $(SHELL) $(top_srcdir)/../depcomp
+ am__depfiles_maybe = depfiles
+@@ -258,7 +263,8 @@
+ @LIBSSP_USE_SYMVER_GNU_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = $(srcdir)/ssp.map
+ @LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = ssp.map-sun
+ AM_CFLAGS = -Wall
+-toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
++@LIBSSP_IN_LIBC_FALSE@toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
++@LIBSSP_IN_LIBC_TRUE@toolexeclib_LTLIBRARIES = libssp_nonshared.la
+ libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
+ nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
+ libssp_la_SOURCES = \
+@@ -414,9 +420,9 @@
+ rm -f "$${dir}/so_locations"; \
+ done
+ libssp.la: $(libssp_la_OBJECTS) $(libssp_la_DEPENDENCIES)
+- $(libssp_la_LINK) -rpath $(toolexeclibdir) $(libssp_la_OBJECTS) $(libssp_la_LIBADD) $(LIBS)
++ $(libssp_la_LINK) $(am_libssp_la_rpath) $(libssp_la_OBJECTS) $(libssp_la_LIBADD) $(LIBS)
+ libssp_nonshared.la: $(libssp_nonshared_la_OBJECTS) $(libssp_nonshared_la_DEPENDENCIES)
+- $(libssp_nonshared_la_LINK) -rpath $(toolexeclibdir) $(libssp_nonshared_la_OBJECTS) $(libssp_nonshared_la_LIBADD) $(LIBS)
++ $(libssp_nonshared_la_LINK) $(am_libssp_nonshared_la_rpath) $(libssp_nonshared_la_OBJECTS) $(libssp_nonshared_la_LIBADD) $(LIBS)
+
+ mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+diff -Nur gcc-4.7.3.orig/libstdc++-v3/configure.host gcc-4.7.3/libstdc++-v3/configure.host
+--- gcc-4.7.3.orig/libstdc++-v3/configure.host 2012-12-18 15:27:14.000000000 +0100
++++ gcc-4.7.3/libstdc++-v3/configure.host 2013-09-16 15:39:43.000000000 +0200
+@@ -243,6 +243,13 @@
+ os_include_dir="os/bsd/freebsd"
+ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
++ # check for musl by target
++ case "${host_os}" in
++ *-musl*)
++ os_include_dir="os/generic"
++ ;;
++ *)
++
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+ elif [ "$bionic" = "yes" ]; then
+@@ -251,6 +258,9 @@
+ os_include_dir="os/gnu-linux"
+ fi
+ ;;
++
++ esac
++ ;;
+ hpux*)
+ os_include_dir="os/hpux"
+ ;;
diff --git a/toolchain/gcc/patches/4.7.3/musl-ppc.patch b/toolchain/gcc/patches/4.7.3/musl-ppc.patch
new file mode 100644
index 000000000..f4211ee73
--- /dev/null
+++ b/toolchain/gcc/patches/4.7.3/musl-ppc.patch
@@ -0,0 +1,155 @@
+diff -Nur gcc-4.7.3.orig/libgcc/config/rs6000/linux-unwind.h gcc-4.7.3/libgcc/config/rs6000/linux-unwind.h
+--- gcc-4.7.3.orig/libgcc/config/rs6000/linux-unwind.h 2011-11-12 18:20:58.000000000 +0100
++++ gcc-4.7.3/libgcc/config/rs6000/linux-unwind.h 2013-09-15 18:29:20.000000000 +0200
+@@ -27,7 +27,6 @@
+ #define R_CR2 70
+ #define R_VR0 77
+ #define R_VRSAVE 109
+-#define R_VSCR 110
+
+ struct gcc_vregs
+ {
+@@ -176,38 +175,6 @@
+ }
+ #endif
+
+-/* Find an entry in the process auxiliary vector. The canonical way to
+- test for VMX is to look at AT_HWCAP. */
+-
+-static long
+-ppc_linux_aux_vector (long which)
+-{
+- /* __libc_stack_end holds the original stack passed to a process. */
+- extern long *__libc_stack_end;
+- long argc;
+- char **argv;
+- char **envp;
+- struct auxv
+- {
+- long a_type;
+- long a_val;
+- } *auxp;
+-
+- /* The Linux kernel puts argc first on the stack. */
+- argc = __libc_stack_end[0];
+- /* Followed by argv, NULL terminated. */
+- argv = (char **) __libc_stack_end + 1;
+- /* Followed by environment string pointers, NULL terminated. */
+- envp = argv + argc + 1;
+- while (*envp++)
+- continue;
+- /* Followed by the aux vector, zero terminated. */
+- for (auxp = (struct auxv *) envp; auxp->a_type != 0; ++auxp)
+- if (auxp->a_type == which)
+- return auxp->a_val;
+- return 0;
+-}
+-
+ /* Do code reading to identify a signal frame, and set the frame
+ state data appropriately. See unwind-dw2.c for the structs. */
+
+@@ -217,8 +184,8 @@
+ ppc_fallback_frame_state (struct _Unwind_Context *context,
+ _Unwind_FrameState *fs)
+ {
+- static long hwcap = 0;
+ struct gcc_regs *regs = get_regs (context);
++ struct gcc_vregs *vregs;
+ long new_cfa;
+ int i;
+
+@@ -230,12 +197,15 @@
+ fs->regs.cfa_reg = STACK_POINTER_REGNUM;
+ fs->regs.cfa_offset = new_cfa - (long) context->cfa;
+
+- for (i = 0; i < 32; i++)
+- if (i != STACK_POINTER_REGNUM)
+- {
+- fs->regs.reg[i].how = REG_SAVED_OFFSET;
+- fs->regs.reg[i].loc.offset = (long) &regs->gpr[i] - new_cfa;
+- }
++#ifdef __powerpc64__
++ fs->regs.reg[2].how = REG_SAVED_OFFSET;
++ fs->regs.reg[2].loc.offset = (long) &regs->gpr[2] - new_cfa;
++#endif
++ for (i = 14; i < 32; i++)
++ {
++ fs->regs.reg[i].how = REG_SAVED_OFFSET;
++ fs->regs.reg[i].loc.offset = (long) &regs->gpr[i] - new_cfa;
++ }
+
+ fs->regs.reg[R_CR2].how = REG_SAVED_OFFSET;
+ /* CR? regs are always 32-bit and PPC is big-endian, so in 64-bit
+@@ -251,57 +221,35 @@
+ fs->retaddr_column = ARG_POINTER_REGNUM;
+ fs->signal_frame = 1;
+
+- if (hwcap == 0)
++ /* If we have a FPU... */
++ for (i = 14; i < 32; i++)
+ {
+- hwcap = ppc_linux_aux_vector (16);
+- /* These will already be set if we found AT_HWCAP. A nonzero
+- value stops us looking again if for some reason we couldn't
+- find AT_HWCAP. */
+-#ifdef __powerpc64__
+- hwcap |= 0xc0000000;
+-#else
+- hwcap |= 0x80000000;
+-#endif
++ fs->regs.reg[i + 32].how = REG_SAVED_OFFSET;
++ fs->regs.reg[i + 32].loc.offset = (long) &regs->fpr[i] - new_cfa;
+ }
+
+- /* If we have a FPU... */
+- if (hwcap & 0x08000000)
+- for (i = 0; i < 32; i++)
+- {
+- fs->regs.reg[i + 32].how = REG_SAVED_OFFSET;
+- fs->regs.reg[i + 32].loc.offset = (long) &regs->fpr[i] - new_cfa;
+- }
+-
+ /* If we have a VMX unit... */
+- if (hwcap & 0x10000000)
+- {
+- struct gcc_vregs *vregs;
+ #ifdef __powerpc64__
+- vregs = regs->vp;
++ vregs = regs->vp;
+ #else
+- vregs = &regs->vregs;
++ vregs = &regs->vregs;
+ #endif
+- if (regs->msr & (1 << 25))
++ if (regs->msr & (1 << 25))
++ {
++ for (i = 20; i < 32; i++)
+ {
+- for (i = 0; i < 32; i++)
+- {
+- fs->regs.reg[i + R_VR0].how = REG_SAVED_OFFSET;
+- fs->regs.reg[i + R_VR0].loc.offset
+- = (long) &vregs->vr[i] - new_cfa;
+- }
+-
+- fs->regs.reg[R_VSCR].how = REG_SAVED_OFFSET;
+- fs->regs.reg[R_VSCR].loc.offset = (long) &vregs->vscr - new_cfa;
++ fs->regs.reg[i + R_VR0].how = REG_SAVED_OFFSET;
++ fs->regs.reg[i + R_VR0].loc.offset = (long) &vregs->vr[i] - new_cfa;
+ }
+-
+- fs->regs.reg[R_VRSAVE].how = REG_SAVED_OFFSET;
+- fs->regs.reg[R_VRSAVE].loc.offset = (long) &vregs->vsave - new_cfa;
+ }
+
++ fs->regs.reg[R_VRSAVE].how = REG_SAVED_OFFSET;
++ fs->regs.reg[R_VRSAVE].loc.offset = (long) &vregs->vsave - new_cfa;
++
+ /* If we have SPE register high-parts... we check at compile-time to
+ avoid expanding the code for all other PowerPC. */
+ #ifdef __SPE__
+- for (i = 0; i < 32; i++)
++ for (i = 14; i < 32; i++)
+ {
+ fs->regs.reg[i + FIRST_PSEUDO_REGISTER - 1].how = REG_SAVED_OFFSET;
+ fs->regs.reg[i + FIRST_PSEUDO_REGISTER - 1].loc.offset
diff --git a/toolchain/gcc/patches/4.7.3/musl.patch b/toolchain/gcc/patches/4.7.3/musl.patch
deleted file mode 100644
index 4da8ce564..000000000
--- a/toolchain/gcc/patches/4.7.3/musl.patch
+++ /dev/null
@@ -1,360 +0,0 @@
-diff -Nur gcc-4.7.3.orig/config.sub gcc-4.7.3/config.sub
---- gcc-4.7.3.orig/config.sub 2012-08-06 16:34:27.000000000 +0200
-+++ gcc-4.7.3/config.sub 2013-08-11 14:20:23.979180205 +0200
-@@ -125,6 +125,7 @@
- maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
- case $maybe_os in
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-+ linux-musl* | \
- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
- knetbsd*-gnu* | netbsd*-gnu* | \
- kopensolaris*-gnu* | \
-diff -Nur gcc-4.7.3.orig/fixincludes/mkfixinc.sh gcc-4.7.3/fixincludes/mkfixinc.sh
---- gcc-4.7.3.orig/fixincludes/mkfixinc.sh 2011-09-22 16:00:17.000000000 +0200
-+++ gcc-4.7.3/fixincludes/mkfixinc.sh 2013-08-11 14:17:48.905129751 +0200
-@@ -20,7 +20,8 @@
- powerpc-*-eabi* | \
- powerpc-*-rtems* | \
- powerpcle-*-eabisim* | \
-- powerpcle-*-eabi* )
-+ powerpcle-*-eabi* | \
-+ *-musl* )
- # IF there is no include fixing,
- # THEN create a no-op fixer and exit
- (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
-diff -Nur gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h gcc-4.7.3/gcc/config/arm/linux-eabi.h
---- gcc-4.7.3.orig/gcc/config/arm/linux-eabi.h 2011-11-02 16:03:19.000000000 +0100
-+++ gcc-4.7.3/gcc/config/arm/linux-eabi.h 2013-08-11 14:17:15.153554066 +0200
-@@ -64,6 +64,10 @@
- #undef GLIBC_DYNAMIC_LINKER
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
-
-+/* musl has no "classic" (i.e. broken) mode */
-+#undef MUSL_DYNAMIC_LINKER
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
-+
- /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
- use the GNU/Linux version, not the generic BPABI version. */
- #undef LINK_SPEC
-diff -Nur gcc-4.7.3.orig/gcc/config/i386/linux64.h gcc-4.7.3/gcc/config/i386/linux64.h
---- gcc-4.7.3.orig/gcc/config/i386/linux64.h 2011-07-07 17:38:34.000000000 +0200
-+++ gcc-4.7.3/gcc/config/i386/linux64.h 2013-08-11 14:17:15.157554016 +0200
-@@ -31,3 +31,7 @@
- #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
- #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
- #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
-+
-+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
-+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
-+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
-diff -Nur gcc-4.7.3.orig/gcc/config/i386/linux.h gcc-4.7.3/gcc/config/i386/linux.h
---- gcc-4.7.3.orig/gcc/config/i386/linux.h 2011-06-03 20:30:39.000000000 +0200
-+++ gcc-4.7.3/gcc/config/i386/linux.h 2013-08-11 14:17:15.153554066 +0200
-@@ -22,3 +22,4 @@
-
- #define GNU_USER_LINK_EMULATION "elf_i386"
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
-diff -Nur gcc-4.7.3.orig/gcc/config/linux.h gcc-4.7.3/gcc/config/linux.h
---- gcc-4.7.3.orig/gcc/config/linux.h 2012-08-14 15:59:04.000000000 +0200
-+++ gcc-4.7.3/gcc/config/linux.h 2013-08-11 14:17:15.169553864 +0200
-@@ -33,10 +33,12 @@
- #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
- #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
- #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
-+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
- #else
- #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
- #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
- #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
-+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
- #endif
-
- #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
-@@ -54,18 +56,21 @@
- uClibc or Bionic is the default C library and whether
- -muclibc or -mglibc or -mbionic has been passed to change the default. */
-
--#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
-- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
-+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
-+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
-
- #if DEFAULT_LIBC == LIBC_GLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
-- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
- #elif DEFAULT_LIBC == LIBC_UCLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
-- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
- #elif DEFAULT_LIBC == LIBC_BIONIC
--#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
-- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
-+#elif DEFAULT_LIBC == LIBC_MUSL
-+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
-+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
- #else
- #error "Unsupported DEFAULT_LIBC"
- #endif /* DEFAULT_LIBC */
-@@ -85,16 +90,16 @@
-
- #define GNU_USER_DYNAMIC_LINKER \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
-- BIONIC_DYNAMIC_LINKER)
-+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
- #define GNU_USER_DYNAMIC_LINKER32 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
-- BIONIC_DYNAMIC_LINKER32)
-+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
- #define GNU_USER_DYNAMIC_LINKER64 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
-- BIONIC_DYNAMIC_LINKER64)
-+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
- #define GNU_USER_DYNAMIC_LINKERX32 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
-- BIONIC_DYNAMIC_LINKERX32)
-+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
-
- /* Determine whether the entire c99 runtime
- is present in the runtime library. */
-diff -Nur gcc-4.7.3.orig/gcc/config/linux.opt gcc-4.7.3/gcc/config/linux.opt
---- gcc-4.7.3.orig/gcc/config/linux.opt 2010-09-29 16:51:52.000000000 +0200
-+++ gcc-4.7.3/gcc/config/linux.opt 2013-08-11 14:17:15.169553864 +0200
-@@ -30,3 +30,7 @@
- muclibc
- Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
- Use uClibc C library
-+
-+mmusl
-+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
-+Use musl C library
-diff -Nur gcc-4.7.3.orig/gcc/config/mips/linux64.h gcc-4.7.3/gcc/config/mips/linux64.h
---- gcc-4.7.3.orig/gcc/config/mips/linux64.h 2011-07-19 20:00:27.000000000 +0200
-+++ gcc-4.7.3/gcc/config/mips/linux64.h 2013-08-11 14:17:15.357551501 +0200
-@@ -28,6 +28,9 @@
- #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
- #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
- #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
-+#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
-+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
-+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
- #define GNU_USER_DYNAMIC_LINKERN32 \
- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
-- BIONIC_DYNAMIC_LINKERN32)
-+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
-diff -Nur gcc-4.7.3.orig/gcc/config/mips/linux.h gcc-4.7.3/gcc/config/mips/linux.h
---- gcc-4.7.3.orig/gcc/config/mips/linux.h 2011-07-19 20:00:27.000000000 +0200
-+++ gcc-4.7.3/gcc/config/mips/linux.h 2013-08-11 14:17:15.169553864 +0200
-@@ -19,3 +19,5 @@
- <http://www.gnu.org/licenses/>. */
-
- #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
-+
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
-diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/linux64.h gcc-4.7.3/gcc/config/rs6000/linux64.h
---- gcc-4.7.3.orig/gcc/config/rs6000/linux64.h 2012-03-12 17:16:51.000000000 +0100
-+++ gcc-4.7.3/gcc/config/rs6000/linux64.h 2013-08-11 14:17:15.169553864 +0200
-@@ -362,17 +362,21 @@
- #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
- #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
- #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
-+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
-+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
- #if DEFAULT_LIBC == LIBC_UCLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
- #elif DEFAULT_LIBC == LIBC_GLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
-+#elif DEFAULT_LIBC == LIBC_MUSL
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
- #else
- #error "Unsupported DEFAULT_LIBC"
- #endif
- #define GNU_USER_DYNAMIC_LINKER32 \
-- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
-+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
- #define GNU_USER_DYNAMIC_LINKER64 \
-- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
-+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
-
-
- #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
-diff -Nur gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h gcc-4.7.3/gcc/config/rs6000/sysv4.h
---- gcc-4.7.3.orig/gcc/config/rs6000/sysv4.h 2012-04-30 19:39:01.000000000 +0200
-+++ gcc-4.7.3/gcc/config/rs6000/sysv4.h 2013-08-11 14:17:15.173553814 +0200
-@@ -804,15 +804,18 @@
-
- #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
- #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
-+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
- #if DEFAULT_LIBC == LIBC_UCLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
-+#elif DEFAULT_LIBC == LIBC_MUSL
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
- #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
--#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
-+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
- #else
- #error "Unsupported DEFAULT_LIBC"
- #endif
- #define GNU_USER_DYNAMIC_LINKER \
-- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
-+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
-
- #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
- %{rdynamic:-export-dynamic} \
-diff -Nur gcc-4.7.3.orig/gcc/config.gcc gcc-4.7.3/gcc/config.gcc
---- gcc-4.7.3.orig/gcc/config.gcc 2013-03-06 23:54:11.000000000 +0100
-+++ gcc-4.7.3/gcc/config.gcc 2013-08-11 14:17:15.141554216 +0200
-@@ -522,7 +522,7 @@
- esac
-
- # Common C libraries.
--tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
-+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
-
- # Common parts for widely ported systems.
- case ${target} in
-@@ -625,6 +625,9 @@
- *-*-*uclibc*)
- tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
- ;;
-+ *-*-*musl*)
-+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
-+ ;;
- *)
- tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
- ;;
-diff -Nur gcc-4.7.3.orig/gcc/configure gcc-4.7.3/gcc/configure
---- gcc-4.7.3.orig/gcc/configure 2013-02-06 16:23:55.000000000 +0100
-+++ gcc-4.7.3/gcc/configure 2013-08-11 14:17:42.205213980 +0200
-@@ -26902,6 +26902,9 @@
- gcc_cv_target_dl_iterate_phdr=no
- fi
- ;;
-+ *-linux-musl*)
-+ gcc_cv_target_dl_iterate_phdr=yes
-+ ;;
- esac
-
- if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
-diff -Nur gcc-4.7.3.orig/gcc/ginclude/stddef.h gcc-4.7.3/gcc/ginclude/stddef.h
---- gcc-4.7.3.orig/gcc/ginclude/stddef.h 2012-02-12 02:06:04.000000000 +0100
-+++ gcc-4.7.3/gcc/ginclude/stddef.h 2013-08-11 14:17:15.349551601 +0200
-@@ -184,6 +184,7 @@
- #ifndef _GCC_SIZE_T
- #ifndef _SIZET_
- #ifndef __size_t
-+#ifndef __DEFINED_size_t /* musl */
- #define __size_t__ /* BeOS */
- #define __SIZE_T__ /* Cray Unicos/Mk */
- #define _SIZE_T
-@@ -200,6 +201,7 @@
- #define ___int_size_t_h
- #define _GCC_SIZE_T
- #define _SIZET_
-+#define __DEFINED_size_t /* musl */
- #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
- || defined(__FreeBSD_kernel__)
- /* __size_t is a typedef on FreeBSD 5, must not trash it. */
-@@ -215,6 +217,7 @@
- typedef long ssize_t;
- #endif /* __BEOS__ */
- #endif /* !(defined (__GNUG__) && defined (size_t)) */
-+#endif /* __DEFINED_size_t */
- #endif /* __size_t */
- #endif /* _SIZET_ */
- #endif /* _GCC_SIZE_T */
-diff -Nur gcc-4.7.3.orig/libgomp/config/posix/time.c gcc-4.7.3/libgomp/config/posix/time.c
---- gcc-4.7.3.orig/libgomp/config/posix/time.c 2009-04-09 17:00:19.000000000 +0200
-+++ gcc-4.7.3/libgomp/config/posix/time.c 2013-08-11 14:17:15.349551601 +0200
-@@ -28,6 +28,8 @@
- The following implementation uses the most simple POSIX routines.
- If present, POSIX 4 clocks should be used instead. */
-
-+#define _POSIX_C_SOURCE 199309L /* for clocks */
-+
- #include "libgomp.h"
- #include <unistd.h>
- #if TIME_WITH_SYS_TIME
-diff -Nur gcc-4.7.3.orig/libitm/config/arm/hwcap.cc gcc-4.7.3/libitm/config/arm/hwcap.cc
---- gcc-4.7.3.orig/libitm/config/arm/hwcap.cc 2011-12-15 04:24:05.000000000 +0100
-+++ gcc-4.7.3/libitm/config/arm/hwcap.cc 2013-08-11 14:17:15.353551551 +0200
-@@ -40,7 +40,11 @@
-
- #ifdef __linux__
- #include <unistd.h>
-+#ifdef __GLIBC__
- #include <sys/fcntl.h>
-+#else
-+#include <fcntl.h>
-+#endif
- #include <elf.h>
-
- static void __attribute__((constructor))
-diff -Nur gcc-4.7.3.orig/libitm/config/linux/x86/tls.h gcc-4.7.3/libitm/config/linux/x86/tls.h
---- gcc-4.7.3.orig/libitm/config/linux/x86/tls.h 2011-11-08 12:13:41.000000000 +0100
-+++ gcc-4.7.3/libitm/config/linux/x86/tls.h 2013-08-11 14:17:15.353551551 +0200
-@@ -25,16 +25,19 @@
- #ifndef LIBITM_X86_TLS_H
- #define LIBITM_X86_TLS_H 1
-
--#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
-+#if defined(__GLIBC_PREREQ)
-+#if __GLIBC_PREREQ(2, 10)
- /* Use slots in the TCB head rather than __thread lookups.
- GLIBC has reserved words 10 through 13 for TM. */
- #define HAVE_ARCH_GTM_THREAD 1
- #define HAVE_ARCH_GTM_THREAD_DISP 1
- #endif
-+#endif
-
- #include "config/generic/tls.h"
-
--#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
-+#if defined(__GLIBC_PREREQ)
-+#if __GLIBC_PREREQ(2, 10)
- namespace GTM HIDDEN {
-
- #ifdef __x86_64__
-@@ -101,5 +104,6 @@
-
- } // namespace GTM
- #endif /* >= GLIBC 2.10 */
-+#endif
-
- #endif // LIBITM_X86_TLS_H
-diff -Nur gcc-4.7.3.orig/libstdc++-v3/configure.host gcc-4.7.3/libstdc++-v3/configure.host
---- gcc-4.7.3.orig/libstdc++-v3/configure.host 2012-12-18 15:27:14.000000000 +0100
-+++ gcc-4.7.3/libstdc++-v3/configure.host 2013-08-11 14:17:15.357551501 +0200
-@@ -243,6 +243,13 @@
- os_include_dir="os/bsd/freebsd"
- ;;
- gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
-+ # check for musl by target
-+ case "${host_os}" in
-+ *-musl*)
-+ os_include_dir="os/generic"
-+ ;;
-+ *)
-+
- if [ "$uclibc" = "yes" ]; then
- os_include_dir="os/uclibc"
- elif [ "$bionic" = "yes" ]; then
-@@ -251,6 +258,9 @@
- os_include_dir="os/gnu-linux"
- fi
- ;;
-+
-+ esac
-+ ;;
- hpux*)
- os_include_dir="os/hpux"
- ;;
diff --git a/toolchain/glibc/Makefile.inc b/toolchain/glibc/Makefile.inc
index 2232e9bb2..7acb49bb3 100644
--- a/toolchain/glibc/Makefile.inc
+++ b/toolchain/glibc/Makefile.inc
@@ -2,9 +2,9 @@
# material, please see the LICENCE file in the top-level directory.
PKG_NAME:= glibc
-PKG_VERSION:= 2.17
+PKG_VERSION:= 2.18
PKG_RELEASE:= 1
-PKG_MD5SUM:= 8a7f11b9ac5d0d5efa4c82175b5a9c1b
+PKG_MD5SUM:= b67b22b428ed183148d1344da6d22ea9
PKG_SITES:= ${MASTER_SITE_GNU:=glibc/}
GLIBC_CONFOPTS:= --build=$(GNU_HOST_NAME) \
--host=$(REAL_GNU_TARGET_NAME) \
diff --git a/toolchain/glibc/patches/glibc-cross.patch b/toolchain/glibc/patches/glibc-cross.patch
index dadd8641b..4084fd20d 100644
--- a/toolchain/glibc/patches/glibc-cross.patch
+++ b/toolchain/glibc/patches/glibc-cross.patch
@@ -1,6 +1,6 @@
-diff -Nur glibc-2.17.orig/sunrpc/rpc/types.h glibc-2.17/sunrpc/rpc/types.h
---- glibc-2.17.orig/sunrpc/rpc/types.h 2012-12-25 04:02:13.000000000 +0100
-+++ glibc-2.17/sunrpc/rpc/types.h 2013-08-12 14:59:35.000000000 +0200
+diff -Nur glibc-2.18.orig/sunrpc/rpc/types.h glibc-2.18/sunrpc/rpc/types.h
+--- glibc-2.18.orig/sunrpc/rpc/types.h 2013-08-11 00:52:55.000000000 +0200
++++ glibc-2.18/sunrpc/rpc/types.h 2013-09-13 08:25:18.000000000 +0200
@@ -69,19 +69,25 @@
#include <sys/types.h>
#endif
@@ -39,9 +39,9 @@ diff -Nur glibc-2.17.orig/sunrpc/rpc/types.h glibc-2.17/sunrpc/rpc/types.h
# define __daddr_t_defined
#endif
-diff -Nur glibc-2.17.orig/sunrpc/rpc_main.c glibc-2.17/sunrpc/rpc_main.c
---- glibc-2.17.orig/sunrpc/rpc_main.c 2012-12-25 04:02:13.000000000 +0100
-+++ glibc-2.17/sunrpc/rpc_main.c 2013-08-12 14:59:37.000000000 +0200
+diff -Nur glibc-2.18.orig/sunrpc/rpc_main.c glibc-2.18/sunrpc/rpc_main.c
+--- glibc-2.18.orig/sunrpc/rpc_main.c 2013-08-11 00:52:55.000000000 +0200
++++ glibc-2.18/sunrpc/rpc_main.c 2013-09-13 08:26:07.000000000 +0200
@@ -38,7 +38,11 @@
#include <stdio.h>
#include <string.h>
@@ -51,10 +51,10 @@ diff -Nur glibc-2.17.orig/sunrpc/rpc_main.c glibc-2.17/sunrpc/rpc_main.c
+#else
#include <libintl.h>
+#endif
+ #include <locale.h>
#include <ctype.h>
#include <sys/types.h>
- #include <sys/param.h>
-@@ -954,10 +958,12 @@
+@@ -958,10 +962,12 @@
abort ();
temp = rindex (cmd->infile, '.');
cp = stpcpy (mkfilename, "Makefile.");
@@ -70,9 +70,9 @@ diff -Nur glibc-2.17.orig/sunrpc/rpc_main.c glibc-2.17/sunrpc/rpc_main.c
}
else
-diff -Nur glibc-2.17.orig/sunrpc/rpc_scan.c glibc-2.17/sunrpc/rpc_scan.c
---- glibc-2.17.orig/sunrpc/rpc_scan.c 2012-12-25 04:02:13.000000000 +0100
-+++ glibc-2.17/sunrpc/rpc_scan.c 2013-08-12 14:59:37.000000000 +0200
+diff -Nur glibc-2.18.orig/sunrpc/rpc_scan.c glibc-2.18/sunrpc/rpc_scan.c
+--- glibc-2.18.orig/sunrpc/rpc_scan.c 2013-08-11 00:52:55.000000000 +0200
++++ glibc-2.18/sunrpc/rpc_scan.c 2013-09-13 08:25:18.000000000 +0200
@@ -37,7 +37,11 @@
#include <stdio.h>
#include <ctype.h>
diff --git a/toolchain/kernel-headers/patches/3.9.11/sortext.patch b/toolchain/kernel-headers/patches/3.9.11/sortext.patch
index d82b76a2d..45a8a4985 100644
--- a/toolchain/kernel-headers/patches/3.9.11/sortext.patch
+++ b/toolchain/kernel-headers/patches/3.9.11/sortext.patch
@@ -1,22 +1,4949 @@
-diff -Nur linux-3.5.2.orig/arch/mips/Kconfig linux-3.5.2/arch/mips/Kconfig
---- linux-3.5.2.orig/arch/mips/Kconfig 2012-08-15 16:55:25.000000000 +0200
-+++ linux-3.5.2/arch/mips/Kconfig 2012-08-23 11:10:29.000000000 +0200
-@@ -31,7 +31,6 @@
+diff -Nur linux-3.9.11.orig/arch/arm/Kconfig linux-3.9.11/arch/arm/Kconfig
+--- linux-3.9.11.orig/arch/arm/Kconfig 2013-07-21 02:16:17.000000000 +0200
++++ linux-3.9.11/arch/arm/Kconfig 2013-09-12 07:26:36.000000000 +0200
+@@ -6,7 +6,6 @@
+ select ARCH_HAVE_CUSTOM_GPIO_H
+ select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ select ARCH_WANT_IPC_PARSE_VERSION
+- select BUILDTIME_EXTABLE_SORT if MMU
+ select CPU_PM if (SUSPEND || CPU_IDLE)
+ select DCACHE_WORD_ACCESS if (CPU_V6 || CPU_V6K || CPU_V7) && !CPU_BIG_ENDIAN && MMU
+ select GENERIC_ATOMIC64 if (CPU_V6 || !CPU_32v6K || !AEABI)
+diff -Nur linux-3.9.11.orig/arch/mips/Kconfig linux-3.9.11/arch/mips/Kconfig
+--- linux-3.9.11.orig/arch/mips/Kconfig 2013-07-21 02:16:17.000000000 +0200
++++ linux-3.9.11/arch/mips/Kconfig 2013-09-12 07:26:20.000000000 +0200
+@@ -34,7 +34,6 @@
select HAVE_MEMBLOCK_NODE_MAP
select ARCH_DISCARD_MEMBLOCK
select GENERIC_SMP_IDLE_THREAD
- select BUILDTIME_EXTABLE_SORT
select GENERIC_CLOCKEVENTS
select GENERIC_CMOS_UPDATE
-
-diff -Nur linux-3.5.2.orig/arch/x86/Kconfig linux-3.5.2/arch/x86/Kconfig
---- linux-3.5.2.orig/arch/x86/Kconfig 2012-08-15 16:55:25.000000000 +0200
-+++ linux-3.5.2/arch/x86/Kconfig 2012-08-23 11:10:17.000000000 +0200
-@@ -85,7 +85,6 @@
- select DCACHE_WORD_ACCESS
+ select HAVE_MOD_ARCH_SPECIFIC
+diff -Nur linux-3.9.11.orig/arch/mips/Kconfig.orig linux-3.9.11/arch/mips/Kconfig.orig
+--- linux-3.9.11.orig/arch/mips/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
++++ linux-3.9.11/arch/mips/Kconfig.orig 2013-07-21 02:16:17.000000000 +0200
+@@ -0,0 +1,2557 @@
++config MIPS
++ bool
++ default y
++ select HAVE_GENERIC_DMA_COHERENT
++ select HAVE_IDE
++ select HAVE_OPROFILE
++ select HAVE_PERF_EVENTS
++ select PERF_USE_VMALLOC
++ select HAVE_ARCH_KGDB
++ select ARCH_HAVE_CUSTOM_GPIO_H
++ select HAVE_FUNCTION_TRACER
++ select HAVE_FUNCTION_TRACE_MCOUNT_TEST
++ select HAVE_DYNAMIC_FTRACE
++ select HAVE_FTRACE_MCOUNT_RECORD
++ select HAVE_C_RECORDMCOUNT
++ select HAVE_FUNCTION_GRAPH_TRACER
++ select HAVE_KPROBES
++ select HAVE_KRETPROBES
++ select HAVE_DEBUG_KMEMLEAK
++ select ARCH_BINFMT_ELF_RANDOMIZE_PIE
++ select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT
++ select RTC_LIB if !MACH_LOONGSON
++ select GENERIC_ATOMIC64 if !64BIT
++ select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
++ select HAVE_DMA_ATTRS
++ select HAVE_DMA_API_DEBUG
++ select HAVE_GENERIC_HARDIRQS
++ select GENERIC_IRQ_PROBE
++ select GENERIC_IRQ_SHOW
++ select HAVE_ARCH_JUMP_LABEL
++ select ARCH_WANT_IPC_PARSE_VERSION
++ select IRQ_FORCED_THREADING
++ select HAVE_MEMBLOCK
++ select HAVE_MEMBLOCK_NODE_MAP
++ select ARCH_DISCARD_MEMBLOCK
++ select GENERIC_SMP_IDLE_THREAD
++ select BUILDTIME_EXTABLE_SORT
++ select GENERIC_CLOCKEVENTS
++ select GENERIC_CMOS_UPDATE
++ select HAVE_MOD_ARCH_SPECIFIC
++ select VIRT_TO_BUS
++ select MODULES_USE_ELF_REL if MODULES
++ select MODULES_USE_ELF_RELA if MODULES && 64BIT
++ select CLONE_BACKWARDS
++
++menu "Machine selection"
++
++config ZONE_DMA
++ bool
++
++choice
++ prompt "System type"
++ default SGI_IP22
++
++config MIPS_ALCHEMY
++ bool "Alchemy processor based machines"
++ select 64BIT_PHYS_ADDR
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_APM_EMULATION
++ select GENERIC_GPIO
++ select ARCH_WANT_OPTIONAL_GPIOLIB
++ select SYS_SUPPORTS_ZBOOT
++ select USB_ARCH_HAS_OHCI
++ select USB_ARCH_HAS_EHCI
++
++config AR7
++ bool "Texas Instruments AR7"
++ select BOOT_ELF32
++ select DMA_NONCOHERENT
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select NO_EXCEPT_FILL
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_ZBOOT_UART16550
++ select ARCH_REQUIRE_GPIOLIB
++ select VLYNQ
++ select HAVE_CLK
++ help
++ Support for the Texas Instruments AR7 System-on-a-Chip
++ family: TNETD7100, 7200 and 7300.
++
++config ATH79
++ bool "Atheros AR71XX/AR724X/AR913X based boards"
++ select ARCH_REQUIRE_GPIOLIB
++ select BOOT_RAW
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select HAVE_CLK
++ select IRQ_CPU
++ select MIPS_MACHINE
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ help
++ Support for the Atheros AR71XX/AR724X/AR913X SoCs.
++
++config BCM47XX
++ bool "Broadcom BCM47XX based boards"
++ select ARCH_WANT_OPTIONAL_GPIOLIB
++ select BOOT_RAW
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select FW_CFE
++ select HW_HAS_PCI
++ select IRQ_CPU
++ select NO_EXCEPT_FILL
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_HAS_EARLY_PRINTK
++ help
++ Support for BCM47XX based boards
++
++config BCM63XX
++ bool "Broadcom BCM63XX based boards"
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_HAS_EARLY_PRINTK
++ select SWAP_IO_SPACE
++ select ARCH_REQUIRE_GPIOLIB
++ select HAVE_CLK
++ help
++ Support for BCM63XX based boards
++
++config MIPS_COBALT
++ bool "Cobalt Server"
++ select CEVT_R4K
++ select CSRC_R4K
++ select CEVT_GT641XX
++ select DMA_NONCOHERENT
++ select HW_HAS_PCI
++ select I8253
++ select I8259
++ select IRQ_CPU
++ select IRQ_GT641XX
++ select PCI_GT64XXX_PCI0
++ select PCI
++ select SYS_HAS_CPU_NEVADA
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config MACH_DECSTATION
++ bool "DECstations"
++ select BOOT_ELF32
++ select CEVT_DS1287
++ select CEVT_R4K
++ select CSRC_IOASIC
++ select CSRC_R4K
++ select CPU_DADDI_WORKAROUNDS if 64BIT
++ select CPU_R4000_WORKAROUNDS if 64BIT
++ select CPU_R4400_WORKAROUNDS if 64BIT
++ select DMA_NONCOHERENT
++ select NO_IOPORT
++ select IRQ_CPU
++ select SYS_HAS_CPU_R3000
++ select SYS_HAS_CPU_R4X00
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_128HZ
++ select SYS_SUPPORTS_256HZ
++ select SYS_SUPPORTS_1024HZ
++ help
++ This enables support for DEC's MIPS based workstations. For details
++ see the Linux/MIPS FAQ on <http://www.linux-mips.org/> and the
++ DECstation porting pages on <http://decstation.unix-ag.org/>.
++
++ If you have one of the following DECstation Models you definitely
++ want to choose R4xx0 for the CPU Type:
++
++ DECstation 5000/50
++ DECstation 5000/150
++ DECstation 5000/260
++ DECsystem 5900/260
++
++ otherwise choose R3000.
++
++config MACH_JAZZ
++ bool "Jazz family of machines"
++ select FW_ARC
++ select FW_ARC32
++ select ARCH_MAY_HAVE_PC_FDC
++ select CEVT_R4K
++ select CSRC_R4K
++ select DEFAULT_SGI_PARTITION if CPU_BIG_ENDIAN
++ select GENERIC_ISA_DMA
++ select HAVE_PCSPKR_PLATFORM
++ select IRQ_CPU
++ select I8253
++ select I8259
++ select ISA
++ select SYS_HAS_CPU_R4X00
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_100HZ
++ help
++ This a family of machines based on the MIPS R4030 chipset which was
++ used by several vendors to build RISC/os and Windows NT workstations.
++ Members include the Acer PICA, MIPS Magnum 4000, MIPS Millennium and
++ Olivetti M700-10 workstations.
++
++config MACH_JZ4740
++ bool "Ingenic JZ4740 based machines"
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_ZBOOT_UART16550
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select GENERIC_GPIO
++ select ARCH_REQUIRE_GPIOLIB
++ select SYS_HAS_EARLY_PRINTK
++ select HAVE_PWM
++ select HAVE_CLK
++ select GENERIC_IRQ_CHIP
++
++config LANTIQ
++ bool "Lantiq based platforms"
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select CEVT_R4K
++ select CSRC_R4K
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_MULTITHREADING
++ select SYS_HAS_EARLY_PRINTK
++ select ARCH_REQUIRE_GPIOLIB
++ select SWAP_IO_SPACE
++ select BOOT_RAW
++ select HAVE_MACH_CLKDEV
++ select CLKDEV_LOOKUP
++ select USE_OF
++ select PINCTRL
++ select PINCTRL_LANTIQ
++
++config LASAT
++ bool "LASAT Networks platforms"
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select SYS_HAS_EARLY_PRINTK
++ select HW_HAS_PCI
++ select IRQ_CPU
++ select PCI_GT64XXX_PCI0
++ select MIPS_NILE4
++ select R5000_CPU_SCACHE
++ select SYS_HAS_CPU_R5000
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL if BROKEN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config MACH_LOONGSON
++ bool "Loongson family of machines"
++ select SYS_SUPPORTS_ZBOOT
++ help
++ This enables the support of Loongson family of machines.
++
++ Loongson is a family of general-purpose MIPS-compatible CPUs.
++ developed at Institute of Computing Technology (ICT),
++ Chinese Academy of Sciences (CAS) in the People's Republic
++ of China. The chief architect is Professor Weiwu Hu.
++
++config MACH_LOONGSON1
++ bool "Loongson 1 family of machines"
++ select SYS_SUPPORTS_ZBOOT
++ help
++ This enables support for the Loongson 1 based machines.
++
++ Loongson 1 is a family of 32-bit MIPS-compatible SoCs developed by
++ the ICT (Institute of Computing Technology) and the Chinese Academy
++ of Sciences.
++
++config MIPS_MALTA
++ bool "MIPS Malta board"
++ select ARCH_MAY_HAVE_PC_FDC
++ select BOOT_ELF32
++ select BOOT_RAW
++ select CEVT_R4K
++ select CSRC_R4K
++ select CSRC_GIC
++ select DMA_NONCOHERENT
++ select GENERIC_ISA_DMA
++ select HAVE_PCSPKR_PLATFORM
++ select IRQ_CPU
++ select IRQ_GIC
++ select HW_HAS_PCI
++ select I8253
++ select I8259
++ select MIPS_BOARDS_GEN
++ select MIPS_BONITO64
++ select MIPS_CPU_SCACHE
++ select PCI_GT64XXX_PCI0
++ select MIPS_MSC
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_HAS_CPU_MIPS64_R1
++ select SYS_HAS_CPU_MIPS64_R2
++ select SYS_HAS_CPU_NEVADA
++ select SYS_HAS_CPU_RM7000
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_MIPS_CMP
++ select SYS_SUPPORTS_MULTITHREADING
++ select SYS_SUPPORTS_SMARTMIPS
++ select SYS_SUPPORTS_ZBOOT
++ help
++ This enables support for the MIPS Technologies Malta evaluation
++ board.
++
++config MIPS_SEAD3
++ bool "MIPS SEAD3 board"
++ select BOOT_ELF32
++ select BOOT_RAW
++ select CEVT_R4K
++ select CSRC_R4K
++ select CPU_MIPSR2_IRQ_VI
++ select CPU_MIPSR2_IRQ_EI
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select IRQ_GIC
++ select MIPS_BOARDS_GEN
++ select MIPS_CPU_SCACHE
++ select MIPS_MSC
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_HAS_CPU_MIPS64_R1
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_SMARTMIPS
++ select USB_ARCH_HAS_EHCI
++ select USB_EHCI_BIG_ENDIAN_DESC
++ select USB_EHCI_BIG_ENDIAN_MMIO
++ select USE_OF
++ help
++ This enables support for the MIPS Technologies SEAD3 evaluation
++ board.
++
++config NEC_MARKEINS
++ bool "NEC EMMA2RH Mark-eins board"
++ select SOC_EMMA2RH
++ select HW_HAS_PCI
++ help
++ This enables support for the NEC Electronics Mark-eins boards.
++
++config MACH_VR41XX
++ bool "NEC VR4100 series based machines"
++ select CEVT_R4K
++ select CSRC_R4K
++ select SYS_HAS_CPU_VR41XX
++ select ARCH_REQUIRE_GPIOLIB
++
++config NXP_STB220
++ bool "NXP STB220 board"
++ select SOC_PNX833X
++ help
++ Support for NXP Semiconductors STB220 Development Board.
++
++config NXP_STB225
++ bool "NXP 225 board"
++ select SOC_PNX833X
++ select SOC_PNX8335
++ help
++ Support for NXP Semiconductors STB225 Development Board.
++
++config PMC_MSP
++ bool "PMC-Sierra MSP chipsets"
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select SWAP_IO_SPACE
++ select NO_EXCEPT_FILL
++ select BOOT_RAW
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select IRQ_CPU
++ select SERIAL_8250
++ select SERIAL_8250_CONSOLE
++ help
++ This adds support for the PMC-Sierra family of Multi-Service
++ Processor System-On-A-Chips. These parts include a number
++ of integrated peripherals, interfaces and DSPs in addition to
++ a variety of MIPS cores.
++
++config POWERTV
++ bool "Cisco PowerTV"
++ select BOOT_ELF32
++ select CEVT_R4K
++ select CPU_MIPSR2_IRQ_VI
++ select CPU_MIPSR2_IRQ_EI
++ select CSRC_POWERTV
++ select DMA_NONCOHERENT
++ select HW_HAS_PCI
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select USB_OHCI_LITTLE_ENDIAN
++ help
++ This enables support for the Cisco PowerTV Platform.
++
++config RALINK
++ bool "Ralink based machines"
++ select CEVT_R4K
++ select CSRC_R4K
++ select BOOT_RAW
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select USE_OF
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_HAS_EARLY_PRINTK
++ select HAVE_MACH_CLKDEV
++ select CLKDEV_LOOKUP
++
++config SGI_IP22
++ bool "SGI IP22 (Indy/Indigo2)"
++ select FW_ARC
++ select FW_ARC32
++ select BOOT_ELF32
++ select CEVT_R4K
++ select CSRC_R4K
++ select DEFAULT_SGI_PARTITION
++ select DMA_NONCOHERENT
++ select HW_HAS_EISA
++ select I8253
++ select I8259
++ select IP22_CPU_SCACHE
++ select IRQ_CPU
++ select GENERIC_ISA_DMA_SUPPORT_BROKEN
++ select SGI_HAS_I8042
++ select SGI_HAS_INDYDOG
++ select SGI_HAS_HAL2
++ select SGI_HAS_SEEQ
++ select SGI_HAS_WD93
++ select SGI_HAS_ZILOG
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_R4X00
++ select SYS_HAS_CPU_R5000
++ #
++ # Disable EARLY_PRINTK for now since it leads to overwritten prom
++ # memory during early boot on some machines.
++ #
++ # See http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20091119164009.GA15038%40deprecation.cyrius.com
++ # for a more details discussion
++ #
++ # select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ help
++ This are the SGI Indy, Challenge S and Indigo2, as well as certain
++ OEM variants like the Tandem CMN B006S. To compile a Linux kernel
++ that runs on these, say Y here.
++
++config SGI_IP27
++ bool "SGI IP27 (Origin200/2000)"
++ select FW_ARC
++ select FW_ARC64
++ select BOOT_ELF64
++ select DEFAULT_SGI_PARTITION
++ select DMA_COHERENT
++ select SYS_HAS_EARLY_PRINTK
++ select HW_HAS_PCI
++ select NR_CPUS_DEFAULT_64
++ select SYS_HAS_CPU_R10000
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_NUMA
++ select SYS_SUPPORTS_SMP
++ help
++ This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
++ workstations. To compile a Linux kernel that runs on these, say Y
++ here.
++
++config SGI_IP28
++ bool "SGI IP28 (Indigo2 R10k)"
++ select FW_ARC
++ select FW_ARC64
++ select BOOT_ELF64
++ select CEVT_R4K
++ select CSRC_R4K
++ select DEFAULT_SGI_PARTITION
++ select DMA_NONCOHERENT
++ select GENERIC_ISA_DMA_SUPPORT_BROKEN
++ select IRQ_CPU
++ select HW_HAS_EISA
++ select I8253
++ select I8259
++ select SGI_HAS_I8042
++ select SGI_HAS_INDYDOG
++ select SGI_HAS_HAL2
++ select SGI_HAS_SEEQ
++ select SGI_HAS_WD93
++ select SGI_HAS_ZILOG
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_R10000
++ #
++ # Disable EARLY_PRINTK for now since it leads to overwritten prom
++ # memory during early boot on some machines.
++ #
++ # See http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=20091119164009.GA15038%40deprecation.cyrius.com
++ # for a more details discussion
++ #
++ # select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ help
++ This is the SGI Indigo2 with R10000 processor. To compile a Linux
++ kernel that runs on these, say Y here.
++
++config SGI_IP32
++ bool "SGI IP32 (O2)"
++ select FW_ARC
++ select FW_ARC32
++ select BOOT_ELF32
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select HW_HAS_PCI
++ select IRQ_CPU
++ select R5000_CPU_SCACHE
++ select RM7000_CPU_SCACHE
++ select SYS_HAS_CPU_R5000
++ select SYS_HAS_CPU_R10000 if BROKEN
++ select SYS_HAS_CPU_RM7000
++ select SYS_HAS_CPU_NEVADA
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ help
++ If you want this kernel to run on SGI O2 workstation, say Y here.
++
++config SIBYTE_CRHINE
++ bool "Sibyte BCM91120C-CRhine"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select SIBYTE_BCM1120
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config SIBYTE_CARMEL
++ bool "Sibyte BCM91120x-Carmel"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select SIBYTE_BCM1120
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config SIBYTE_CRHONE
++ bool "Sibyte BCM91125C-CRhone"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select SIBYTE_BCM1125
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config SIBYTE_RHONE
++ bool "Sibyte BCM91125E-Rhone"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select SIBYTE_BCM1125H
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config SIBYTE_SWARM
++ bool "Sibyte BCM91250A-SWARM"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select HAVE_PATA_PLATFORM
++ select NR_CPUS_DEFAULT_2
++ select SIBYTE_SB1250
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select ZONE_DMA32 if 64BIT
++
++config SIBYTE_LITTLESUR
++ bool "Sibyte BCM91250C2-LittleSur"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select HAVE_PATA_PLATFORM
++ select NR_CPUS_DEFAULT_2
++ select SIBYTE_SB1250
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config SIBYTE_SENTOSA
++ bool "Sibyte BCM91250E-Sentosa"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select NR_CPUS_DEFAULT_2
++ select SIBYTE_SB1250
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++
++config SIBYTE_BIGSUR
++ bool "Sibyte BCM91480B-BigSur"
++ select BOOT_ELF32
++ select DMA_COHERENT
++ select NR_CPUS_DEFAULT_4
++ select SIBYTE_BCM1x80
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_SB1
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select ZONE_DMA32 if 64BIT
++
++config SNI_RM
++ bool "SNI RM200/300/400"
++ select FW_ARC if CPU_LITTLE_ENDIAN
++ select FW_ARC32 if CPU_LITTLE_ENDIAN
++ select FW_SNIPROM if CPU_BIG_ENDIAN
++ select ARCH_MAY_HAVE_PC_FDC
++ select BOOT_ELF32
++ select CEVT_R4K
++ select CSRC_R4K
++ select DEFAULT_SGI_PARTITION if CPU_BIG_ENDIAN
++ select DMA_NONCOHERENT
++ select GENERIC_ISA_DMA
++ select HAVE_PCSPKR_PLATFORM
++ select HW_HAS_EISA
++ select HW_HAS_PCI
++ select IRQ_CPU
++ select I8253
++ select I8259
++ select ISA
++ select SWAP_IO_SPACE if CPU_BIG_ENDIAN
++ select SYS_HAS_CPU_R4X00
++ select SYS_HAS_CPU_R5000
++ select SYS_HAS_CPU_R10000
++ select R5000_CPU_SCACHE
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ help
++ The SNI RM200/300/400 are MIPS-based machines manufactured by
++ Siemens Nixdorf Informationssysteme (SNI), parent company of Pyramid
++ Technology and now in turn merged with Fujitsu. Say Y here to
++ support this machine type.
++
++config MACH_TX39XX
++ bool "Toshiba TX39 series based machines"
++
++config MACH_TX49XX
++ bool "Toshiba TX49 series based machines"
++
++config MIKROTIK_RB532
++ bool "Mikrotik RB532 boards"
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select HW_HAS_PCI
++ select IRQ_CPU
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SWAP_IO_SPACE
++ select BOOT_RAW
++ select ARCH_REQUIRE_GPIOLIB
++ help
++ Support the Mikrotik(tm) RouterBoard 532 series,
++ based on the IDT RC32434 SoC.
++
++config WR_PPMC
++ bool "Wind River PPMC board"
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select BOOT_ELF32
++ select DMA_NONCOHERENT
++ select HW_HAS_PCI
++ select PCI_GT64XXX_PCI0
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_MIPS32_R1
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_HAS_CPU_MIPS64_R1
++ select SYS_HAS_CPU_NEVADA
++ select SYS_HAS_CPU_RM7000
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ help
++ This enables support for the Wind River MIPS32 4KC PPMC evaluation
++ board, which is based on GT64120 bridge chip.
++
++config CAVIUM_OCTEON_SIMULATOR
++ bool "Cavium Networks Octeon Simulator"
++ select CEVT_R4K
++ select 64BIT_PHYS_ADDR
++ select DMA_COHERENT
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HOTPLUG_CPU
++ select SYS_HAS_CPU_CAVIUM_OCTEON
++ select HOLES_IN_ZONE
++ help
++ The Octeon simulator is software performance model of the Cavium
++ Octeon Processor. It supports simulating Octeon processors on x86
++ hardware.
++
++config CAVIUM_OCTEON_REFERENCE_BOARD
++ bool "Cavium Networks Octeon reference board"
++ select CEVT_R4K
++ select 64BIT_PHYS_ADDR
++ select DMA_COHERENT
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select EDAC_SUPPORT
++ select SYS_SUPPORTS_HOTPLUG_CPU
++ select SYS_HAS_EARLY_PRINTK
++ select SYS_HAS_CPU_CAVIUM_OCTEON
++ select SWAP_IO_SPACE
++ select HW_HAS_PCI
++ select ARCH_SUPPORTS_MSI
++ select ZONE_DMA32
++ select USB_ARCH_HAS_OHCI
++ select USB_ARCH_HAS_EHCI
++ select HOLES_IN_ZONE
++ help
++ This option supports all of the Octeon reference boards from Cavium
++ Networks. It builds a kernel that dynamically determines the Octeon
++ CPU type and supports all known board reference implementations.
++ Some of the supported boards are:
++ EBT3000
++ EBH3000
++ EBH3100
++ Thunder
++ Kodama
++ Hikari
++ Say Y here for most Octeon reference boards.
++
++config NLM_XLR_BOARD
++ bool "Netlogic XLR/XLS based systems"
++ select BOOT_ELF32
++ select NLM_COMMON
++ select SYS_HAS_CPU_XLR
++ select SYS_SUPPORTS_SMP
++ select HW_HAS_PCI
++ select SWAP_IO_SPACE
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select 64BIT_PHYS_ADDR
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select DMA_COHERENT
++ select NR_CPUS_DEFAULT_32
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select ARCH_SUPPORTS_MSI
++ select ZONE_DMA32 if 64BIT
++ select SYNC_R4K
++ select SYS_HAS_EARLY_PRINTK
++ select USB_ARCH_HAS_OHCI if USB_SUPPORT
++ select USB_ARCH_HAS_EHCI if USB_SUPPORT
++ help
++ Support for systems based on Netlogic XLR and XLS processors.
++ Say Y here if you have a XLR or XLS based board.
++
++config NLM_XLP_BOARD
++ bool "Netlogic XLP based systems"
++ select BOOT_ELF32
++ select NLM_COMMON
++ select SYS_HAS_CPU_XLP
++ select SYS_SUPPORTS_SMP
++ select HW_HAS_PCI
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select 64BIT_PHYS_ADDR
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_HIGHMEM
++ select DMA_COHERENT
++ select NR_CPUS_DEFAULT_32
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select ZONE_DMA32 if 64BIT
++ select SYNC_R4K
++ select SYS_HAS_EARLY_PRINTK
++ select USE_OF
++ help
++ This board is based on Netlogic XLP Processor.
++ Say Y here if you have a XLP based board.
++
++endchoice
++
++source "arch/mips/alchemy/Kconfig"
++source "arch/mips/ath79/Kconfig"
++source "arch/mips/bcm47xx/Kconfig"
++source "arch/mips/bcm63xx/Kconfig"
++source "arch/mips/jazz/Kconfig"
++source "arch/mips/jz4740/Kconfig"
++source "arch/mips/lantiq/Kconfig"
++source "arch/mips/lasat/Kconfig"
++source "arch/mips/pmcs-msp71xx/Kconfig"
++source "arch/mips/powertv/Kconfig"
++source "arch/mips/ralink/Kconfig"
++source "arch/mips/sgi-ip27/Kconfig"
++source "arch/mips/sibyte/Kconfig"
++source "arch/mips/txx9/Kconfig"
++source "arch/mips/vr41xx/Kconfig"
++source "arch/mips/cavium-octeon/Kconfig"
++source "arch/mips/loongson/Kconfig"
++source "arch/mips/loongson1/Kconfig"
++source "arch/mips/netlogic/Kconfig"
++
++endmenu
++
++config RWSEM_GENERIC_SPINLOCK
++ bool
++ default y
++
++config RWSEM_XCHGADD_ALGORITHM
++ bool
++
++config ARCH_HAS_ILOG2_U32
++ bool
++ default n
++
++config ARCH_HAS_ILOG2_U64
++ bool
++ default n
++
++config GENERIC_HWEIGHT
++ bool
++ default y
++
++config GENERIC_CALIBRATE_DELAY
++ bool
++ default y
++
++config SCHED_OMIT_FRAME_POINTER
++ bool
++ default y
++
++#
++# Select some configuration options automatically based on user selections.
++#
++config FW_ARC
++ bool
++
++config ARCH_MAY_HAVE_PC_FDC
++ bool
++
++config BOOT_RAW
++ bool
++
++config CEVT_BCM1480
++ bool
++
++config CEVT_DS1287
++ bool
++
++config CEVT_GT641XX
++ bool
++
++config CEVT_R4K
++ bool
++
++config CEVT_SB1250
++ bool
++
++config CEVT_TXX9
++ bool
++
++config CSRC_BCM1480
++ bool
++
++config CSRC_IOASIC
++ bool
++
++config CSRC_POWERTV
++ bool
++
++config CSRC_R4K
++ bool
++
++config CSRC_GIC
++ bool
++
++config CSRC_SB1250
++ bool
++
++config GPIO_TXX9
++ select GENERIC_GPIO
++ select ARCH_REQUIRE_GPIOLIB
++ bool
++
++config FW_CFE
++ bool
++
++config ARCH_DMA_ADDR_T_64BIT
++ def_bool (HIGHMEM && 64BIT_PHYS_ADDR) || 64BIT
++
++config DMA_COHERENT
++ bool
++
++config DMA_NONCOHERENT
++ bool
++ select NEED_DMA_MAP_STATE
++
++config NEED_DMA_MAP_STATE
++ bool
++
++config SYS_HAS_EARLY_PRINTK
++ bool
++
++config HOTPLUG_CPU
++ bool "Support for hot-pluggable CPUs"
++ depends on SMP && HOTPLUG && SYS_SUPPORTS_HOTPLUG_CPU
++ help
++ Say Y here to allow turning CPUs off and on. CPUs can be
++ controlled through /sys/devices/system/cpu.
++ (Note: power management support will enable this option
++ automatically on SMP systems. )
++ Say N if you want to disable CPU hotplug.
++
++config SYS_SUPPORTS_HOTPLUG_CPU
++ bool
++
++config I8259
++ bool
++
++config MIPS_BONITO64
++ bool
++
++config MIPS_MSC
++ bool
++
++config MIPS_NILE4
++ bool
++
++config MIPS_DISABLE_OBSOLETE_IDE
++ bool
++
++config SYNC_R4K
++ bool
++
++config MIPS_MACHINE
++ def_bool n
++
++config NO_IOPORT
++ def_bool n
++
++config GENERIC_ISA_DMA
++ bool
++ select ZONE_DMA if GENERIC_ISA_DMA_SUPPORT_BROKEN=n
++ select ISA_DMA_API
++
++config GENERIC_ISA_DMA_SUPPORT_BROKEN
++ bool
++ select GENERIC_ISA_DMA
++
++config ISA_DMA_API
++ bool
++
++config GENERIC_GPIO
++ bool
++
++config HOLES_IN_ZONE
++ bool
++
++#
++# Endianness selection. Sufficiently obscure so many users don't know what to
++# answer,so we try hard to limit the available choices. Also the use of a
++# choice statement should be more obvious to the user.
++#
++choice
++ prompt "Endianness selection"
++ help
++ Some MIPS machines can be configured for either little or big endian
++ byte order. These modes require different kernels and a different
++ Linux distribution. In general there is one preferred byteorder for a
++ particular system but some systems are just as commonly used in the
++ one or the other endianness.
++
++config CPU_BIG_ENDIAN
++ bool "Big endian"
++ depends on SYS_SUPPORTS_BIG_ENDIAN
++
++config CPU_LITTLE_ENDIAN
++ bool "Little endian"
++ depends on SYS_SUPPORTS_LITTLE_ENDIAN
++ help
++
++endchoice
++
++config EXPORT_UASM
++ bool
++
++config SYS_SUPPORTS_APM_EMULATION
++ bool
++
++config SYS_SUPPORTS_BIG_ENDIAN
++ bool
++
++config SYS_SUPPORTS_LITTLE_ENDIAN
++ bool
++
++config SYS_SUPPORTS_HUGETLBFS
++ bool
++ depends on CPU_SUPPORTS_HUGEPAGES && 64BIT
++ default y
++
++config MIPS_HUGE_TLB_SUPPORT
++ def_bool HUGETLB_PAGE || TRANSPARENT_HUGEPAGE
++
++config IRQ_CPU
++ bool
++
++config IRQ_CPU_RM7K
++ bool
++
++config IRQ_MSP_SLP
++ bool
++
++config IRQ_MSP_CIC
++ bool
++
++config IRQ_TXX9
++ bool
++
++config IRQ_GT641XX
++ bool
++
++config IRQ_GIC
++ bool
++
++config MIPS_BOARDS_GEN
++ bool
++
++config PCI_GT64XXX_PCI0
++ bool
++
++config NO_EXCEPT_FILL
++ bool
++
++config SOC_EMMA2RH
++ bool
++ select CEVT_R4K
++ select CSRC_R4K
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select SWAP_IO_SPACE
++ select SYS_HAS_CPU_R5500
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_BIG_ENDIAN
++
++config SOC_PNX833X
++ bool
++ select CEVT_R4K
++ select CSRC_R4K
++ select IRQ_CPU
++ select DMA_NONCOHERENT
++ select SYS_HAS_CPU_MIPS32_R2
++ select SYS_SUPPORTS_32BIT_KERNEL
++ select SYS_SUPPORTS_LITTLE_ENDIAN
++ select SYS_SUPPORTS_BIG_ENDIAN
++ select GENERIC_GPIO
++ select CPU_MIPSR2_IRQ_VI
++
++config SOC_PNX8335
++ bool
++ select SOC_PNX833X
++
++config SWAP_IO_SPACE
++ bool
++
++config SGI_HAS_INDYDOG
++ bool
++
++config SGI_HAS_HAL2
++ bool
++
++config SGI_HAS_SEEQ
++ bool
++
++config SGI_HAS_WD93
++ bool
++
++config SGI_HAS_ZILOG
++ bool
++
++config SGI_HAS_I8042
++ bool
++
++config DEFAULT_SGI_PARTITION
++ bool
++
++config FW_ARC32
++ bool
++
++config FW_SNIPROM
++ bool
++
++config BOOT_ELF32
++ bool
++
++config MIPS_L1_CACHE_SHIFT
++ int
++ default "4" if MACH_DECSTATION || MIKROTIK_RB532 || PMC_MSP4200_EVAL
++ default "6" if MIPS_CPU_SCACHE
++ default "7" if SGI_IP22 || SGI_IP27 || SGI_IP28 || SNI_RM || CPU_CAVIUM_OCTEON
++ default "5"
++
++config HAVE_STD_PC_SERIAL_PORT
++ bool
++
++config ARC_CONSOLE
++ bool "ARC console support"
++ depends on SGI_IP22 || SGI_IP28 || (SNI_RM && CPU_LITTLE_ENDIAN)
++
++config ARC_MEMORY
++ bool
++ depends on MACH_JAZZ || SNI_RM || SGI_IP32
++ default y
++
++config ARC_PROMLIB
++ bool
++ depends on MACH_JAZZ || SNI_RM || SGI_IP22 || SGI_IP28 || SGI_IP32
++ default y
++
++config FW_ARC64
++ bool
++
++config BOOT_ELF64
++ bool
++
++menu "CPU selection"
++
++choice
++ prompt "CPU type"
++ default CPU_R4X00
++
++config CPU_LOONGSON2E
++ bool "Loongson 2E"
++ depends on SYS_HAS_CPU_LOONGSON2E
++ select CPU_LOONGSON2
++ help
++ The Loongson 2E processor implements the MIPS III instruction set
++ with many extensions.
++
++ It has an internal FPGA northbridge, which is compatible to
++ bonito64.
++
++config CPU_LOONGSON2F
++ bool "Loongson 2F"
++ depends on SYS_HAS_CPU_LOONGSON2F
++ select CPU_LOONGSON2
++ select GENERIC_GPIO
++ select ARCH_REQUIRE_GPIOLIB
++ help
++ The Loongson 2F processor implements the MIPS III instruction set
++ with many extensions.
++
++ Loongson2F have built-in DDR2 and PCIX controller. The PCIX controller
++ have a similar programming interface with FPGA northbridge used in
++ Loongson2E.
++
++config CPU_LOONGSON1B
++ bool "Loongson 1B"
++ depends on SYS_HAS_CPU_LOONGSON1B
++ select CPU_LOONGSON1
++ help
++ The Loongson 1B is a 32-bit SoC, which implements the MIPS32
++ release 2 instruction set.
++
++config CPU_MIPS32_R1
++ bool "MIPS32 Release 1"
++ depends on SYS_HAS_CPU_MIPS32_R1
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ help
++ Choose this option to build a kernel for release 1 or later of the
++ MIPS32 architecture. Most modern embedded systems with a 32-bit
++ MIPS processor are based on a MIPS32 processor. If you know the
++ specific type of processor in your system, choose those that one
++ otherwise CPU_MIPS32_R1 is a safe bet for any MIPS32 system.
++ Release 2 of the MIPS32 architecture is available since several
++ years so chances are you even have a MIPS32 Release 2 processor
++ in which case you should choose CPU_MIPS32_R2 instead for better
++ performance.
++
++config CPU_MIPS32_R2
++ bool "MIPS32 Release 2"
++ depends on SYS_HAS_CPU_MIPS32_R2
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ help
++ Choose this option to build a kernel for release 2 or later of the
++ MIPS32 architecture. Most modern embedded systems with a 32-bit
++ MIPS processor are based on a MIPS32 processor. If you know the
++ specific type of processor in your system, choose those that one
++ otherwise CPU_MIPS32_R1 is a safe bet for any MIPS32 system.
++
++config CPU_MIPS64_R1
++ bool "MIPS64 Release 1"
++ depends on SYS_HAS_CPU_MIPS64_R1
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ Choose this option to build a kernel for release 1 or later of the
++ MIPS64 architecture. Many modern embedded systems with a 64-bit
++ MIPS processor are based on a MIPS64 processor. If you know the
++ specific type of processor in your system, choose those that one
++ otherwise CPU_MIPS64_R1 is a safe bet for any MIPS64 system.
++ Release 2 of the MIPS64 architecture is available since several
++ years so chances are you even have a MIPS64 Release 2 processor
++ in which case you should choose CPU_MIPS64_R2 instead for better
++ performance.
++
++config CPU_MIPS64_R2
++ bool "MIPS64 Release 2"
++ depends on SYS_HAS_CPU_MIPS64_R2
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ Choose this option to build a kernel for release 2 or later of the
++ MIPS64 architecture. Many modern embedded systems with a 64-bit
++ MIPS processor are based on a MIPS64 processor. If you know the
++ specific type of processor in your system, choose those that one
++ otherwise CPU_MIPS64_R1 is a safe bet for any MIPS64 system.
++
++config CPU_R3000
++ bool "R3000"
++ depends on SYS_HAS_CPU_R3000
++ select CPU_HAS_WB
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ help
++ Please make sure to pick the right CPU type. Linux/MIPS is not
++ designed to be generic, i.e. Kernels compiled for R3000 CPUs will
++ *not* work on R4000 machines and vice versa. However, since most
++ of the supported machines have an R4000 (or similar) CPU, R4x00
++ might be a safe bet. If the resulting kernel does not work,
++ try to recompile with R3000.
++
++config CPU_TX39XX
++ bool "R39XX"
++ depends on SYS_HAS_CPU_TX39XX
++ select CPU_SUPPORTS_32BIT_KERNEL
++
++config CPU_VR41XX
++ bool "R41xx"
++ depends on SYS_HAS_CPU_VR41XX
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ help
++ The options selects support for the NEC VR4100 series of processors.
++ Only choose this option if you have one of these processors as a
++ kernel built with this option will not run on any other type of
++ processor or vice versa.
++
++config CPU_R4300
++ bool "R4300"
++ depends on SYS_HAS_CPU_R4300
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ help
++ MIPS Technologies R4300-series processors.
++
++config CPU_R4X00
++ bool "R4x00"
++ depends on SYS_HAS_CPU_R4X00
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ MIPS Technologies R4000-series processors other than 4300, including
++ the R4000, R4400, R4600, and 4700.
++
++config CPU_TX49XX
++ bool "R49XX"
++ depends on SYS_HAS_CPU_TX49XX
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HUGEPAGES
++
++config CPU_R5000
++ bool "R5000"
++ depends on SYS_HAS_CPU_R5000
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ MIPS Technologies R5000-series processors other than the Nevada.
++
++config CPU_R5432
++ bool "R5432"
++ depends on SYS_HAS_CPU_R5432
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HUGEPAGES
++
++config CPU_R5500
++ bool "R5500"
++ depends on SYS_HAS_CPU_R5500
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ NEC VR5500 and VR5500A series processors implement 64-bit MIPS IV
++ instruction set.
++
++config CPU_R6000
++ bool "R6000"
++ depends on SYS_HAS_CPU_R6000
++ select CPU_SUPPORTS_32BIT_KERNEL
++ help
++ MIPS Technologies R6000 and R6000A series processors. Note these
++ processors are extremely rare and the support for them is incomplete.
++
++config CPU_NEVADA
++ bool "RM52xx"
++ depends on SYS_HAS_CPU_NEVADA
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ QED / PMC-Sierra RM52xx-series ("Nevada") processors.
++
++config CPU_R8000
++ bool "R8000"
++ depends on SYS_HAS_CPU_R8000
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_64BIT_KERNEL
++ help
++ MIPS Technologies R8000 processors. Note these processors are
++ uncommon and the support for them is incomplete.
++
++config CPU_R10000
++ bool "R10000"
++ depends on SYS_HAS_CPU_R10000
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++ help
++ MIPS Technologies R10000-series processors.
++
++config CPU_RM7000
++ bool "RM7000"
++ depends on SYS_HAS_CPU_RM7000
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++
++config CPU_SB1
++ bool "SB1"
++ depends on SYS_HAS_CPU_SB1
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++ select WEAK_ORDERING
++
++config CPU_CAVIUM_OCTEON
++ bool "Cavium Octeon processor"
++ depends on SYS_HAS_CPU_CAVIUM_OCTEON
++ select ARCH_SPARSEMEM_ENABLE
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select SYS_SUPPORTS_SMP
++ select NR_CPUS_DEFAULT_16
++ select WEAK_ORDERING
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++ select LIBFDT
++ select USE_OF
++ help
++ The Cavium Octeon processor is a highly integrated chip containing
++ many ethernet hardware widgets for networking tasks. The processor
++ can have up to 16 Mips64v2 cores and 8 integrated gigabit ethernets.
++ Full details can be found at http://www.caviumnetworks.com.
++
++config CPU_BMIPS3300
++ bool "BMIPS3300"
++ depends on SYS_HAS_CPU_BMIPS3300
++ select CPU_BMIPS
++ help
++ Broadcom BMIPS3300 processors.
++
++config CPU_BMIPS4350
++ bool "BMIPS4350"
++ depends on SYS_HAS_CPU_BMIPS4350
++ select CPU_BMIPS
++ select SYS_SUPPORTS_SMP
++ select SYS_SUPPORTS_HOTPLUG_CPU
++ help
++ Broadcom BMIPS4350 ("VIPER") processors.
++
++config CPU_BMIPS4380
++ bool "BMIPS4380"
++ depends on SYS_HAS_CPU_BMIPS4380
++ select CPU_BMIPS
++ select SYS_SUPPORTS_SMP
++ select SYS_SUPPORTS_HOTPLUG_CPU
++ help
++ Broadcom BMIPS4380 processors.
++
++config CPU_BMIPS5000
++ bool "BMIPS5000"
++ depends on SYS_HAS_CPU_BMIPS5000
++ select CPU_BMIPS
++ select CPU_SUPPORTS_HIGHMEM
++ select MIPS_CPU_SCACHE
++ select SYS_SUPPORTS_SMP
++ select SYS_SUPPORTS_HOTPLUG_CPU
++ help
++ Broadcom BMIPS5000 processors.
++
++config CPU_XLR
++ bool "Netlogic XLR SoC"
++ depends on SYS_HAS_CPU_XLR
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++ select WEAK_ORDERING
++ select WEAK_REORDERING_BEYOND_LLSC
++ help
++ Netlogic Microsystems XLR/XLS processors.
++
++config CPU_XLP
++ bool "Netlogic XLP SoC"
++ depends on SYS_HAS_CPU_XLP
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select WEAK_ORDERING
++ select WEAK_REORDERING_BEYOND_LLSC
++ select CPU_HAS_PREFETCH
++ select CPU_MIPSR2
++ help
++ Netlogic Microsystems XLP processors.
++endchoice
++
++if CPU_LOONGSON2F
++config CPU_NOP_WORKAROUNDS
++ bool
++
++config CPU_JUMP_WORKAROUNDS
++ bool
++
++config CPU_LOONGSON2F_WORKAROUNDS
++ bool "Loongson 2F Workarounds"
++ default y
++ select CPU_NOP_WORKAROUNDS
++ select CPU_JUMP_WORKAROUNDS
++ help
++ Loongson 2F01 / 2F02 processors have the NOP & JUMP issues which
++ require workarounds. Without workarounds the system may hang
++ unexpectedly. For more information please refer to the gas
++ -mfix-loongson2f-nop and -mfix-loongson2f-jump options.
++
++ Loongson 2F03 and later have fixed these issues and no workarounds
++ are needed. The workarounds have no significant side effect on them
++ but may decrease the performance of the system so this option should
++ be disabled unless the kernel is intended to be run on 2F01 or 2F02
++ systems.
++
++ If unsure, please say Y.
++endif # CPU_LOONGSON2F
++
++config SYS_SUPPORTS_ZBOOT
++ bool
++ select HAVE_KERNEL_GZIP
++ select HAVE_KERNEL_BZIP2
++ select HAVE_KERNEL_LZMA
++ select HAVE_KERNEL_LZO
++
++config SYS_SUPPORTS_ZBOOT_UART16550
++ bool
++ select SYS_SUPPORTS_ZBOOT
++
++config CPU_LOONGSON2
++ bool
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_64BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++ select CPU_SUPPORTS_HUGEPAGES
++
++config CPU_LOONGSON1
++ bool
++ select CPU_MIPS32
++ select CPU_MIPSR2
++ select CPU_HAS_PREFETCH
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select CPU_SUPPORTS_HIGHMEM
++
++config CPU_BMIPS
++ bool
++ select CPU_MIPS32
++ select CPU_SUPPORTS_32BIT_KERNEL
++ select DMA_NONCOHERENT
++ select IRQ_CPU
++ select SWAP_IO_SPACE
++ select WEAK_ORDERING
++
++config SYS_HAS_CPU_LOONGSON2E
++ bool
++
++config SYS_HAS_CPU_LOONGSON2F
++ bool
++ select CPU_SUPPORTS_CPUFREQ
++ select CPU_SUPPORTS_ADDRWINCFG if 64BIT
++ select CPU_SUPPORTS_UNCACHED_ACCELERATED
++
++config SYS_HAS_CPU_LOONGSON1B
++ bool
++
++config SYS_HAS_CPU_MIPS32_R1
++ bool
++
++config SYS_HAS_CPU_MIPS32_R2
++ bool
++
++config SYS_HAS_CPU_MIPS64_R1
++ bool
++
++config SYS_HAS_CPU_MIPS64_R2
++ bool
++
++config SYS_HAS_CPU_R3000
++ bool
++
++config SYS_HAS_CPU_TX39XX
++ bool
++
++config SYS_HAS_CPU_VR41XX
++ bool
++
++config SYS_HAS_CPU_R4300
++ bool
++
++config SYS_HAS_CPU_R4X00
++ bool
++
++config SYS_HAS_CPU_TX49XX
++ bool
++
++config SYS_HAS_CPU_R5000
++ bool
++
++config SYS_HAS_CPU_R5432
++ bool
++
++config SYS_HAS_CPU_R5500
++ bool
++
++config SYS_HAS_CPU_R6000
++ bool
++
++config SYS_HAS_CPU_NEVADA
++ bool
++
++config SYS_HAS_CPU_R8000
++ bool
++
++config SYS_HAS_CPU_R10000
++ bool
++
++config SYS_HAS_CPU_RM7000
++ bool
++
++config SYS_HAS_CPU_SB1
++ bool
++
++config SYS_HAS_CPU_CAVIUM_OCTEON
++ bool
++
++config SYS_HAS_CPU_BMIPS3300
++ bool
++
++config SYS_HAS_CPU_BMIPS4350
++ bool
++
++config SYS_HAS_CPU_BMIPS4380
++ bool
++
++config SYS_HAS_CPU_BMIPS5000
++ bool
++
++config SYS_HAS_CPU_XLR
++ bool
++
++config SYS_HAS_CPU_XLP
++ bool
++
++#
++# CPU may reorder R->R, R->W, W->R, W->W
++# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
++#
++config WEAK_ORDERING
++ bool
++
++#
++# CPU may reorder reads and writes beyond LL/SC
++# CPU may reorder R->LL, R->LL, W->LL, W->LL, R->SC, R->SC, W->SC, W->SC
++#
++config WEAK_REORDERING_BEYOND_LLSC
++ bool
++endmenu
++
++#
++# These two indicate any level of the MIPS32 and MIPS64 architecture
++#
++config CPU_MIPS32
++ bool
++ default y if CPU_MIPS32_R1 || CPU_MIPS32_R2
++
++config CPU_MIPS64
++ bool
++ default y if CPU_MIPS64_R1 || CPU_MIPS64_R2
++
++#
++# These two indicate the revision of the architecture, either Release 1 or Release 2
++#
++config CPU_MIPSR1
++ bool
++ default y if CPU_MIPS32_R1 || CPU_MIPS64_R1
++
++config CPU_MIPSR2
++ bool
++ default y if CPU_MIPS32_R2 || CPU_MIPS64_R2 || CPU_CAVIUM_OCTEON
++
++config SYS_SUPPORTS_32BIT_KERNEL
++ bool
++config SYS_SUPPORTS_64BIT_KERNEL
++ bool
++config CPU_SUPPORTS_32BIT_KERNEL
++ bool
++config CPU_SUPPORTS_64BIT_KERNEL
++ bool
++config CPU_SUPPORTS_CPUFREQ
++ bool
++config CPU_SUPPORTS_ADDRWINCFG
++ bool
++config CPU_SUPPORTS_HUGEPAGES
++ bool
++config CPU_SUPPORTS_UNCACHED_ACCELERATED
++ bool
++config MIPS_PGD_C0_CONTEXT
++ bool
++ default y if 64BIT && CPU_MIPSR2 && !CPU_XLP
++
++#
++# Set to y for ptrace access to watch registers.
++#
++config HARDWARE_WATCHPOINTS
++ bool
++ default y if CPU_MIPSR1 || CPU_MIPSR2
++
++menu "Kernel type"
++
++choice
++ prompt "Kernel code model"
++ help
++ You should only select this option if you have a workload that
++ actually benefits from 64-bit processing or if your machine has
++ large memory. You will only be presented a single option in this
++ menu if your system does not support both 32-bit and 64-bit kernels.
++
++config 32BIT
++ bool "32-bit kernel"
++ depends on CPU_SUPPORTS_32BIT_KERNEL && SYS_SUPPORTS_32BIT_KERNEL
++ select TRAD_SIGNALS
++ help
++ Select this option if you want to build a 32-bit kernel.
++config 64BIT
++ bool "64-bit kernel"
++ depends on CPU_SUPPORTS_64BIT_KERNEL && SYS_SUPPORTS_64BIT_KERNEL
++ select HAVE_SYSCALL_WRAPPERS
++ help
++ Select this option if you want to build a 64-bit kernel.
++
++endchoice
++
++choice
++ prompt "Kernel page size"
++ default PAGE_SIZE_4KB
++
++config PAGE_SIZE_4KB
++ bool "4kB"
++ depends on !CPU_LOONGSON2
++ help
++ This option select the standard 4kB Linux page size. On some
++ R3000-family processors this is the only available page size. Using
++ 4kB page size will minimize memory consumption and is therefore
++ recommended for low memory systems.
++
++config PAGE_SIZE_8KB
++ bool "8kB"
++ depends on CPU_R8000 || CPU_CAVIUM_OCTEON
++ help
++ Using 8kB page size will result in higher performance kernel at
++ the price of higher memory consumption. This option is available
++ only on R8000 and cnMIPS processors. Note that you will need a
++ suitable Linux distribution to support this.
++
++config PAGE_SIZE_16KB
++ bool "16kB"
++ depends on !CPU_R3000 && !CPU_TX39XX
++ help
++ Using 16kB page size will result in higher performance kernel at
++ the price of higher memory consumption. This option is available on
++ all non-R3000 family processors. Note that you will need a suitable
++ Linux distribution to support this.
++
++config PAGE_SIZE_32KB
++ bool "32kB"
++ depends on CPU_CAVIUM_OCTEON
++ help
++ Using 32kB page size will result in higher performance kernel at
++ the price of higher memory consumption. This option is available
++ only on cnMIPS cores. Note that you will need a suitable Linux
++ distribution to support this.
++
++config PAGE_SIZE_64KB
++ bool "64kB"
++ depends on !CPU_R3000 && !CPU_TX39XX
++ help
++ Using 64kB page size will result in higher performance kernel at
++ the price of higher memory consumption. This option is available on
++ all non-R3000 family processor. Not that at the time of this
++ writing this option is still high experimental.
++
++endchoice
++
++config FORCE_MAX_ZONEORDER
++ int "Maximum zone order"
++ range 14 64 if HUGETLB_PAGE && PAGE_SIZE_64KB
++ default "14" if HUGETLB_PAGE && PAGE_SIZE_64KB
++ range 13 64 if HUGETLB_PAGE && PAGE_SIZE_32KB
++ default "13" if HUGETLB_PAGE && PAGE_SIZE_32KB
++ range 12 64 if HUGETLB_PAGE && PAGE_SIZE_16KB
++ default "12" if HUGETLB_PAGE && PAGE_SIZE_16KB
++ range 11 64
++ default "11"
++ help
++ The kernel memory allocator divides physically contiguous memory
++ blocks into "zones", where each zone is a power of two number of
++ pages. This option selects the largest power of two that the kernel
++ keeps in the memory allocator. If you need to allocate very large
++ blocks of physically contiguous memory, then you may need to
++ increase this value.
++
++ This config option is actually maximum order plus one. For example,
++ a value of 11 means that the largest free memory block is 2^10 pages.
++
++ The page size is not necessarily 4KB. Keep this in mind
++ when choosing a value for this option.
++
++config BOARD_SCACHE
++ bool
++
++config IP22_CPU_SCACHE
++ bool
++ select BOARD_SCACHE
++
++#
++# Support for a MIPS32 / MIPS64 style S-caches
++#
++config MIPS_CPU_SCACHE
++ bool
++ select BOARD_SCACHE
++
++config R5000_CPU_SCACHE
++ bool
++ select BOARD_SCACHE
++
++config RM7000_CPU_SCACHE
++ bool
++ select BOARD_SCACHE
++
++config SIBYTE_DMA_PAGEOPS
++ bool "Use DMA to clear/copy pages"
++ depends on CPU_SB1
++ help
++ Instead of using the CPU to zero and copy pages, use a Data Mover
++ channel. These DMA channels are otherwise unused by the standard
++ SiByte Linux port. Seems to give a small performance benefit.
++
++config CPU_HAS_PREFETCH
++ bool
++
++config CPU_GENERIC_DUMP_TLB
++ bool
++ default y if !(CPU_R3000 || CPU_R6000 || CPU_R8000 || CPU_TX39XX)
++
++config CPU_R4K_FPU
++ bool
++ default y if !(CPU_R3000 || CPU_R6000 || CPU_TX39XX || CPU_CAVIUM_OCTEON)
++
++config CPU_R4K_CACHE_TLB
++ bool
++ default y if !(CPU_R3000 || CPU_R8000 || CPU_SB1 || CPU_TX39XX || CPU_CAVIUM_OCTEON)
++
++choice
++ prompt "MIPS MT options"
++
++config MIPS_MT_DISABLED
++ bool "Disable multithreading support."
++ help
++ Use this option if your workload can't take advantage of
++ MIPS hardware multithreading support. On systems that don't have
++ the option of an MT-enabled processor this option will be the only
++ option in this menu.
++
++config MIPS_MT_SMP
++ bool "Use 1 TC on each available VPE for SMP"
++ depends on SYS_SUPPORTS_MULTITHREADING
++ select CPU_MIPSR2_IRQ_VI
++ select CPU_MIPSR2_IRQ_EI
++ select MIPS_MT
++ select NR_CPUS_DEFAULT_2
++ select SMP
++ select SYS_SUPPORTS_SCHED_SMT if SMP
++ select SYS_SUPPORTS_SMP
++ select SMP_UP
++ select MIPS_PERF_SHARED_TC_COUNTERS
++ help
++ This is a kernel model which is known a VSMP but lately has been
++ marketesed into SMVP.
++ Virtual SMP uses the processor's VPEs to implement virtual
++ processors. In currently available configuration of the 34K processor
++ this allows for a dual processor. Both processors will share the same
++ primary caches; each will obtain the half of the TLB for it's own
++ exclusive use. For a layman this model can be described as similar to
++ what Intel calls Hyperthreading.
++
++ For further information see http://www.linux-mips.org/wiki/34K#VSMP
++
++config MIPS_MT_SMTC
++ bool "SMTC: Use all TCs on all VPEs for SMP"
++ depends on CPU_MIPS32_R2
++ #depends on CPU_MIPS64_R2 # once there is hardware ...
++ depends on SYS_SUPPORTS_MULTITHREADING
++ select CPU_MIPSR2_IRQ_VI
++ select CPU_MIPSR2_IRQ_EI
++ select MIPS_MT
++ select NR_CPUS_DEFAULT_8
++ select SMP
++ select SYS_SUPPORTS_SMP
++ select SMP_UP
++ help
++ This is a kernel model which is known a SMTC or lately has been
++ marketesed into SMVP.
++ is presenting the available TC's of the core as processors to Linux.
++ On currently available 34K processors this means a Linux system will
++ see up to 5 processors. The implementation of the SMTC kernel differs
++ significantly from VSMP and cannot efficiently coexist in the same
++ kernel binary so the choice between VSMP and SMTC is a compile time
++ decision.
++
++ For further information see http://www.linux-mips.org/wiki/34K#SMTC
++
++endchoice
++
++config MIPS_MT
++ bool
++
++config SCHED_SMT
++ bool "SMT (multithreading) scheduler support"
++ depends on SYS_SUPPORTS_SCHED_SMT
++ default n
++ help
++ SMT scheduler support improves the CPU scheduler's decision making
++ when dealing with MIPS MT enabled cores at a cost of slightly
++ increased overhead in some places. If unsure say N here.
++
++config SYS_SUPPORTS_SCHED_SMT
++ bool
++
++config SYS_SUPPORTS_MULTITHREADING
++ bool
++
++config MIPS_MT_FPAFF
++ bool "Dynamic FPU affinity for FP-intensive threads"
++ default y
++ depends on MIPS_MT_SMP || MIPS_MT_SMTC
++
++config MIPS_VPE_LOADER
++ bool "VPE loader support."
++ depends on SYS_SUPPORTS_MULTITHREADING
++ select CPU_MIPSR2_IRQ_VI
++ select CPU_MIPSR2_IRQ_EI
++ select MIPS_MT
++ help
++ Includes a loader for loading an elf relocatable object
++ onto another VPE and running it.
++
++config MIPS_MT_SMTC_IM_BACKSTOP
++ bool "Use per-TC register bits as backstop for inhibited IM bits"
++ depends on MIPS_MT_SMTC
++ default n
++ help
++ To support multiple TC microthreads acting as "CPUs" within
++ a VPE, VPE-wide interrupt mask bits must be specially manipulated
++ during interrupt handling. To support legacy drivers and interrupt
++ controller management code, SMTC has a "backstop" to track and
++ if necessary restore the interrupt mask. This has some performance
++ impact on interrupt service overhead.
++
++config MIPS_MT_SMTC_IRQAFF
++ bool "Support IRQ affinity API"
++ depends on MIPS_MT_SMTC
++ default n
++ help
++ Enables SMP IRQ affinity API (/proc/irq/*/smp_affinity, etc.)
++ for SMTC Linux kernel. Requires platform support, of which
++ an example can be found in the MIPS kernel i8259 and Malta
++ platform code. Adds some overhead to interrupt dispatch, and
++ should be used only if you know what you are doing.
++
++config MIPS_VPE_LOADER_TOM
++ bool "Load VPE program into memory hidden from linux"
++ depends on MIPS_VPE_LOADER
++ default y
++ help
++ The loader can use memory that is present but has been hidden from
++ Linux using the kernel command line option "mem=xxMB". It's up to
++ you to ensure the amount you put in the option and the space your
++ program requires is less or equal to the amount physically present.
++
++# this should possibly be in drivers/char, but it is rather cpu related. Hmmm
++config MIPS_VPE_APSP_API
++ bool "Enable support for AP/SP API (RTLX)"
++ depends on MIPS_VPE_LOADER
++ help
++
++config MIPS_CMP
++ bool "MIPS CMP framework support"
++ depends on SYS_SUPPORTS_MIPS_CMP
++ select SYNC_R4K
++ select SYS_SUPPORTS_SMP
++ select SYS_SUPPORTS_SCHED_SMT if SMP
++ select WEAK_ORDERING
++ default n
++ help
++ This is a placeholder option for the GCMP work. It will need to
++ be handled differently...
++
++config SB1_PASS_1_WORKAROUNDS
++ bool
++ depends on CPU_SB1_PASS_1
++ default y
++
++config SB1_PASS_2_WORKAROUNDS
++ bool
++ depends on CPU_SB1 && (CPU_SB1_PASS_2_2 || CPU_SB1_PASS_2)
++ default y
++
++config SB1_PASS_2_1_WORKAROUNDS
++ bool
++ depends on CPU_SB1 && CPU_SB1_PASS_2
++ default y
++
++config 64BIT_PHYS_ADDR
++ bool
++
++config ARCH_PHYS_ADDR_T_64BIT
++ def_bool 64BIT_PHYS_ADDR
++
++config CPU_HAS_SMARTMIPS
++ depends on SYS_SUPPORTS_SMARTMIPS
++ bool "Support for the SmartMIPS ASE"
++ help
++ SmartMIPS is a extension of the MIPS32 architecture aimed at
++ increased security at both hardware and software level for
++ smartcards. Enabling this option will allow proper use of the
++ SmartMIPS instructions by Linux applications. However a kernel with
++ this option will not work on a MIPS core without SmartMIPS core. If
++ you don't know you probably don't have SmartMIPS and should say N
++ here.
++
++config CPU_HAS_WB
++ bool
++
++config XKS01
++ bool
++
++#
++# Vectored interrupt mode is an R2 feature
++#
++config CPU_MIPSR2_IRQ_VI
++ bool
++
++#
++# Extended interrupt mode is an R2 feature
++#
++config CPU_MIPSR2_IRQ_EI
++ bool
++
++config CPU_HAS_SYNC
++ bool
++ depends on !CPU_R3000
++ default y
++
++#
++# CPU non-features
++#
++config CPU_DADDI_WORKAROUNDS
++ bool
++
++config CPU_R4000_WORKAROUNDS
++ bool
++ select CPU_R4400_WORKAROUNDS
++
++config CPU_R4400_WORKAROUNDS
++ bool
++
++#
++# - Highmem only makes sense for the 32-bit kernel.
++# - The current highmem code will only work properly on physically indexed
++# caches such as R3000, SB1, R7000 or those that look like they're virtually
++# indexed such as R4000/R4400 SC and MC versions or R10000. So for the
++# moment we protect the user and offer the highmem option only on machines
++# where it's known to be safe. This will not offer highmem on a few systems
++# such as MIPS32 and MIPS64 CPUs which may have virtual and physically
++# indexed CPUs but we're playing safe.
++# - We use SYS_SUPPORTS_HIGHMEM to offer highmem only for systems where we
++# know they might have memory configurations that could make use of highmem
++# support.
++#
++config HIGHMEM
++ bool "High Memory Support"
++ depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM
++
++config CPU_SUPPORTS_HIGHMEM
++ bool
++
++config SYS_SUPPORTS_HIGHMEM
++ bool
++
++config SYS_SUPPORTS_SMARTMIPS
++ bool
++
++config ARCH_FLATMEM_ENABLE
++ def_bool y
++ depends on !NUMA && !CPU_LOONGSON2
++
++config ARCH_DISCONTIGMEM_ENABLE
++ bool
++ default y if SGI_IP27
++ help
++ Say Y to support efficient handling of discontiguous physical memory,
++ for architectures which are either NUMA (Non-Uniform Memory Access)
++ or have huge holes in the physical address space for other reasons.
++ See <file:Documentation/vm/numa> for more.
++
++config ARCH_SPARSEMEM_ENABLE
++ bool
++ select SPARSEMEM_STATIC
++
++config NUMA
++ bool "NUMA Support"
++ depends on SYS_SUPPORTS_NUMA
++ help
++ Say Y to compile the kernel to support NUMA (Non-Uniform Memory
++ Access). This option improves performance on systems with more
++ than two nodes; on two node systems it is generally better to
++ leave it disabled; on single node systems disable this option
++ disabled.
++
++config SYS_SUPPORTS_NUMA
++ bool
++
++config NODES_SHIFT
++ int
++ default "6"
++ depends on NEED_MULTIPLE_NODES
++
++config HW_PERF_EVENTS
++ bool "Enable hardware performance counter support for perf events"
++ depends on PERF_EVENTS && !MIPS_MT_SMTC && OPROFILE=n && (CPU_MIPS32 || CPU_MIPS64 || CPU_R10000 || CPU_SB1 || CPU_CAVIUM_OCTEON || CPU_XLP)
++ default y
++ help
++ Enable hardware performance counter support for perf events. If
++ disabled, perf events will use software events only.
++
++source "mm/Kconfig"
++
++config SMP
++ bool "Multi-Processing support"
++ depends on SYS_SUPPORTS_SMP
++ select USE_GENERIC_SMP_HELPERS
++ help
++ This enables support for systems with more than one CPU. If you have
++ a system with only one CPU, like most personal computers, say N. If
++ you have a system with more than one CPU, say Y.
++
++ If you say N here, the kernel will run on single and multiprocessor
++ machines, but will use only one CPU of a multiprocessor machine. If
++ you say Y here, the kernel will run on many, but not all,
++ singleprocessor machines. On a singleprocessor machine, the kernel
++ will run faster if you say N here.
++
++ People using multiprocessor machines who say Y here should also say
++ Y to "Enhanced Real Time Clock Support", below.
++
++ See also the SMP-HOWTO available at
++ <http://www.tldp.org/docs.html#howto>.
++
++ If you don't know what to do here, say N.
++
++config SMP_UP
++ bool
++
++config SYS_SUPPORTS_MIPS_CMP
++ bool
++
++config SYS_SUPPORTS_SMP
++ bool
++
++config NR_CPUS_DEFAULT_1
++ bool
++
++config NR_CPUS_DEFAULT_2
++ bool
++
++config NR_CPUS_DEFAULT_4
++ bool
++
++config NR_CPUS_DEFAULT_8
++ bool
++
++config NR_CPUS_DEFAULT_16
++ bool
++
++config NR_CPUS_DEFAULT_32
++ bool
++
++config NR_CPUS_DEFAULT_64
++ bool
++
++config NR_CPUS
++ int "Maximum number of CPUs (2-64)"
++ range 1 64 if NR_CPUS_DEFAULT_1
++ depends on SMP
++ default "1" if NR_CPUS_DEFAULT_1
++ default "2" if NR_CPUS_DEFAULT_2
++ default "4" if NR_CPUS_DEFAULT_4
++ default "8" if NR_CPUS_DEFAULT_8
++ default "16" if NR_CPUS_DEFAULT_16
++ default "32" if NR_CPUS_DEFAULT_32
++ default "64" if NR_CPUS_DEFAULT_64
++ help
++ This allows you to specify the maximum number of CPUs which this
++ kernel will support. The maximum supported value is 32 for 32-bit
++ kernel and 64 for 64-bit kernels; the minimum value which makes
++ sense is 1 for Qemu (useful only for kernel debugging purposes)
++ and 2 for all others.
++
++ This is purely to save memory - each supported CPU adds
++ approximately eight kilobytes to the kernel image. For best
++ performance should round up your number of processors to the next
++ power of two.
++
++config MIPS_PERF_SHARED_TC_COUNTERS
++ bool
++
++#
++# Timer Interrupt Frequency Configuration
++#
++
++choice
++ prompt "Timer frequency"
++ default HZ_250
++ help
++ Allows the configuration of the timer frequency.
++
++ config HZ_48
++ bool "48 HZ" if SYS_SUPPORTS_48HZ || SYS_SUPPORTS_ARBIT_HZ
++
++ config HZ_100
++ bool "100 HZ" if SYS_SUPPORTS_100HZ || SYS_SUPPORTS_ARBIT_HZ
++
++ config HZ_128
++ bool "128 HZ" if SYS_SUPPORTS_128HZ || SYS_SUPPORTS_ARBIT_HZ
++
++ config HZ_250
++ bool "250 HZ" if SYS_SUPPORTS_250HZ || SYS_SUPPORTS_ARBIT_HZ
++
++ config HZ_256
++ bool "256 HZ" if SYS_SUPPORTS_256HZ || SYS_SUPPORTS_ARBIT_HZ
++
++ config HZ_1000
++ bool "1000 HZ" if SYS_SUPPORTS_1000HZ || SYS_SUPPORTS_ARBIT_HZ
++
++ config HZ_1024
++ bool "1024 HZ" if SYS_SUPPORTS_1024HZ || SYS_SUPPORTS_ARBIT_HZ
++
++endchoice
++
++config SYS_SUPPORTS_48HZ
++ bool
++
++config SYS_SUPPORTS_100HZ
++ bool
++
++config SYS_SUPPORTS_128HZ
++ bool
++
++config SYS_SUPPORTS_250HZ
++ bool
++
++config SYS_SUPPORTS_256HZ
++ bool
++
++config SYS_SUPPORTS_1000HZ
++ bool
++
++config SYS_SUPPORTS_1024HZ
++ bool
++
++config SYS_SUPPORTS_ARBIT_HZ
++ bool
++ default y if !SYS_SUPPORTS_48HZ && !SYS_SUPPORTS_100HZ && \
++ !SYS_SUPPORTS_128HZ && !SYS_SUPPORTS_250HZ && \
++ !SYS_SUPPORTS_256HZ && !SYS_SUPPORTS_1000HZ && \
++ !SYS_SUPPORTS_1024HZ
++
++config HZ
++ int
++ default 48 if HZ_48
++ default 100 if HZ_100
++ default 128 if HZ_128
++ default 250 if HZ_250
++ default 256 if HZ_256
++ default 1000 if HZ_1000
++ default 1024 if HZ_1024
++
++source "kernel/Kconfig.preempt"
++
++config KEXEC
++ bool "Kexec system call"
++ help
++ kexec is a system call that implements the ability to shutdown your
++ current kernel, and to start another kernel. It is like a reboot
++ but it is independent of the system firmware. And like a reboot
++ you can start any kernel with it, not just Linux.
++
++ The name comes from the similarity to the exec system call.
++
++ It is an ongoing process to be certain the hardware in a machine
++ is properly shutdown, so do not be surprised if this code does not
++ initially work for you. It may help to enable device hotplugging
++ support. As of this writing the exact hardware interface is
++ strongly in flux, so no good recommendation can be made.
++
++config CRASH_DUMP
++ bool "Kernel crash dumps"
++ help
++ Generate crash dump after being started by kexec.
++ This should be normally only set in special crash dump kernels
++ which are loaded in the main kernel with kexec-tools into
++ a specially reserved region and then later executed after
++ a crash by kdump/kexec. The crash dump kernel must be compiled
++ to a memory address not used by the main kernel or firmware using
++ PHYSICAL_START.
++
++config PHYSICAL_START
++ hex "Physical address where the kernel is loaded"
++ default "0xffffffff84000000" if 64BIT
++ default "0x84000000" if 32BIT
++ depends on CRASH_DUMP
++ help
++ This gives the CKSEG0 or KSEG0 address where the kernel is loaded.
++ If you plan to use kernel for capturing the crash dump change
++ this value to start of the reserved region (the "X" value as
++ specified in the "crashkernel=YM@XM" command line boot parameter
++ passed to the panic-ed kernel).
++
++config SECCOMP
++ bool "Enable seccomp to safely compute untrusted bytecode"
++ depends on PROC_FS
++ default y
++ help
++ This kernel feature is useful for number crunching applications
++ that may need to compute untrusted bytecode during their
++ execution. By using pipes or other transports made available to
++ the process as file descriptors supporting the read/write
++ syscalls, it's possible to isolate those applications in
++ their own address space using seccomp. Once seccomp is
++ enabled via /proc/<pid>/seccomp, it cannot be disabled
++ and the task is only allowed to execute a few safe syscalls
++ defined by each seccomp mode.
++
++ If unsure, say Y. Only embedded should say N here.
++
++config USE_OF
++ bool
++ select OF
++ select OF_EARLY_FLATTREE
++ select IRQ_DOMAIN
++
++endmenu
++
++config LOCKDEP_SUPPORT
++ bool
++ default y
++
++config STACKTRACE_SUPPORT
++ bool
++ default y
++
++source "init/Kconfig"
++
++source "kernel/Kconfig.freezer"
++
++menu "Bus options (PCI, PCMCIA, EISA, ISA, TC)"
++
++config HW_HAS_EISA
++ bool
++config HW_HAS_PCI
++ bool
++
++config PCI
++ bool "Support for PCI controller"
++ depends on HW_HAS_PCI
++ select PCI_DOMAINS
++ select GENERIC_PCI_IOMAP
++ select NO_GENERIC_PCI_IOPORT_MAP
++ help
++ Find out whether you have a PCI motherboard. PCI is the name of a
++ bus system, i.e. the way the CPU talks to the other stuff inside
++ your box. Other bus systems are ISA, EISA, or VESA. If you have PCI,
++ say Y, otherwise N.
++
++config PCI_DOMAINS
++ bool
++
++source "drivers/pci/Kconfig"
++
++source "drivers/pci/pcie/Kconfig"
++
++#
++# ISA support is now enabled via select. Too many systems still have the one
++# or other ISA chip on the board that users don't know about so don't expect
++# users to choose the right thing ...
++#
++config ISA
++ bool
++
++config EISA
++ bool "EISA support"
++ depends on HW_HAS_EISA
++ select ISA
++ select GENERIC_ISA_DMA
++ ---help---
++ The Extended Industry Standard Architecture (EISA) bus was
++ developed as an open alternative to the IBM MicroChannel bus.
++
++ The EISA bus provided some of the features of the IBM MicroChannel
++ bus while maintaining backward compatibility with cards made for
++ the older ISA bus. The EISA bus saw limited use between 1988 and
++ 1995 when it was made obsolete by the PCI bus.
++
++ Say Y here if you are building a kernel for an EISA-based machine.
++
++ Otherwise, say N.
++
++source "drivers/eisa/Kconfig"
++
++config TC
++ bool "TURBOchannel support"
++ depends on MACH_DECSTATION
++ help
++ TURBOchannel is a DEC (now Compaq (now HP)) bus for Alpha and MIPS
++ processors. TURBOchannel programming specifications are available
++ at:
++ <ftp://ftp.hp.com/pub/alphaserver/archive/triadd/>
++ and:
++ <http://www.computer-refuge.org/classiccmp/ftp.digital.com/pub/DEC/TriAdd/>
++ Linux driver support status is documented at:
++ <http://www.linux-mips.org/wiki/DECstation>
++
++config MMU
++ bool
++ default y
++
++config I8253
++ bool
++ select CLKSRC_I8253
++ select CLKEVT_I8253
++ select MIPS_EXTERNAL_TIMER
++
++config ZONE_DMA32
++ bool
++
++source "drivers/pcmcia/Kconfig"
++
++source "drivers/pci/hotplug/Kconfig"
++
++config RAPIDIO
++ bool "RapidIO support"
++ depends on PCI
++ default n
++ help
++ If you say Y here, the kernel will include drivers and
++ infrastructure code to support RapidIO interconnect devices.
++
++source "drivers/rapidio/Kconfig"
++
++endmenu
++
++menu "Executable file formats"
++
++source "fs/Kconfig.binfmt"
++
++config TRAD_SIGNALS
++ bool
++
++config MIPS32_COMPAT
++ bool "Kernel support for Linux/MIPS 32-bit binary compatibility"
++ depends on 64BIT
++ help
++ Select this option if you want Linux/MIPS 32-bit binary
++ compatibility. Since all software available for Linux/MIPS is
++ currently 32-bit you should say Y here.
++
++config COMPAT
++ bool
++ depends on MIPS32_COMPAT
++ select ARCH_WANT_OLD_COMPAT_IPC
++ default y
++
++config SYSVIPC_COMPAT
++ bool
++ depends on COMPAT && SYSVIPC
++ default y
++
++config MIPS32_O32
++ bool "Kernel support for o32 binaries"
++ depends on MIPS32_COMPAT
++ help
++ Select this option if you want to run o32 binaries. These are pure
++ 32-bit binaries as used by the 32-bit Linux/MIPS port. Most of
++ existing binaries are in this format.
++
++ If unsure, say Y.
++
++config MIPS32_N32
++ bool "Kernel support for n32 binaries"
++ depends on MIPS32_COMPAT
++ help
++ Select this option if you want to run n32 binaries. These are
++ 64-bit binaries using 32-bit quantities for addressing and certain
++ data that would normally be 64-bit. They are used in special
++ cases.
++
++ If unsure, say N.
++
++config BINFMT_ELF32
++ bool
++ default y if MIPS32_O32 || MIPS32_N32
++
++endmenu
++
++menu "Power management options"
++
++config ARCH_HIBERNATION_POSSIBLE
++ def_bool y
++ depends on SYS_SUPPORTS_HOTPLUG_CPU || !SMP
++
++config ARCH_SUSPEND_POSSIBLE
++ def_bool y
++ depends on SYS_SUPPORTS_HOTPLUG_CPU || !SMP
++
++source "kernel/power/Kconfig"
++
++endmenu
++
++source "arch/mips/kernel/cpufreq/Kconfig"
++
++source "net/Kconfig"
++
++source "drivers/Kconfig"
++
++source "drivers/firmware/Kconfig"
++
++source "fs/Kconfig"
++
++source "arch/mips/Kconfig.debug"
++
++source "security/Kconfig"
++
++source "crypto/Kconfig"
++
++source "lib/Kconfig"
+diff -Nur linux-3.9.11.orig/arch/x86/Kconfig linux-3.9.11/arch/x86/Kconfig
+--- linux-3.9.11.orig/arch/x86/Kconfig 2013-07-21 02:16:17.000000000 +0200
++++ linux-3.9.11/arch/x86/Kconfig 2013-09-12 07:26:20.000000000 +0200
+@@ -99,7 +99,6 @@
select GENERIC_SMP_IDLE_THREAD
+ select ARCH_WANT_IPC_PARSE_VERSION if X86_32
select HAVE_ARCH_SECCOMP_FILTER
- select BUILDTIME_EXTABLE_SORT
select GENERIC_CMOS_UPDATE
select CLOCKSOURCE_WATCHDOG
select GENERIC_CLOCKEVENTS
+diff -Nur linux-3.9.11.orig/arch/x86/Kconfig.orig linux-3.9.11/arch/x86/Kconfig.orig
+--- linux-3.9.11.orig/arch/x86/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100
++++ linux-3.9.11/arch/x86/Kconfig.orig 2013-07-21 02:16:17.000000000 +0200
+@@ -0,0 +1,2351 @@
++# Select 32 or 64 bit
++config 64BIT
++ bool "64-bit kernel" if ARCH = "x86"
++ default ARCH != "i386"
++ ---help---
++ Say yes to build a 64-bit kernel - formerly known as x86_64
++ Say no to build a 32-bit kernel - formerly known as i386
++
++config X86_32
++ def_bool y
++ depends on !64BIT
++ select CLKSRC_I8253
++ select HAVE_UID16
++
++config X86_64
++ def_bool y
++ depends on 64BIT
++ select X86_DEV_DMA_OPS
++
++### Arch settings
++config X86
++ def_bool y
++ select HAVE_AOUT if X86_32
++ select HAVE_UNSTABLE_SCHED_CLOCK
++ select ARCH_SUPPORTS_NUMA_BALANCING
++ select ARCH_WANTS_PROT_NUMA_PROT_NONE
++ select HAVE_IDE
++ select HAVE_OPROFILE
++ select HAVE_PCSPKR_PLATFORM
++ select HAVE_PERF_EVENTS
++ select HAVE_IOREMAP_PROT
++ select HAVE_KPROBES
++ select HAVE_MEMBLOCK
++ select HAVE_MEMBLOCK_NODE_MAP
++ select ARCH_DISCARD_MEMBLOCK
++ select ARCH_WANT_OPTIONAL_GPIOLIB
++ select ARCH_WANT_FRAME_POINTERS
++ select HAVE_DMA_ATTRS
++ select HAVE_DMA_CONTIGUOUS if !SWIOTLB
++ select HAVE_KRETPROBES
++ select HAVE_OPTPROBES
++ select HAVE_KPROBES_ON_FTRACE
++ select HAVE_FTRACE_MCOUNT_RECORD
++ select HAVE_FENTRY if X86_64
++ select HAVE_C_RECORDMCOUNT
++ select HAVE_DYNAMIC_FTRACE
++ select HAVE_DYNAMIC_FTRACE_WITH_REGS
++ select HAVE_FUNCTION_TRACER
++ select HAVE_FUNCTION_GRAPH_TRACER
++ select HAVE_FUNCTION_GRAPH_FP_TEST
++ select HAVE_FUNCTION_TRACE_MCOUNT_TEST
++ select HAVE_SYSCALL_TRACEPOINTS
++ select SYSCTL_EXCEPTION_TRACE
++ select HAVE_KVM
++ select HAVE_ARCH_KGDB
++ select HAVE_ARCH_TRACEHOOK
++ select HAVE_GENERIC_DMA_COHERENT if X86_32
++ select HAVE_EFFICIENT_UNALIGNED_ACCESS
++ select USER_STACKTRACE_SUPPORT
++ select HAVE_REGS_AND_STACK_ACCESS_API
++ select HAVE_DMA_API_DEBUG
++ select HAVE_KERNEL_GZIP
++ select HAVE_KERNEL_BZIP2
++ select HAVE_KERNEL_LZMA
++ select HAVE_KERNEL_XZ
++ select HAVE_KERNEL_LZO
++ select HAVE_HW_BREAKPOINT
++ select HAVE_MIXED_BREAKPOINTS_REGS
++ select PERF_EVENTS
++ select HAVE_PERF_EVENTS_NMI
++ select HAVE_PERF_REGS
++ select HAVE_PERF_USER_STACK_DUMP
++ select HAVE_DEBUG_KMEMLEAK
++ select ANON_INODES
++ select HAVE_ALIGNED_STRUCT_PAGE if SLUB
++ select HAVE_CMPXCHG_LOCAL
++ select HAVE_CMPXCHG_DOUBLE
++ select HAVE_ARCH_KMEMCHECK
++ select HAVE_USER_RETURN_NOTIFIER
++ select ARCH_BINFMT_ELF_RANDOMIZE_PIE
++ select HAVE_ARCH_JUMP_LABEL
++ select HAVE_TEXT_POKE_SMP
++ select HAVE_GENERIC_HARDIRQS
++ select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
++ select SPARSE_IRQ
++ select GENERIC_FIND_FIRST_BIT
++ select GENERIC_IRQ_PROBE
++ select GENERIC_PENDING_IRQ if SMP
++ select GENERIC_IRQ_SHOW
++ select GENERIC_CLOCKEVENTS_MIN_ADJUST
++ select IRQ_FORCED_THREADING
++ select USE_GENERIC_SMP_HELPERS if SMP
++ select HAVE_BPF_JIT if X86_64
++ select HAVE_ARCH_TRANSPARENT_HUGEPAGE
++ select CLKEVT_I8253
++ select ARCH_HAVE_NMI_SAFE_CMPXCHG
++ select GENERIC_IOMAP
++ select DCACHE_WORD_ACCESS
++ select GENERIC_SMP_IDLE_THREAD
++ select ARCH_WANT_IPC_PARSE_VERSION if X86_32
++ select HAVE_ARCH_SECCOMP_FILTER
++ select BUILDTIME_EXTABLE_SORT
++ select GENERIC_CMOS_UPDATE
++ select CLOCKSOURCE_WATCHDOG
++ select GENERIC_CLOCKEVENTS
++ select ARCH_CLOCKSOURCE_DATA if X86_64
++ select GENERIC_CLOCKEVENTS_BROADCAST if X86_64 || (X86_32 && X86_LOCAL_APIC)
++ select GENERIC_TIME_VSYSCALL if X86_64
++ select KTIME_SCALAR if X86_32
++ select GENERIC_STRNCPY_FROM_USER
++ select GENERIC_STRNLEN_USER
++ select HAVE_CONTEXT_TRACKING if X86_64
++ select HAVE_IRQ_TIME_ACCOUNTING
++ select VIRT_TO_BUS
++ select MODULES_USE_ELF_REL if X86_32
++ select MODULES_USE_ELF_RELA if X86_64
++ select CLONE_BACKWARDS if X86_32
++ select ARCH_USE_BUILTIN_BSWAP
++ select OLD_SIGSUSPEND3 if X86_32 || IA32_EMULATION
++ select OLD_SIGACTION if X86_32
++ select COMPAT_OLD_SIGACTION if IA32_EMULATION
++
++config INSTRUCTION_DECODER
++ def_bool y
++ depends on KPROBES || PERF_EVENTS || UPROBES
++
++config OUTPUT_FORMAT
++ string
++ default "elf32-i386" if X86_32
++ default "elf64-x86-64" if X86_64
++
++config ARCH_DEFCONFIG
++ string
++ default "arch/x86/configs/i386_defconfig" if X86_32
++ default "arch/x86/configs/x86_64_defconfig" if X86_64
++
++config LOCKDEP_SUPPORT
++ def_bool y
++
++config STACKTRACE_SUPPORT
++ def_bool y
++
++config HAVE_LATENCYTOP_SUPPORT
++ def_bool y
++
++config MMU
++ def_bool y
++
++config SBUS
++ bool
++
++config NEED_DMA_MAP_STATE
++ def_bool y
++ depends on X86_64 || INTEL_IOMMU || DMA_API_DEBUG
++
++config NEED_SG_DMA_LENGTH
++ def_bool y
++
++config GENERIC_ISA_DMA
++ def_bool y
++ depends on ISA_DMA_API
++
++config GENERIC_BUG
++ def_bool y
++ depends on BUG
++ select GENERIC_BUG_RELATIVE_POINTERS if X86_64
++
++config GENERIC_BUG_RELATIVE_POINTERS
++ bool
++
++config GENERIC_HWEIGHT
++ def_bool y
++
++config GENERIC_GPIO
++ bool
++
++config ARCH_MAY_HAVE_PC_FDC
++ def_bool y
++ depends on ISA_DMA_API
++
++config RWSEM_XCHGADD_ALGORITHM
++ def_bool y
++
++config GENERIC_CALIBRATE_DELAY
++ def_bool y
++
++config ARCH_HAS_CPU_RELAX
++ def_bool y
++
++config ARCH_HAS_DEFAULT_IDLE
++ def_bool y
++
++config ARCH_HAS_CACHE_LINE_SIZE
++ def_bool y
++
++config ARCH_HAS_CPU_AUTOPROBE
++ def_bool y
++
++config HAVE_SETUP_PER_CPU_AREA
++ def_bool y
++
++config NEED_PER_CPU_EMBED_FIRST_CHUNK
++ def_bool y
++
++config NEED_PER_CPU_PAGE_FIRST_CHUNK
++ def_bool y
++
++config ARCH_HIBERNATION_POSSIBLE
++ def_bool y
++
++config ARCH_SUSPEND_POSSIBLE
++ def_bool y
++
++config ZONE_DMA32
++ bool
++ default X86_64
++
++config AUDIT_ARCH
++ bool
++ default X86_64
++
++config ARCH_SUPPORTS_OPTIMIZED_INLINING
++ def_bool y
++
++config ARCH_SUPPORTS_DEBUG_PAGEALLOC
++ def_bool y
++
++config HAVE_INTEL_TXT
++ def_bool y
++ depends on INTEL_IOMMU && ACPI
++
++config X86_32_SMP
++ def_bool y
++ depends on X86_32 && SMP
++
++config X86_64_SMP
++ def_bool y
++ depends on X86_64 && SMP
++
++config X86_HT
++ def_bool y
++ depends on SMP
++
++config X86_32_LAZY_GS
++ def_bool y
++ depends on X86_32 && !CC_STACKPROTECTOR
++
++config ARCH_HWEIGHT_CFLAGS
++ string
++ default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
++ default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64
++
++config ARCH_CPU_PROBE_RELEASE
++ def_bool y
++ depends on HOTPLUG_CPU
++
++config ARCH_SUPPORTS_UPROBES
++ def_bool y
++
++source "init/Kconfig"
++source "kernel/Kconfig.freezer"
++
++menu "Processor type and features"
++
++config ZONE_DMA
++ bool "DMA memory allocation support" if EXPERT
++ default y
++ help
++ DMA memory allocation support allows devices with less than 32-bit
++ addressing to allocate within the first 16MB of address space.
++ Disable if no such devices will be used.
++
++ If unsure, say Y.
++
++config SMP
++ bool "Symmetric multi-processing support"
++ ---help---
++ This enables support for systems with more than one CPU. If you have
++ a system with only one CPU, like most personal computers, say N. If
++ you have a system with more than one CPU, say Y.
++
++ If you say N here, the kernel will run on single and multiprocessor
++ machines, but will use only one CPU of a multiprocessor machine. If
++ you say Y here, the kernel will run on many, but not all,
++ singleprocessor machines. On a singleprocessor machine, the kernel
++ will run faster if you say N here.
++
++ Note that if you say Y here and choose architecture "586" or
++ "Pentium" under "Processor family", the kernel will not work on 486
++ architectures. Similarly, multiprocessor kernels for the "PPro"
++ architecture may not work on all Pentium based boards.
++
++ People using multiprocessor machines who say Y here should also say
++ Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
++ Management" code will be disabled if you say Y here.
++
++ See also <file:Documentation/x86/i386/IO-APIC.txt>,
++ <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
++ <http://www.tldp.org/docs.html#howto>.
++
++ If you don't know what to do here, say N.
++
++config X86_X2APIC
++ bool "Support x2apic"
++ depends on X86_LOCAL_APIC && X86_64 && IRQ_REMAP
++ ---help---
++ This enables x2apic support on CPUs that have this feature.
++
++ This allows 32-bit apic IDs (so it can support very large systems),
++ and accesses the local apic via MSRs not via mmio.
++
++ If you don't know what to do here, say N.
++
++config X86_MPPARSE
++ bool "Enable MPS table" if ACPI || SFI
++ default y
++ depends on X86_LOCAL_APIC
++ ---help---
++ For old smp systems that do not have proper acpi support. Newer systems
++ (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
++
++config X86_BIGSMP
++ bool "Support for big SMP systems with more than 8 CPUs"
++ depends on X86_32 && SMP
++ ---help---
++ This option is needed for the systems that have more than 8 CPUs
++
++config GOLDFISH
++ def_bool y
++ depends on X86_GOLDFISH
++
++if X86_32
++config X86_EXTENDED_PLATFORM
++ bool "Support for extended (non-PC) x86 platforms"
++ default y
++ ---help---
++ If you disable this option then the kernel will only support
++ standard PC platforms. (which covers the vast majority of
++ systems out there.)
++
++ If you enable this option then you'll be able to select support
++ for the following (non-PC) 32 bit x86 platforms:
++ AMD Elan
++ NUMAQ (IBM/Sequent)
++ RDC R-321x SoC
++ SGI 320/540 (Visual Workstation)
++ STA2X11-based (e.g. Northville)
++ Summit/EXA (IBM x440)
++ Unisys ES7000 IA32 series
++ Moorestown MID devices
++
++ If you have one of these systems, or if you want to build a
++ generic distribution kernel, say Y here - otherwise say N.
++endif
++
++if X86_64
++config X86_EXTENDED_PLATFORM
++ bool "Support for extended (non-PC) x86 platforms"
++ default y
++ ---help---
++ If you disable this option then the kernel will only support
++ standard PC platforms. (which covers the vast majority of
++ systems out there.)
++
++ If you enable this option then you'll be able to select support
++ for the following (non-PC) 64 bit x86 platforms:
++ Numascale NumaChip
++ ScaleMP vSMP
++ SGI Ultraviolet
++
++ If you have one of these systems, or if you want to build a
++ generic distribution kernel, say Y here - otherwise say N.
++endif
++# This is an alphabetically sorted list of 64 bit extended platforms
++# Please maintain the alphabetic order if and when there are additions
++config X86_NUMACHIP
++ bool "Numascale NumaChip"
++ depends on X86_64
++ depends on X86_EXTENDED_PLATFORM
++ depends on NUMA
++ depends on SMP
++ depends on X86_X2APIC
++ depends on PCI_MMCONFIG
++ ---help---
++ Adds support for Numascale NumaChip large-SMP systems. Needed to
++ enable more than ~168 cores.
++ If you don't have one of these, you should say N here.
++
++config X86_VSMP
++ bool "ScaleMP vSMP"
++ select PARAVIRT_GUEST
++ select PARAVIRT
++ depends on X86_64 && PCI
++ depends on X86_EXTENDED_PLATFORM
++ depends on SMP
++ ---help---
++ Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
++ supposed to run on these EM64T-based machines. Only choose this option
++ if you have one of these machines.
++
++config X86_UV
++ bool "SGI Ultraviolet"
++ depends on X86_64
++ depends on X86_EXTENDED_PLATFORM
++ depends on NUMA
++ depends on X86_X2APIC
++ ---help---
++ This option is needed in order to support SGI Ultraviolet systems.
++ If you don't have one of these, you should say N here.
++
++# Following is an alphabetically sorted list of 32 bit extended platforms
++# Please maintain the alphabetic order if and when there are additions
++
++config X86_GOLDFISH
++ bool "Goldfish (Virtual Platform)"
++ depends on X86_32
++ ---help---
++ Enable support for the Goldfish virtual platform used primarily
++ for Android development. Unless you are building for the Android
++ Goldfish emulator say N here.
++
++config X86_INTEL_CE
++ bool "CE4100 TV platform"
++ depends on PCI
++ depends on PCI_GODIRECT
++ depends on X86_32
++ depends on X86_EXTENDED_PLATFORM
++ select X86_REBOOTFIXUPS
++ select OF
++ select OF_EARLY_FLATTREE
++ select IRQ_DOMAIN
++ ---help---
++ Select for the Intel CE media processor (CE4100) SOC.
++ This option compiles in support for the CE4100 SOC for settop
++ boxes and media devices.
++
++config X86_WANT_INTEL_MID
++ bool "Intel MID platform support"
++ depends on X86_32
++ depends on X86_EXTENDED_PLATFORM
++ ---help---
++ Select to build a kernel capable of supporting Intel MID platform
++ systems which do not have the PCI legacy interfaces (Moorestown,
++ Medfield). If you are building for a PC class system say N here.
++
++if X86_WANT_INTEL_MID
++
++config X86_INTEL_MID
++ bool
++
++config X86_MDFLD
++ bool "Medfield MID platform"
++ depends on PCI
++ depends on PCI_GOANY
++ depends on X86_IO_APIC
++ select X86_INTEL_MID
++ select SFI
++ select DW_APB_TIMER
++ select APB_TIMER
++ select I2C
++ select SPI
++ select INTEL_SCU_IPC
++ select X86_PLATFORM_DEVICES
++ select MFD_INTEL_MSIC
++ ---help---
++ Medfield is Intel's Low Power Intel Architecture (LPIA) based Moblin
++ Internet Device(MID) platform.
++ Unlike standard x86 PCs, Medfield does not have many legacy devices
++ nor standard legacy replacement devices/features. e.g. Medfield does
++ not contain i8259, i8254, HPET, legacy BIOS, most of the io ports.
++
++endif
++
++config X86_INTEL_LPSS
++ bool "Intel Low Power Subsystem Support"
++ depends on ACPI
++ select COMMON_CLK
++ ---help---
++ Select to build support for Intel Low Power Subsystem such as
++ found on Intel Lynxpoint PCH. Selecting this option enables
++ things like clock tree (common clock framework) which are needed
++ by the LPSS peripheral drivers.
++
++config X86_RDC321X
++ bool "RDC R-321x SoC"
++ depends on X86_32
++ depends on X86_EXTENDED_PLATFORM
++ select M486
++ select X86_REBOOTFIXUPS
++ ---help---
++ This option is needed for RDC R-321x system-on-chip, also known
++ as R-8610-(G).
++ If you don't have one of these chips, you should say N here.
++
++config X86_32_NON_STANDARD
++ bool "Support non-standard 32-bit SMP architectures"
++ depends on X86_32 && SMP
++ depends on X86_EXTENDED_PLATFORM
++ ---help---
++ This option compiles in the NUMAQ, Summit, bigsmp, ES7000,
++ STA2X11, default subarchitectures. It is intended for a generic
++ binary kernel. If you select them all, kernel will probe it
++ one by one and will fallback to default.
++
++# Alphabetically sorted list of Non standard 32 bit platforms
++
++config X86_NUMAQ
++ bool "NUMAQ (IBM/Sequent)"
++ depends on X86_32_NON_STANDARD
++ depends on PCI
++ select NUMA
++ select X86_MPPARSE
++ ---help---
++ This option is used for getting Linux to run on a NUMAQ (IBM/Sequent)
++ NUMA multiquad box. This changes the way that processors are
++ bootstrapped, and uses Clustered Logical APIC addressing mode instead
++ of Flat Logical. You will need a new lynxer.elf file to flash your
++ firmware with - send email to <Martin.Bligh@us.ibm.com>.
++
++config X86_SUPPORTS_MEMORY_FAILURE
++ def_bool y
++ # MCE code calls memory_failure():
++ depends on X86_MCE
++ # On 32-bit this adds too big of NODES_SHIFT and we run out of page flags:
++ depends on !X86_NUMAQ
++ # On 32-bit SPARSEMEM adds too big of SECTIONS_WIDTH:
++ depends on X86_64 || !SPARSEMEM
++ select ARCH_SUPPORTS_MEMORY_FAILURE
++
++config X86_VISWS
++ bool "SGI 320/540 (Visual Workstation)"
++ depends on X86_32 && PCI && X86_MPPARSE && PCI_GODIRECT
++ depends on X86_32_NON_STANDARD
++ ---help---
++ The SGI Visual Workstation series is an IA32-based workstation
++ based on SGI systems chips with some legacy PC hardware attached.
++
++ Say Y here to create a kernel to run on the SGI 320 or 540.
++
++ A kernel compiled for the Visual Workstation will run on general
++ PCs as well. See <file:Documentation/sgi-visws.txt> for details.
++
++config STA2X11
++ bool "STA2X11 Companion Chip Support"
++ depends on X86_32_NON_STANDARD && PCI
++ select X86_DEV_DMA_OPS
++ select X86_DMA_REMAP
++ select SWIOTLB
++ select MFD_STA2X11
++ select ARCH_REQUIRE_GPIOLIB
++ default n
++ ---help---
++ This adds support for boards based on the STA2X11 IO-Hub,
++ a.k.a. "ConneXt". The chip is used in place of the standard
++ PC chipset, so all "standard" peripherals are missing. If this
++ option is selected the kernel will still be able to boot on
++ standard PC machines.
++
++config X86_SUMMIT
++ bool "Summit/EXA (IBM x440)"
++ depends on X86_32_NON_STANDARD
++ ---help---
++ This option is needed for IBM systems that use the Summit/EXA chipset.
++ In particular, it is needed for the x440.
++
++config X86_ES7000
++ bool "Unisys ES7000 IA32 series"
++ depends on X86_32_NON_STANDARD && X86_BIGSMP
++ ---help---
++ Support for Unisys ES7000 systems. Say 'Y' here if this kernel is
++ supposed to run on an IA32-based Unisys ES7000 system.
++
++config X86_32_IRIS
++ tristate "Eurobraille/Iris poweroff module"
++ depends on X86_32
++ ---help---
++ The Iris machines from EuroBraille do not have APM or ACPI support
++ to shut themselves down properly. A special I/O sequence is
++ needed to do so, which is what this module does at
++ kernel shutdown.
++
++ This is only for Iris machines from EuroBraille.
++
++ If unused, say N.
++
++config SCHED_OMIT_FRAME_POINTER
++ def_bool y
++ prompt "Single-depth WCHAN output"
++ depends on X86
++ ---help---
++ Calculate simpler /proc/<PID>/wchan values. If this option
++ is disabled then wchan values will recurse back to the
++ caller function. This provides more accurate wchan values,
++ at the expense of slightly more scheduling overhead.
++
++ If in doubt, say "Y".
++
++menuconfig PARAVIRT_GUEST
++ bool "Paravirtualized guest support"
++ ---help---
++ Say Y here to get to see options related to running Linux under
++ various hypervisors. This option alone does not add any kernel code.
++
++ If you say N, all options in this submenu will be skipped and disabled.
++
++if PARAVIRT_GUEST
++
++config PARAVIRT_TIME_ACCOUNTING
++ bool "Paravirtual steal time accounting"
++ select PARAVIRT
++ default n
++ ---help---
++ Select this option to enable fine granularity task steal time
++ accounting. Time spent executing other tasks in parallel with
++ the current vCPU is discounted from the vCPU power. To account for
++ that, there can be a small performance impact.
++
++ If in doubt, say N here.
++
++source "arch/x86/xen/Kconfig"
++
++config KVM_GUEST
++ bool "KVM Guest support (including kvmclock)"
++ select PARAVIRT
++ select PARAVIRT
++ select PARAVIRT_CLOCK
++ default y if PARAVIRT_GUEST
++ ---help---
++ This option enables various optimizations for running under the KVM
++ hypervisor. It includes a paravirtualized clock, so that instead
++ of relying on a PIT (or probably other) emulation by the
++ underlying device model, the host provides the guest with
++ timing infrastructure such as time of day, and system time
++
++source "arch/x86/lguest/Kconfig"
++
++config PARAVIRT
++ bool "Enable paravirtualization code"
++ ---help---
++ This changes the kernel so it can modify itself when it is run
++ under a hypervisor, potentially improving performance significantly
++ over full virtualization. However, when run without a hypervisor
++ the kernel is theoretically slower and slightly larger.
++
++config PARAVIRT_SPINLOCKS
++ bool "Paravirtualization layer for spinlocks"
++ depends on PARAVIRT && SMP
++ ---help---
++ Paravirtualized spinlocks allow a pvops backend to replace the
++ spinlock implementation with something virtualization-friendly
++ (for example, block the virtual CPU rather than spinning).
++
++ Unfortunately the downside is an up to 5% performance hit on
++ native kernels, with various workloads.
++
++ If you are unsure how to answer this question, answer N.
++
++config PARAVIRT_CLOCK
++ bool
++
++endif
++
++config PARAVIRT_DEBUG
++ bool "paravirt-ops debugging"
++ depends on PARAVIRT && DEBUG_KERNEL
++ ---help---
++ Enable to debug paravirt_ops internals. Specifically, BUG if
++ a paravirt_op is missing when it is called.
++
++config NO_BOOTMEM
++ def_bool y
++
++config MEMTEST
++ bool "Memtest"
++ ---help---
++ This option adds a kernel parameter 'memtest', which allows memtest
++ to be set.
++ memtest=0, mean disabled; -- default
++ memtest=1, mean do 1 test pattern;
++ ...
++ memtest=4, mean do 4 test patterns.
++ If you are unsure how to answer this question, answer N.
++
++config X86_SUMMIT_NUMA
++ def_bool y
++ depends on X86_32 && NUMA && X86_32_NON_STANDARD
++
++config X86_CYCLONE_TIMER
++ def_bool y
++ depends on X86_SUMMIT
++
++source "arch/x86/Kconfig.cpu"
++
++config HPET_TIMER
++ def_bool X86_64
++ prompt "HPET Timer Support" if X86_32
++ ---help---
++ Use the IA-PC HPET (High Precision Event Timer) to manage
++ time in preference to the PIT and RTC, if a HPET is
++ present.
++ HPET is the next generation timer replacing legacy 8254s.
++ The HPET provides a stable time base on SMP
++ systems, unlike the TSC, but it is more expensive to access,
++ as it is off-chip. You can find the HPET spec at
++ <http://www.intel.com/hardwaredesign/hpetspec_1.pdf>.
++
++ You can safely choose Y here. However, HPET will only be
++ activated if the platform and the BIOS support this feature.
++ Otherwise the 8254 will be used for timing services.
++
++ Choose N to continue using the legacy 8254 timer.
++
++config HPET_EMULATE_RTC
++ def_bool y
++ depends on HPET_TIMER && (RTC=y || RTC=m || RTC_DRV_CMOS=m || RTC_DRV_CMOS=y)
++
++config APB_TIMER
++ def_bool y if X86_INTEL_MID
++ prompt "Intel MID APB Timer Support" if X86_INTEL_MID
++ select DW_APB_TIMER
++ depends on X86_INTEL_MID && SFI
++ help
++ APB timer is the replacement for 8254, HPET on X86 MID platforms.
++ The APBT provides a stable time base on SMP
++ systems, unlike the TSC, but it is more expensive to access,
++ as it is off-chip. APB timers are always running regardless of CPU
++ C states, they are used as per CPU clockevent device when possible.
++
++# Mark as expert because too many people got it wrong.
++# The code disables itself when not needed.
++config DMI
++ default y
++ bool "Enable DMI scanning" if EXPERT
++ ---help---
++ Enabled scanning of DMI to identify machine quirks. Say Y
++ here unless you have verified that your setup is not
++ affected by entries in the DMI blacklist. Required by PNP
++ BIOS code.
++
++config GART_IOMMU
++ bool "GART IOMMU support" if EXPERT
++ default y
++ select SWIOTLB
++ depends on X86_64 && PCI && AMD_NB
++ ---help---
++ Support for full DMA access of devices with 32bit memory access only
++ on systems with more than 3GB. This is usually needed for USB,
++ sound, many IDE/SATA chipsets and some other devices.
++ Provides a driver for the AMD Athlon64/Opteron/Turion/Sempron GART
++ based hardware IOMMU and a software bounce buffer based IOMMU used
++ on Intel systems and as fallback.
++ The code is only active when needed (enough memory and limited
++ device) unless CONFIG_IOMMU_DEBUG or iommu=force is specified
++ too.
++
++config CALGARY_IOMMU
++ bool "IBM Calgary IOMMU support"
++ select SWIOTLB
++ depends on X86_64 && PCI
++ ---help---
++ Support for hardware IOMMUs in IBM's xSeries x366 and x460
++ systems. Needed to run systems with more than 3GB of memory
++ properly with 32-bit PCI devices that do not support DAC
++ (Double Address Cycle). Calgary also supports bus level
++ isolation, where all DMAs pass through the IOMMU. This
++ prevents them from going anywhere except their intended
++ destination. This catches hard-to-find kernel bugs and
++ mis-behaving drivers and devices that do not use the DMA-API
++ properly to set up their DMA buffers. The IOMMU can be
++ turned off at boot time with the iommu=off parameter.
++ Normally the kernel will make the right choice by itself.
++ If unsure, say Y.
++
++config CALGARY_IOMMU_ENABLED_BY_DEFAULT
++ def_bool y
++ prompt "Should Calgary be enabled by default?"
++ depends on CALGARY_IOMMU
++ ---help---
++ Should Calgary be enabled by default? if you choose 'y', Calgary
++ will be used (if it exists). If you choose 'n', Calgary will not be
++ used even if it exists. If you choose 'n' and would like to use
++ Calgary anyway, pass 'iommu=calgary' on the kernel command line.
++ If unsure, say Y.
++
++# need this always selected by IOMMU for the VIA workaround
++config SWIOTLB
++ def_bool y if X86_64
++ ---help---
++ Support for software bounce buffers used on x86-64 systems
++ which don't have a hardware IOMMU. Using this PCI devices
++ which can only access 32-bits of memory can be used on systems
++ with more than 3 GB of memory.
++ If unsure, say Y.
++
++config IOMMU_HELPER
++ def_bool y
++ depends on CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU
++
++config MAXSMP
++ bool "Enable Maximum number of SMP Processors and NUMA Nodes"
++ depends on X86_64 && SMP && DEBUG_KERNEL
++ select CPUMASK_OFFSTACK
++ ---help---
++ Enable maximum number of CPUS and NUMA Nodes for this architecture.
++ If unsure, say N.
++
++config NR_CPUS
++ int "Maximum number of CPUs" if SMP && !MAXSMP
++ range 2 8 if SMP && X86_32 && !X86_BIGSMP
++ range 2 512 if SMP && !MAXSMP
++ default "1" if !SMP
++ default "4096" if MAXSMP
++ default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
++ default "8" if SMP
++ ---help---
++ This allows you to specify the maximum number of CPUs which this
++ kernel will support. The maximum supported value is 512 and the
++ minimum value which makes sense is 2.
++
++ This is purely to save memory - each supported CPU adds
++ approximately eight kilobytes to the kernel image.
++
++config SCHED_SMT
++ bool "SMT (Hyperthreading) scheduler support"
++ depends on X86_HT
++ ---help---
++ SMT scheduler support improves the CPU scheduler's decision making
++ when dealing with Intel Pentium 4 chips with HyperThreading at a
++ cost of slightly increased overhead in some places. If unsure say
++ N here.
++
++config SCHED_MC
++ def_bool y
++ prompt "Multi-core scheduler support"
++ depends on X86_HT
++ ---help---
++ Multi-core scheduler support improves the CPU scheduler's decision
++ making when dealing with multi-core CPU chips at a cost of slightly
++ increased overhead in some places. If unsure say N here.
++
++source "kernel/Kconfig.preempt"
++
++config X86_UP_APIC
++ bool "Local APIC support on uniprocessors"
++ depends on X86_32 && !SMP && !X86_32_NON_STANDARD
++ ---help---
++ A local APIC (Advanced Programmable Interrupt Controller) is an
++ integrated interrupt controller in the CPU. If you have a single-CPU
++ system which has a processor with a local APIC, you can say Y here to
++ enable and use it. If you say Y here even though your machine doesn't
++ have a local APIC, then the kernel will still run with no slowdown at
++ all. The local APIC supports CPU-generated self-interrupts (timer,
++ performance counters), and the NMI watchdog which detects hard
++ lockups.
++
++config X86_UP_IOAPIC
++ bool "IO-APIC support on uniprocessors"
++ depends on X86_UP_APIC
++ ---help---
++ An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an
++ SMP-capable replacement for PC-style interrupt controllers. Most
++ SMP systems and many recent uniprocessor systems have one.
++
++ If you have a single-CPU system with an IO-APIC, you can say Y here
++ to use it. If you say Y here even though your machine doesn't have
++ an IO-APIC, then the kernel will still run with no slowdown at all.
++
++config X86_LOCAL_APIC
++ def_bool y
++ depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC
++
++config X86_IO_APIC
++ def_bool y
++ depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC
++
++config X86_VISWS_APIC
++ def_bool y
++ depends on X86_32 && X86_VISWS
++
++config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
++ bool "Reroute for broken boot IRQs"
++ depends on X86_IO_APIC
++ ---help---
++ This option enables a workaround that fixes a source of
++ spurious interrupts. This is recommended when threaded
++ interrupt handling is used on systems where the generation of
++ superfluous "boot interrupts" cannot be disabled.
++
++ Some chipsets generate a legacy INTx "boot IRQ" when the IRQ
++ entry in the chipset's IO-APIC is masked (as, e.g. the RT
++ kernel does during interrupt handling). On chipsets where this
++ boot IRQ generation cannot be disabled, this workaround keeps
++ the original IRQ line masked so that only the equivalent "boot
++ IRQ" is delivered to the CPUs. The workaround also tells the
++ kernel to set up the IRQ handler on the boot IRQ line. In this
++ way only one interrupt is delivered to the kernel. Otherwise
++ the spurious second interrupt may cause the kernel to bring
++ down (vital) interrupt lines.
++
++ Only affects "broken" chipsets. Interrupt sharing may be
++ increased on these systems.
++
++config X86_MCE
++ bool "Machine Check / overheating reporting"
++ default y
++ ---help---
++ Machine Check support allows the processor to notify the
++ kernel if it detects a problem (e.g. overheating, data corruption).
++ The action the kernel takes depends on the severity of the problem,
++ ranging from warning messages to halting the machine.
++
++config X86_MCE_INTEL
++ def_bool y
++ prompt "Intel MCE features"
++ depends on X86_MCE && X86_LOCAL_APIC
++ ---help---
++ Additional support for intel specific MCE features such as
++ the thermal monitor.
++
++config X86_MCE_AMD
++ def_bool y
++ prompt "AMD MCE features"
++ depends on X86_MCE && X86_LOCAL_APIC
++ ---help---
++ Additional support for AMD specific MCE features such as
++ the DRAM Error Threshold.
++
++config X86_ANCIENT_MCE
++ bool "Support for old Pentium 5 / WinChip machine checks"
++ depends on X86_32 && X86_MCE
++ ---help---
++ Include support for machine check handling on old Pentium 5 or WinChip
++ systems. These typically need to be enabled explicitely on the command
++ line.
++
++config X86_MCE_THRESHOLD
++ depends on X86_MCE_AMD || X86_MCE_INTEL
++ def_bool y
++
++config X86_MCE_INJECT
++ depends on X86_MCE
++ tristate "Machine check injector support"
++ ---help---
++ Provide support for injecting machine checks for testing purposes.
++ If you don't know what a machine check is and you don't do kernel
++ QA it is safe to say n.
++
++config X86_THERMAL_VECTOR
++ def_bool y
++ depends on X86_MCE_INTEL
++
++config VM86
++ bool "Enable VM86 support" if EXPERT
++ default y
++ depends on X86_32
++ ---help---
++ This option is required by programs like DOSEMU to run 16-bit legacy
++ code on X86 processors. It also may be needed by software like
++ XFree86 to initialize some video cards via BIOS. Disabling this
++ option saves about 6k.
++
++config TOSHIBA
++ tristate "Toshiba Laptop support"
++ depends on X86_32
++ ---help---
++ This adds a driver to safely access the System Management Mode of
++ the CPU on Toshiba portables with a genuine Toshiba BIOS. It does
++ not work on models with a Phoenix BIOS. The System Management Mode
++ is used to set the BIOS and power saving options on Toshiba portables.
++
++ For information on utilities to make use of this driver see the
++ Toshiba Linux utilities web site at:
++ <http://www.buzzard.org.uk/toshiba/>.
++
++ Say Y if you intend to run this kernel on a Toshiba portable.
++ Say N otherwise.
++
++config I8K
++ tristate "Dell laptop support"
++ select HWMON
++ ---help---
++ This adds a driver to safely access the System Management Mode
++ of the CPU on the Dell Inspiron 8000. The System Management Mode
++ is used to read cpu temperature and cooling fan status and to
++ control the fans on the I8K portables.
++
++ This driver has been tested only on the Inspiron 8000 but it may
++ also work with other Dell laptops. You can force loading on other
++ models by passing the parameter `force=1' to the module. Use at
++ your own risk.
++
++ For information on utilities to make use of this driver see the
++ I8K Linux utilities web site at:
++ <http://people.debian.org/~dz/i8k/>
++
++ Say Y if you intend to run this kernel on a Dell Inspiron 8000.
++ Say N otherwise.
++
++config X86_REBOOTFIXUPS
++ bool "Enable X86 board specific fixups for reboot"
++ depends on X86_32
++ ---help---
++ This enables chipset and/or board specific fixups to be done
++ in order to get reboot to work correctly. This is only needed on
++ some combinations of hardware and BIOS. The symptom, for which
++ this config is intended, is when reboot ends with a stalled/hung
++ system.
++
++ Currently, the only fixup is for the Geode machines using
++ CS5530A and CS5536 chipsets and the RDC R-321x SoC.
++
++ Say Y if you want to enable the fixup. Currently, it's safe to
++ enable this option even if you don't need it.
++ Say N otherwise.
++
++config MICROCODE
++ tristate "CPU microcode loading support"
++ select FW_LOADER
++ ---help---
++
++ If you say Y here, you will be able to update the microcode on
++ certain Intel and AMD processors. The Intel support is for the
++ IA32 family, e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4,
++ Xeon etc. The AMD support is for families 0x10 and later. You will
++ obviously need the actual microcode binary data itself which is not
++ shipped with the Linux kernel.
++
++ This option selects the general module only, you need to select
++ at least one vendor specific module as well.
++
++ To compile this driver as a module, choose M here: the module
++ will be called microcode.
++
++config MICROCODE_INTEL
++ bool "Intel microcode loading support"
++ depends on MICROCODE
++ default MICROCODE
++ select FW_LOADER
++ ---help---
++ This options enables microcode patch loading support for Intel
++ processors.
++
++ For latest news and information on obtaining all the required
++ Intel ingredients for this driver, check:
++ <http://www.urbanmyth.org/microcode/>.
++
++config MICROCODE_AMD
++ bool "AMD microcode loading support"
++ depends on MICROCODE
++ select FW_LOADER
++ ---help---
++ If you select this option, microcode patch loading support for AMD
++ processors will be enabled.
++
++config MICROCODE_OLD_INTERFACE
++ def_bool y
++ depends on MICROCODE
++
++config MICROCODE_INTEL_LIB
++ def_bool y
++ depends on MICROCODE_INTEL
++
++config MICROCODE_INTEL_EARLY
++ bool "Early load microcode"
++ depends on MICROCODE_INTEL && BLK_DEV_INITRD
++ default y
++ help
++ This option provides functionality to read additional microcode data
++ at the beginning of initrd image. The data tells kernel to load
++ microcode to CPU's as early as possible. No functional change if no
++ microcode data is glued to the initrd, therefore it's safe to say Y.
++
++config MICROCODE_EARLY
++ def_bool y
++ depends on MICROCODE_INTEL_EARLY
++
++config X86_MSR
++ tristate "/dev/cpu/*/msr - Model-specific register support"
++ ---help---
++ This device gives privileged processes access to the x86
++ Model-Specific Registers (MSRs). It is a character device with
++ major 202 and minors 0 to 31 for /dev/cpu/0/msr to /dev/cpu/31/msr.
++ MSR accesses are directed to a specific CPU on multi-processor
++ systems.
++
++config X86_CPUID
++ tristate "/dev/cpu/*/cpuid - CPU information support"
++ ---help---
++ This device gives processes access to the x86 CPUID instruction to
++ be executed on a specific processor. It is a character device
++ with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
++ /dev/cpu/31/cpuid.
++
++choice
++ prompt "High Memory Support"
++ default HIGHMEM64G if X86_NUMAQ
++ default HIGHMEM4G
++ depends on X86_32
++
++config NOHIGHMEM
++ bool "off"
++ depends on !X86_NUMAQ
++ ---help---
++ Linux can use up to 64 Gigabytes of physical memory on x86 systems.
++ However, the address space of 32-bit x86 processors is only 4
++ Gigabytes large. That means that, if you have a large amount of
++ physical memory, not all of it can be "permanently mapped" by the
++ kernel. The physical memory that's not permanently mapped is called
++ "high memory".
++
++ If you are compiling a kernel which will never run on a machine with
++ more than 1 Gigabyte total physical RAM, answer "off" here (default
++ choice and suitable for most users). This will result in a "3GB/1GB"
++ split: 3GB are mapped so that each process sees a 3GB virtual memory
++ space and the remaining part of the 4GB virtual memory space is used
++ by the kernel to permanently map as much physical memory as
++ possible.
++
++ If the machine has between 1 and 4 Gigabytes physical RAM, then
++ answer "4GB" here.
++
++ If more than 4 Gigabytes is used then answer "64GB" here. This
++ selection turns Intel PAE (Physical Address Extension) mode on.
++ PAE implements 3-level paging on IA32 processors. PAE is fully
++ supported by Linux, PAE mode is implemented on all recent Intel
++ processors (Pentium Pro and better). NOTE: If you say "64GB" here,
++ then the kernel will not boot on CPUs that don't support PAE!
++
++ The actual amount of total physical memory will either be
++ auto detected or can be forced by using a kernel command line option
++ such as "mem=256M". (Try "man bootparam" or see the documentation of
++ your boot loader (lilo or loadlin) about how to pass options to the
++ kernel at boot time.)
++
++ If unsure, say "off".
++
++config HIGHMEM4G
++ bool "4GB"
++ depends on !X86_NUMAQ
++ ---help---
++ Select this if you have a 32-bit processor and between 1 and 4
++ gigabytes of physical RAM.
++
++config HIGHMEM64G
++ bool "64GB"
++ depends on !M486
++ select X86_PAE
++ ---help---
++ Select this if you have a 32-bit processor and more than 4
++ gigabytes of physical RAM.
++
++endchoice
++
++choice
++ prompt "Memory split" if EXPERT
++ default VMSPLIT_3G
++ depends on X86_32
++ ---help---
++ Select the desired split between kernel and user memory.
++
++ If the address range available to the kernel is less than the
++ physical memory installed, the remaining memory will be available
++ as "high memory". Accessing high memory is a little more costly
++ than low memory, as it needs to be mapped into the kernel first.
++ Note that increasing the kernel address space limits the range
++ available to user programs, making the address space there
++ tighter. Selecting anything other than the default 3G/1G split
++ will also likely make your kernel incompatible with binary-only
++ kernel modules.
++
++ If you are not absolutely sure what you are doing, leave this
++ option alone!
++
++ config VMSPLIT_3G
++ bool "3G/1G user/kernel split"
++ config VMSPLIT_3G_OPT
++ depends on !X86_PAE
++ bool "3G/1G user/kernel split (for full 1G low memory)"
++ config VMSPLIT_2G
++ bool "2G/2G user/kernel split"
++ config VMSPLIT_2G_OPT
++ depends on !X86_PAE
++ bool "2G/2G user/kernel split (for full 2G low memory)"
++ config VMSPLIT_1G
++ bool "1G/3G user/kernel split"
++endchoice
++
++config PAGE_OFFSET
++ hex
++ default 0xB0000000 if VMSPLIT_3G_OPT
++ default 0x80000000 if VMSPLIT_2G
++ default 0x78000000 if VMSPLIT_2G_OPT
++ default 0x40000000 if VMSPLIT_1G
++ default 0xC0000000
++ depends on X86_32
++
++config HIGHMEM
++ def_bool y
++ depends on X86_32 && (HIGHMEM64G || HIGHMEM4G)
++
++config X86_PAE
++ bool "PAE (Physical Address Extension) Support"
++ depends on X86_32 && !HIGHMEM4G
++ ---help---
++ PAE is required for NX support, and furthermore enables
++ larger swapspace support for non-overcommit purposes. It
++ has the cost of more pagetable lookup overhead, and also
++ consumes more pagetable space per process.
++
++config ARCH_PHYS_ADDR_T_64BIT
++ def_bool y
++ depends on X86_64 || X86_PAE
++
++config ARCH_DMA_ADDR_T_64BIT
++ def_bool y
++ depends on X86_64 || HIGHMEM64G
++
++config DIRECT_GBPAGES
++ bool "Enable 1GB pages for kernel pagetables" if EXPERT
++ default y
++ depends on X86_64
++ ---help---
++ Allow the kernel linear mapping to use 1GB pages on CPUs that
++ support it. This can improve the kernel's performance a tiny bit by
++ reducing TLB pressure. If in doubt, say "Y".
++
++# Common NUMA Features
++config NUMA
++ bool "Numa Memory Allocation and Scheduler Support"
++ depends on SMP
++ depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI))
++ default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP)
++ ---help---
++ Enable NUMA (Non Uniform Memory Access) support.
++
++ The kernel will try to allocate memory used by a CPU on the
++ local memory controller of the CPU and add some more
++ NUMA awareness to the kernel.
++
++ For 64-bit this is recommended if the system is Intel Core i7
++ (or later), AMD Opteron, or EM64T NUMA.
++
++ For 32-bit this is only needed on (rare) 32-bit-only platforms
++ that support NUMA topologies, such as NUMAQ / Summit, or if you
++ boot a 32-bit kernel on a 64-bit NUMA platform.
++
++ Otherwise, you should say N.
++
++comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
++ depends on X86_32 && X86_SUMMIT && (!HIGHMEM64G || !ACPI)
++
++config AMD_NUMA
++ def_bool y
++ prompt "Old style AMD Opteron NUMA detection"
++ depends on X86_64 && NUMA && PCI
++ ---help---
++ Enable AMD NUMA node topology detection. You should say Y here if
++ you have a multi processor AMD system. This uses an old method to
++ read the NUMA configuration directly from the builtin Northbridge
++ of Opteron. It is recommended to use X86_64_ACPI_NUMA instead,
++ which also takes priority if both are compiled in.
++
++config X86_64_ACPI_NUMA
++ def_bool y
++ prompt "ACPI NUMA detection"
++ depends on X86_64 && NUMA && ACPI && PCI
++ select ACPI_NUMA
++ ---help---
++ Enable ACPI SRAT based node topology detection.
++
++# Some NUMA nodes have memory ranges that span
++# other nodes. Even though a pfn is valid and
++# between a node's start and end pfns, it may not
++# reside on that node. See memmap_init_zone()
++# for details.
++config NODES_SPAN_OTHER_NODES
++ def_bool y
++ depends on X86_64_ACPI_NUMA
++
++config NUMA_EMU
++ bool "NUMA emulation"
++ depends on NUMA
++ ---help---
++ Enable NUMA emulation. A flat machine will be split
++ into virtual nodes when booted with "numa=fake=N", where N is the
++ number of nodes. This is only useful for debugging.
++
++config NODES_SHIFT
++ int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP
++ range 1 10
++ default "10" if MAXSMP
++ default "6" if X86_64
++ default "4" if X86_NUMAQ
++ default "3"
++ depends on NEED_MULTIPLE_NODES
++ ---help---
++ Specify the maximum number of NUMA Nodes available on the target
++ system. Increases memory reserved to accommodate various tables.
++
++config ARCH_HAVE_MEMORY_PRESENT
++ def_bool y
++ depends on X86_32 && DISCONTIGMEM
++
++config NEED_NODE_MEMMAP_SIZE
++ def_bool y
++ depends on X86_32 && (DISCONTIGMEM || SPARSEMEM)
++
++config ARCH_FLATMEM_ENABLE
++ def_bool y
++ depends on X86_32 && !NUMA
++
++config ARCH_DISCONTIGMEM_ENABLE
++ def_bool y
++ depends on NUMA && X86_32
++
++config ARCH_DISCONTIGMEM_DEFAULT
++ def_bool y
++ depends on NUMA && X86_32
++
++config ARCH_SPARSEMEM_ENABLE
++ def_bool y
++ depends on X86_64 || NUMA || X86_32 || X86_32_NON_STANDARD
++ select SPARSEMEM_STATIC if X86_32
++ select SPARSEMEM_VMEMMAP_ENABLE if X86_64
++
++config ARCH_SPARSEMEM_DEFAULT
++ def_bool y
++ depends on X86_64
++
++config ARCH_SELECT_MEMORY_MODEL
++ def_bool y
++ depends on ARCH_SPARSEMEM_ENABLE
++
++config ARCH_MEMORY_PROBE
++ def_bool y
++ depends on X86_64 && MEMORY_HOTPLUG
++
++config ARCH_PROC_KCORE_TEXT
++ def_bool y
++ depends on X86_64 && PROC_KCORE
++
++config ILLEGAL_POINTER_VALUE
++ hex
++ default 0 if X86_32
++ default 0xdead000000000000 if X86_64
++
++source "mm/Kconfig"
++
++config HIGHPTE
++ bool "Allocate 3rd-level pagetables from highmem"
++ depends on HIGHMEM
++ ---help---
++ The VM uses one page table entry for each page of physical memory.
++ For systems with a lot of RAM, this can be wasteful of precious
++ low memory. Setting this option will put user-space page table
++ entries in high memory.
++
++config X86_CHECK_BIOS_CORRUPTION
++ bool "Check for low memory corruption"
++ ---help---
++ Periodically check for memory corruption in low memory, which
++ is suspected to be caused by BIOS. Even when enabled in the
++ configuration, it is disabled at runtime. Enable it by
++ setting "memory_corruption_check=1" on the kernel command
++ line. By default it scans the low 64k of memory every 60
++ seconds; see the memory_corruption_check_size and
++ memory_corruption_check_period parameters in
++ Documentation/kernel-parameters.txt to adjust this.
++
++ When enabled with the default parameters, this option has
++ almost no overhead, as it reserves a relatively small amount
++ of memory and scans it infrequently. It both detects corruption
++ and prevents it from affecting the running system.
++
++ It is, however, intended as a diagnostic tool; if repeatable
++ BIOS-originated corruption always affects the same memory,
++ you can use memmap= to prevent the kernel from using that
++ memory.
++
++config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
++ bool "Set the default setting of memory_corruption_check"
++ depends on X86_CHECK_BIOS_CORRUPTION
++ default y
++ ---help---
++ Set whether the default state of memory_corruption_check is
++ on or off.
++
++config X86_RESERVE_LOW
++ int "Amount of low memory, in kilobytes, to reserve for the BIOS"
++ default 64
++ range 4 640
++ ---help---
++ Specify the amount of low memory to reserve for the BIOS.
++
++ The first page contains BIOS data structures that the kernel
++ must not use, so that page must always be reserved.
++
++ By default we reserve the first 64K of physical RAM, as a
++ number of BIOSes are known to corrupt that memory range
++ during events such as suspend/resume or monitor cable
++ insertion, so it must not be used by the kernel.
++
++ You can set this to 4 if you are absolutely sure that you
++ trust the BIOS to get all its memory reservations and usages
++ right. If you know your BIOS have problems beyond the
++ default 64K area, you can set this to 640 to avoid using the
++ entire low memory range.
++
++ If you have doubts about the BIOS (e.g. suspend/resume does
++ not work or there's kernel crashes after certain hardware
++ hotplug events) then you might want to enable
++ X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check
++ typical corruption patterns.
++
++ Leave this to the default value of 64 if you are unsure.
++
++config MATH_EMULATION
++ bool
++ prompt "Math emulation" if X86_32
++ ---help---
++ Linux can emulate a math coprocessor (used for floating point
++ operations) if you don't have one. 486DX and Pentium processors have
++ a math coprocessor built in, 486SX and 386 do not, unless you added
++ a 487DX or 387, respectively. (The messages during boot time can
++ give you some hints here ["man dmesg"].) Everyone needs either a
++ coprocessor or this emulation.
++
++ If you don't have a math coprocessor, you need to say Y here; if you
++ say Y here even though you have a coprocessor, the coprocessor will
++ be used nevertheless. (This behavior can be changed with the kernel
++ command line option "no387", which comes handy if your coprocessor
++ is broken. Try "man bootparam" or see the documentation of your boot
++ loader (lilo or loadlin) about how to pass options to the kernel at
++ boot time.) This means that it is a good idea to say Y here if you
++ intend to use this kernel on different machines.
++
++ More information about the internals of the Linux math coprocessor
++ emulation can be found in <file:arch/x86/math-emu/README>.
++
++ If you are not sure, say Y; apart from resulting in a 66 KB bigger
++ kernel, it won't hurt.
++
++config MTRR
++ def_bool y
++ prompt "MTRR (Memory Type Range Register) support" if EXPERT
++ ---help---
++ On Intel P6 family processors (Pentium Pro, Pentium II and later)
++ the Memory Type Range Registers (MTRRs) may be used to control
++ processor access to memory ranges. This is most useful if you have
++ a video (VGA) card on a PCI or AGP bus. Enabling write-combining
++ allows bus write transfers to be combined into a larger transfer
++ before bursting over the PCI/AGP bus. This can increase performance
++ of image write operations 2.5 times or more. Saying Y here creates a
++ /proc/mtrr file which may be used to manipulate your processor's
++ MTRRs. Typically the X server should use this.
++
++ This code has a reasonably generic interface so that similar
++ control registers on other processors can be easily supported
++ as well:
++
++ The Cyrix 6x86, 6x86MX and M II processors have Address Range
++ Registers (ARRs) which provide a similar functionality to MTRRs. For
++ these, the ARRs are used to emulate the MTRRs.
++ The AMD K6-2 (stepping 8 and above) and K6-3 processors have two
++ MTRRs. The Centaur C6 (WinChip) has 8 MCRs, allowing
++ write-combining. All of these processors are supported by this code
++ and it makes sense to say Y here if you have one of them.
++
++ Saying Y here also fixes a problem with buggy SMP BIOSes which only
++ set the MTRRs for the boot CPU and not for the secondary CPUs. This
++ can lead to all sorts of problems, so it's good to say Y here.
++
++ You can safely say Y even if your machine doesn't have MTRRs, you'll
++ just add about 9 KB to your kernel.
++
++ See <file:Documentation/x86/mtrr.txt> for more information.
++
++config MTRR_SANITIZER
++ def_bool y
++ prompt "MTRR cleanup support"
++ depends on MTRR
++ ---help---
++ Convert MTRR layout from continuous to discrete, so X drivers can
++ add writeback entries.
++
++ Can be disabled with disable_mtrr_cleanup on the kernel command line.
++ The largest mtrr entry size for a continuous block can be set with
++ mtrr_chunk_size.
++
++ If unsure, say Y.
++
++config MTRR_SANITIZER_ENABLE_DEFAULT
++ int "MTRR cleanup enable value (0-1)"
++ range 0 1
++ default "0"
++ depends on MTRR_SANITIZER
++ ---help---
++ Enable mtrr cleanup default value
++
++config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT
++ int "MTRR cleanup spare reg num (0-7)"
++ range 0 7
++ default "1"
++ depends on MTRR_SANITIZER
++ ---help---
++ mtrr cleanup spare entries default, it can be changed via
++ mtrr_spare_reg_nr=N on the kernel command line.
++
++config X86_PAT
++ def_bool y
++ prompt "x86 PAT support" if EXPERT
++ depends on MTRR
++ ---help---
++ Use PAT attributes to setup page level cache control.
++
++ PATs are the modern equivalents of MTRRs and are much more
++ flexible than MTRRs.
++
++ Say N here if you see bootup problems (boot crash, boot hang,
++ spontaneous reboots) or a non-working video driver.
++
++ If unsure, say Y.
++
++config ARCH_USES_PG_UNCACHED
++ def_bool y
++ depends on X86_PAT
++
++config ARCH_RANDOM
++ def_bool y
++ prompt "x86 architectural random number generator" if EXPERT
++ ---help---
++ Enable the x86 architectural RDRAND instruction
++ (Intel Bull Mountain technology) to generate random numbers.
++ If supported, this is a high bandwidth, cryptographically
++ secure hardware random number generator.
++
++config X86_SMAP
++ def_bool y
++ prompt "Supervisor Mode Access Prevention" if EXPERT
++ ---help---
++ Supervisor Mode Access Prevention (SMAP) is a security
++ feature in newer Intel processors. There is a small
++ performance cost if this enabled and turned on; there is
++ also a small increase in the kernel size if this is enabled.
++
++ If unsure, say Y.
++
++config EFI
++ bool "EFI runtime service support"
++ depends on ACPI
++ select UCS2_STRING
++ ---help---
++ This enables the kernel to use EFI runtime services that are
++ available (such as the EFI variable services).
++
++ This option is only useful on systems that have EFI firmware.
++ In addition, you should use the latest ELILO loader available
++ at <http://elilo.sourceforge.net> in order to take advantage
++ of EFI runtime services. However, even with this option, the
++ resultant kernel should continue to boot on existing non-EFI
++ platforms.
++
++config EFI_STUB
++ bool "EFI stub support"
++ depends on EFI
++ ---help---
++ This kernel feature allows a bzImage to be loaded directly
++ by EFI firmware without the use of a bootloader.
++
++ See Documentation/x86/efi-stub.txt for more information.
++
++config SECCOMP
++ def_bool y
++ prompt "Enable seccomp to safely compute untrusted bytecode"
++ ---help---
++ This kernel feature is useful for number crunching applications
++ that may need to compute untrusted bytecode during their
++ execution. By using pipes or other transports made available to
++ the process as file descriptors supporting the read/write
++ syscalls, it's possible to isolate those applications in
++ their own address space using seccomp. Once seccomp is
++ enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
++ and the task is only allowed to execute a few safe syscalls
++ defined by each seccomp mode.
++
++ If unsure, say Y. Only embedded should say N here.
++
++config CC_STACKPROTECTOR
++ bool "Enable -fstack-protector buffer overflow detection"
++ ---help---
++ This option turns on the -fstack-protector GCC feature. This
++ feature puts, at the beginning of functions, a canary value on
++ the stack just before the return address, and validates
++ the value just before actually returning. Stack based buffer
++ overflows (that need to overwrite this return address) now also
++ overwrite the canary, which gets detected and the attack is then
++ neutralized via a kernel panic.
++
++ This feature requires gcc version 4.2 or above, or a distribution
++ gcc with the feature backported. Older versions are automatically
++ detected and for those versions, this configuration option is
++ ignored. (and a warning is printed during bootup)
++
++source kernel/Kconfig.hz
++
++config KEXEC
++ bool "kexec system call"
++ ---help---
++ kexec is a system call that implements the ability to shutdown your
++ current kernel, and to start another kernel. It is like a reboot
++ but it is independent of the system firmware. And like a reboot
++ you can start any kernel with it, not just Linux.
++
++ The name comes from the similarity to the exec system call.
++
++ It is an ongoing process to be certain the hardware in a machine
++ is properly shutdown, so do not be surprised if this code does not
++ initially work for you. It may help to enable device hotplugging
++ support. As of this writing the exact hardware interface is
++ strongly in flux, so no good recommendation can be made.
++
++config CRASH_DUMP
++ bool "kernel crash dumps"
++ depends on X86_64 || (X86_32 && HIGHMEM)
++ ---help---
++ Generate crash dump after being started by kexec.
++ This should be normally only set in special crash dump kernels
++ which are loaded in the main kernel with kexec-tools into
++ a specially reserved region and then later executed after
++ a crash by kdump/kexec. The crash dump kernel must be compiled
++ to a memory address not used by the main kernel or BIOS using
++ PHYSICAL_START, or it must be built as a relocatable image
++ (CONFIG_RELOCATABLE=y).
++ For more details see Documentation/kdump/kdump.txt
++
++config KEXEC_JUMP
++ bool "kexec jump"
++ depends on KEXEC && HIBERNATION
++ ---help---
++ Jump between original kernel and kexeced kernel and invoke
++ code in physical address mode via KEXEC
++
++config PHYSICAL_START
++ hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
++ default "0x1000000"
++ ---help---
++ This gives the physical address where the kernel is loaded.
++
++ If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then
++ bzImage will decompress itself to above physical address and
++ run from there. Otherwise, bzImage will run from the address where
++ it has been loaded by the boot loader and will ignore above physical
++ address.
++
++ In normal kdump cases one does not have to set/change this option
++ as now bzImage can be compiled as a completely relocatable image
++ (CONFIG_RELOCATABLE=y) and be used to load and run from a different
++ address. This option is mainly useful for the folks who don't want
++ to use a bzImage for capturing the crash dump and want to use a
++ vmlinux instead. vmlinux is not relocatable hence a kernel needs
++ to be specifically compiled to run from a specific memory area
++ (normally a reserved region) and this option comes handy.
++
++ So if you are using bzImage for capturing the crash dump,
++ leave the value here unchanged to 0x1000000 and set
++ CONFIG_RELOCATABLE=y. Otherwise if you plan to use vmlinux
++ for capturing the crash dump change this value to start of
++ the reserved region. In other words, it can be set based on
++ the "X" value as specified in the "crashkernel=YM@XM"
++ command line boot parameter passed to the panic-ed
++ kernel. Please take a look at Documentation/kdump/kdump.txt
++ for more details about crash dumps.
++
++ Usage of bzImage for capturing the crash dump is recommended as
++ one does not have to build two kernels. Same kernel can be used
++ as production kernel and capture kernel. Above option should have
++ gone away after relocatable bzImage support is introduced. But it
++ is present because there are users out there who continue to use
++ vmlinux for dump capture. This option should go away down the
++ line.
++
++ Don't change this unless you know what you are doing.
++
++config RELOCATABLE
++ bool "Build a relocatable kernel"
++ default y
++ ---help---
++ This builds a kernel image that retains relocation information
++ so it can be loaded someplace besides the default 1MB.
++ The relocations tend to make the kernel binary about 10% larger,
++ but are discarded at runtime.
++
++ One use is for the kexec on panic case where the recovery kernel
++ must live at a different physical address than the primary
++ kernel.
++
++ Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
++ it has been loaded at and the compile time physical address
++ (CONFIG_PHYSICAL_START) is ignored.
++
++# Relocation on x86-32 needs some additional build support
++config X86_NEED_RELOCS
++ def_bool y
++ depends on X86_32 && RELOCATABLE
++
++config PHYSICAL_ALIGN
++ hex "Alignment value to which kernel should be aligned" if X86_32
++ default "0x1000000"
++ range 0x2000 0x1000000
++ ---help---
++ This value puts the alignment restrictions on physical address
++ where kernel is loaded and run from. Kernel is compiled for an
++ address which meets above alignment restriction.
++
++ If bootloader loads the kernel at a non-aligned address and
++ CONFIG_RELOCATABLE is set, kernel will move itself to nearest
++ address aligned to above value and run from there.
++
++ If bootloader loads the kernel at a non-aligned address and
++ CONFIG_RELOCATABLE is not set, kernel will ignore the run time
++ load address and decompress itself to the address it has been
++ compiled for and run from there. The address for which kernel is
++ compiled already meets above alignment restrictions. Hence the
++ end result is that kernel runs from a physical address meeting
++ above alignment restrictions.
++
++ Don't change this unless you know what you are doing.
++
++config HOTPLUG_CPU
++ bool "Support for hot-pluggable CPUs"
++ depends on SMP && HOTPLUG
++ ---help---
++ Say Y here to allow turning CPUs off and on. CPUs can be
++ controlled through /sys/devices/system/cpu.
++ ( Note: power management support will enable this option
++ automatically on SMP systems. )
++ Say N if you want to disable CPU hotplug.
++
++config BOOTPARAM_HOTPLUG_CPU0
++ bool "Set default setting of cpu0_hotpluggable"
++ default n
++ depends on HOTPLUG_CPU
++ ---help---
++ Set whether default state of cpu0_hotpluggable is on or off.
++
++ Say Y here to enable CPU0 hotplug by default. If this switch
++ is turned on, there is no need to give cpu0_hotplug kernel
++ parameter and the CPU0 hotplug feature is enabled by default.
++
++ Please note: there are two known CPU0 dependencies if you want
++ to enable the CPU0 hotplug feature either by this switch or by
++ cpu0_hotplug kernel parameter.
++
++ First, resume from hibernate or suspend always starts from CPU0.
++ So hibernate and suspend are prevented if CPU0 is offline.
++
++ Second dependency is PIC interrupts always go to CPU0. CPU0 can not
++ offline if any interrupt can not migrate out of CPU0. There may
++ be other CPU0 dependencies.
++
++ Please make sure the dependencies are under your control before
++ you enable this feature.
++
++ Say N if you don't want to enable CPU0 hotplug feature by default.
++ You still can enable the CPU0 hotplug feature at boot by kernel
++ parameter cpu0_hotplug.
++
++config DEBUG_HOTPLUG_CPU0
++ def_bool n
++ prompt "Debug CPU0 hotplug"
++ depends on HOTPLUG_CPU
++ ---help---
++ Enabling this option offlines CPU0 (if CPU0 can be offlined) as
++ soon as possible and boots up userspace with CPU0 offlined. User
++ can online CPU0 back after boot time.
++
++ To debug CPU0 hotplug, you need to enable CPU0 offline/online
++ feature by either turning on CONFIG_BOOTPARAM_HOTPLUG_CPU0 during
++ compilation or giving cpu0_hotplug kernel parameter at boot.
++
++ If unsure, say N.
++
++config COMPAT_VDSO
++ def_bool y
++ prompt "Compat VDSO support"
++ depends on X86_32 || IA32_EMULATION
++ ---help---
++ Map the 32-bit VDSO to the predictable old-style address too.
++
++ Say N here if you are running a sufficiently recent glibc
++ version (2.3.3 or later), to remove the high-mapped
++ VDSO mapping and to exclusively use the randomized VDSO.
++
++ If unsure, say Y.
++
++config CMDLINE_BOOL
++ bool "Built-in kernel command line"
++ ---help---
++ Allow for specifying boot arguments to the kernel at
++ build time. On some systems (e.g. embedded ones), it is
++ necessary or convenient to provide some or all of the
++ kernel boot arguments with the kernel itself (that is,
++ to not rely on the boot loader to provide them.)
++
++ To compile command line arguments into the kernel,
++ set this option to 'Y', then fill in the
++ the boot arguments in CONFIG_CMDLINE.
++
++ Systems with fully functional boot loaders (i.e. non-embedded)
++ should leave this option set to 'N'.
++
++config CMDLINE
++ string "Built-in kernel command string"
++ depends on CMDLINE_BOOL
++ default ""
++ ---help---
++ Enter arguments here that should be compiled into the kernel
++ image and used at boot time. If the boot loader provides a
++ command line at boot time, it is appended to this string to
++ form the full kernel command line, when the system boots.
++
++ However, you can use the CONFIG_CMDLINE_OVERRIDE option to
++ change this behavior.
++
++ In most cases, the command line (whether built-in or provided
++ by the boot loader) should specify the device for the root
++ file system.
++
++config CMDLINE_OVERRIDE
++ bool "Built-in command line overrides boot loader arguments"
++ depends on CMDLINE_BOOL
++ ---help---
++ Set this option to 'Y' to have the kernel ignore the boot loader
++ command line, and use ONLY the built-in command line.
++
++ This is used to work around broken boot loaders. This should
++ be set to 'N' under normal conditions.
++
++endmenu
++
++config ARCH_ENABLE_MEMORY_HOTPLUG
++ def_bool y
++ depends on X86_64 || (X86_32 && HIGHMEM)
++
++config ARCH_ENABLE_MEMORY_HOTREMOVE
++ def_bool y
++ depends on MEMORY_HOTPLUG
++
++config USE_PERCPU_NUMA_NODE_ID
++ def_bool y
++ depends on NUMA
++
++menu "Power management and ACPI options"
++
++config ARCH_HIBERNATION_HEADER
++ def_bool y
++ depends on X86_64 && HIBERNATION
++
++source "kernel/power/Kconfig"
++
++source "drivers/acpi/Kconfig"
++
++source "drivers/sfi/Kconfig"
++
++config X86_APM_BOOT
++ def_bool y
++ depends on APM
++
++menuconfig APM
++ tristate "APM (Advanced Power Management) BIOS support"
++ depends on X86_32 && PM_SLEEP
++ ---help---
++ APM is a BIOS specification for saving power using several different
++ techniques. This is mostly useful for battery powered laptops with
++ APM compliant BIOSes. If you say Y here, the system time will be
++ reset after a RESUME operation, the /proc/apm device will provide
++ battery status information, and user-space programs will receive
++ notification of APM "events" (e.g. battery status change).
++
++ If you select "Y" here, you can disable actual use of the APM
++ BIOS by passing the "apm=off" option to the kernel at boot time.
++
++ Note that the APM support is almost completely disabled for
++ machines with more than one CPU.
++
++ In order to use APM, you will need supporting software. For location
++ and more information, read <file:Documentation/power/apm-acpi.txt>
++ and the Battery Powered Linux mini-HOWTO, available from
++ <http://www.tldp.org/docs.html#howto>.
++
++ This driver does not spin down disk drives (see the hdparm(8)
++ manpage ("man 8 hdparm") for that), and it doesn't turn off
++ VESA-compliant "green" monitors.
++
++ This driver does not support the TI 4000M TravelMate and the ACER
++ 486/DX4/75 because they don't have compliant BIOSes. Many "green"
++ desktop machines also don't have compliant BIOSes, and this driver
++ may cause those machines to panic during the boot phase.
++
++ Generally, if you don't have a battery in your machine, there isn't
++ much point in using this driver and you should say N. If you get
++ random kernel OOPSes or reboots that don't seem to be related to
++ anything, try disabling/enabling this option (or disabling/enabling
++ APM in your BIOS).
++
++ Some other things you should try when experiencing seemingly random,
++ "weird" problems:
++
++ 1) make sure that you have enough swap space and that it is
++ enabled.
++ 2) pass the "no-hlt" option to the kernel
++ 3) switch on floating point emulation in the kernel and pass
++ the "no387" option to the kernel
++ 4) pass the "floppy=nodma" option to the kernel
++ 5) pass the "mem=4M" option to the kernel (thereby disabling
++ all but the first 4 MB of RAM)
++ 6) make sure that the CPU is not over clocked.
++ 7) read the sig11 FAQ at <http://www.bitwizard.nl/sig11/>
++ 8) disable the cache from your BIOS settings
++ 9) install a fan for the video card or exchange video RAM
++ 10) install a better fan for the CPU
++ 11) exchange RAM chips
++ 12) exchange the motherboard.
++
++ To compile this driver as a module, choose M here: the
++ module will be called apm.
++
++if APM
++
++config APM_IGNORE_USER_SUSPEND
++ bool "Ignore USER SUSPEND"
++ ---help---
++ This option will ignore USER SUSPEND requests. On machines with a
++ compliant APM BIOS, you want to say N. However, on the NEC Versa M
++ series notebooks, it is necessary to say Y because of a BIOS bug.
++
++config APM_DO_ENABLE
++ bool "Enable PM at boot time"
++ ---help---
++ Enable APM features at boot time. From page 36 of the APM BIOS
++ specification: "When disabled, the APM BIOS does not automatically
++ power manage devices, enter the Standby State, enter the Suspend
++ State, or take power saving steps in response to CPU Idle calls."
++ This driver will make CPU Idle calls when Linux is idle (unless this
++ feature is turned off -- see "Do CPU IDLE calls", below). This
++ should always save battery power, but more complicated APM features
++ will be dependent on your BIOS implementation. You may need to turn
++ this option off if your computer hangs at boot time when using APM
++ support, or if it beeps continuously instead of suspending. Turn
++ this off if you have a NEC UltraLite Versa 33/C or a Toshiba
++ T400CDT. This is off by default since most machines do fine without
++ this feature.
++
++config APM_CPU_IDLE
++ depends on CPU_IDLE
++ bool "Make CPU Idle calls when idle"
++ ---help---
++ Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop.
++ On some machines, this can activate improved power savings, such as
++ a slowed CPU clock rate, when the machine is idle. These idle calls
++ are made after the idle loop has run for some length of time (e.g.,
++ 333 mS). On some machines, this will cause a hang at boot time or
++ whenever the CPU becomes idle. (On machines with more than one CPU,
++ this option does nothing.)
++
++config APM_DISPLAY_BLANK
++ bool "Enable console blanking using APM"
++ ---help---
++ Enable console blanking using the APM. Some laptops can use this to
++ turn off the LCD backlight when the screen blanker of the Linux
++ virtual console blanks the screen. Note that this is only used by
++ the virtual console screen blanker, and won't turn off the backlight
++ when using the X Window system. This also doesn't have anything to
++ do with your VESA-compliant power-saving monitor. Further, this
++ option doesn't work for all laptops -- it might not turn off your
++ backlight at all, or it might print a lot of errors to the console,
++ especially if you are using gpm.
++
++config APM_ALLOW_INTS
++ bool "Allow interrupts during APM BIOS calls"
++ ---help---
++ Normally we disable external interrupts while we are making calls to
++ the APM BIOS as a measure to lessen the effects of a badly behaving
++ BIOS implementation. The BIOS should reenable interrupts if it
++ needs to. Unfortunately, some BIOSes do not -- especially those in
++ many of the newer IBM Thinkpads. If you experience hangs when you
++ suspend, try setting this to Y. Otherwise, say N.
++
++endif # APM
++
++source "drivers/cpufreq/Kconfig"
++
++source "drivers/cpuidle/Kconfig"
++
++source "drivers/idle/Kconfig"
++
++endmenu
++
++
++menu "Bus options (PCI etc.)"
++
++config PCI
++ bool "PCI support"
++ default y
++ select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
++ ---help---
++ Find out whether you have a PCI motherboard. PCI is the name of a
++ bus system, i.e. the way the CPU talks to the other stuff inside
++ your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or
++ VESA. If you have PCI, say Y, otherwise N.
++
++choice
++ prompt "PCI access mode"
++ depends on X86_32 && PCI
++ default PCI_GOANY
++ ---help---
++ On PCI systems, the BIOS can be used to detect the PCI devices and
++ determine their configuration. However, some old PCI motherboards
++ have BIOS bugs and may crash if this is done. Also, some embedded
++ PCI-based systems don't have any BIOS at all. Linux can also try to
++ detect the PCI hardware directly without using the BIOS.
++
++ With this option, you can specify how Linux should detect the
++ PCI devices. If you choose "BIOS", the BIOS will be used,
++ if you choose "Direct", the BIOS won't be used, and if you
++ choose "MMConfig", then PCI Express MMCONFIG will be used.
++ If you choose "Any", the kernel will try MMCONFIG, then the
++ direct access method and falls back to the BIOS if that doesn't
++ work. If unsure, go with the default, which is "Any".
++
++config PCI_GOBIOS
++ bool "BIOS"
++
++config PCI_GOMMCONFIG
++ bool "MMConfig"
++
++config PCI_GODIRECT
++ bool "Direct"
++
++config PCI_GOOLPC
++ bool "OLPC XO-1"
++ depends on OLPC
++
++config PCI_GOANY
++ bool "Any"
++
++endchoice
++
++config PCI_BIOS
++ def_bool y
++ depends on X86_32 && PCI && (PCI_GOBIOS || PCI_GOANY)
++
++# x86-64 doesn't support PCI BIOS access from long mode so always go direct.
++config PCI_DIRECT
++ def_bool y
++ depends on PCI && (X86_64 || (PCI_GODIRECT || PCI_GOANY || PCI_GOOLPC || PCI_GOMMCONFIG))
++
++config PCI_MMCONFIG
++ def_bool y
++ depends on X86_32 && PCI && (ACPI || SFI) && (PCI_GOMMCONFIG || PCI_GOANY)
++
++config PCI_OLPC
++ def_bool y
++ depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY)
++
++config PCI_XEN
++ def_bool y
++ depends on PCI && XEN
++ select SWIOTLB_XEN
++
++config PCI_DOMAINS
++ def_bool y
++ depends on PCI
++
++config PCI_MMCONFIG
++ bool "Support mmconfig PCI config space access"
++ depends on X86_64 && PCI && ACPI
++
++config PCI_CNB20LE_QUIRK
++ bool "Read CNB20LE Host Bridge Windows" if EXPERT
++ depends on PCI
++ help
++ Read the PCI windows out of the CNB20LE host bridge. This allows
++ PCI hotplug to work on systems with the CNB20LE chipset which do
++ not have ACPI.
++
++ There's no public spec for this chipset, and this functionality
++ is known to be incomplete.
++
++ You should say N unless you know you need this.
++
++source "drivers/pci/pcie/Kconfig"
++
++source "drivers/pci/Kconfig"
++
++# x86_64 have no ISA slots, but can have ISA-style DMA.
++config ISA_DMA_API
++ bool "ISA-style DMA support" if (X86_64 && EXPERT)
++ default y
++ help
++ Enables ISA-style DMA support for devices requiring such controllers.
++ If unsure, say Y.
++
++if X86_32
++
++config ISA
++ bool "ISA support"
++ ---help---
++ Find out whether you have ISA slots on your motherboard. ISA is the
++ name of a bus system, i.e. the way the CPU talks to the other stuff
++ inside your box. Other bus systems are PCI, EISA, MicroChannel
++ (MCA) or VESA. ISA is an older system, now being displaced by PCI;
++ newer boards don't support it. If you have ISA, say Y, otherwise N.
++
++config EISA
++ bool "EISA support"
++ depends on ISA
++ ---help---
++ The Extended Industry Standard Architecture (EISA) bus was
++ developed as an open alternative to the IBM MicroChannel bus.
++
++ The EISA bus provided some of the features of the IBM MicroChannel
++ bus while maintaining backward compatibility with cards made for
++ the older ISA bus. The EISA bus saw limited use between 1988 and
++ 1995 when it was made obsolete by the PCI bus.
++
++ Say Y here if you are building a kernel for an EISA-based machine.
++
++ Otherwise, say N.
++
++source "drivers/eisa/Kconfig"
++
++config SCx200
++ tristate "NatSemi SCx200 support"
++ ---help---
++ This provides basic support for National Semiconductor's
++ (now AMD's) Geode processors. The driver probes for the
++ PCI-IDs of several on-chip devices, so its a good dependency
++ for other scx200_* drivers.
++
++ If compiled as a module, the driver is named scx200.
++
++config SCx200HR_TIMER
++ tristate "NatSemi SCx200 27MHz High-Resolution Timer Support"
++ depends on SCx200
++ default y
++ ---help---
++ This driver provides a clocksource built upon the on-chip
++ 27MHz high-resolution timer. Its also a workaround for
++ NSC Geode SC-1100's buggy TSC, which loses time when the
++ processor goes idle (as is done by the scheduler). The
++ other workaround is idle=poll boot option.
++
++config OLPC
++ bool "One Laptop Per Child support"
++ depends on !X86_PAE
++ select GPIOLIB
++ select OF
++ select OF_PROMTREE
++ select IRQ_DOMAIN
++ ---help---
++ Add support for detecting the unique features of the OLPC
++ XO hardware.
++
++config OLPC_XO1_PM
++ bool "OLPC XO-1 Power Management"
++ depends on OLPC && MFD_CS5535 && PM_SLEEP
++ select MFD_CORE
++ ---help---
++ Add support for poweroff and suspend of the OLPC XO-1 laptop.
++
++config OLPC_XO1_RTC
++ bool "OLPC XO-1 Real Time Clock"
++ depends on OLPC_XO1_PM && RTC_DRV_CMOS
++ ---help---
++ Add support for the XO-1 real time clock, which can be used as a
++ programmable wakeup source.
++
++config OLPC_XO1_SCI
++ bool "OLPC XO-1 SCI extras"
++ depends on OLPC && OLPC_XO1_PM
++ depends on INPUT=y
++ select POWER_SUPPLY
++ select GPIO_CS5535
++ select MFD_CORE
++ ---help---
++ Add support for SCI-based features of the OLPC XO-1 laptop:
++ - EC-driven system wakeups
++ - Power button
++ - Ebook switch
++ - Lid switch
++ - AC adapter status updates
++ - Battery status updates
++
++config OLPC_XO15_SCI
++ bool "OLPC XO-1.5 SCI extras"
++ depends on OLPC && ACPI
++ select POWER_SUPPLY
++ ---help---
++ Add support for SCI-based features of the OLPC XO-1.5 laptop:
++ - EC-driven system wakeups
++ - AC adapter status updates
++ - Battery status updates
++
++config ALIX
++ bool "PCEngines ALIX System Support (LED setup)"
++ select GPIOLIB
++ ---help---
++ This option enables system support for the PCEngines ALIX.
++ At present this just sets up LEDs for GPIO control on
++ ALIX2/3/6 boards. However, other system specific setup should
++ get added here.
++
++ Note: You must still enable the drivers for GPIO and LED support
++ (GPIO_CS5535 & LEDS_GPIO) to actually use the LEDs
++
++ Note: You have to set alix.force=1 for boards with Award BIOS.
++
++config NET5501
++ bool "Soekris Engineering net5501 System Support (LEDS, GPIO, etc)"
++ select GPIOLIB
++ ---help---
++ This option enables system support for the Soekris Engineering net5501.
++
++config GEOS
++ bool "Traverse Technologies GEOS System Support (LEDS, GPIO, etc)"
++ select GPIOLIB
++ depends on DMI
++ ---help---
++ This option enables system support for the Traverse Technologies GEOS.
++
++config TS5500
++ bool "Technologic Systems TS-5500 platform support"
++ depends on MELAN
++ select CHECK_SIGNATURE
++ select NEW_LEDS
++ select LEDS_CLASS
++ ---help---
++ This option enables system support for the Technologic Systems TS-5500.
++
++endif # X86_32
++
++config AMD_NB
++ def_bool y
++ depends on CPU_SUP_AMD && PCI
++
++source "drivers/pcmcia/Kconfig"
++
++source "drivers/pci/hotplug/Kconfig"
++
++config RAPIDIO
++ bool "RapidIO support"
++ depends on PCI
++ default n
++ help
++ If you say Y here, the kernel will include drivers and
++ infrastructure code to support RapidIO interconnect devices.
++
++source "drivers/rapidio/Kconfig"
++
++endmenu
++
++
++menu "Executable file formats / Emulations"
++
++source "fs/Kconfig.binfmt"
++
++config IA32_EMULATION
++ bool "IA32 Emulation"
++ depends on X86_64
++ select BINFMT_ELF
++ select COMPAT_BINFMT_ELF
++ select HAVE_UID16
++ ---help---
++ Include code to run legacy 32-bit programs under a
++ 64-bit kernel. You should likely turn this on, unless you're
++ 100% sure that you don't have any 32-bit programs left.
++
++config IA32_AOUT
++ tristate "IA32 a.out support"
++ depends on IA32_EMULATION
++ ---help---
++ Support old a.out binaries in the 32bit emulation.
++
++config X86_X32
++ bool "x32 ABI for 64-bit mode"
++ depends on X86_64 && IA32_EMULATION
++ ---help---
++ Include code to run binaries for the x32 native 32-bit ABI
++ for 64-bit processors. An x32 process gets access to the
++ full 64-bit register file and wide data path while leaving
++ pointers at 32 bits for smaller memory footprint.
++
++ You will need a recent binutils (2.22 or later) with
++ elf32_x86_64 support enabled to compile a kernel with this
++ option set.
++
++config COMPAT
++ def_bool y
++ depends on IA32_EMULATION || X86_X32
++ select ARCH_WANT_OLD_COMPAT_IPC
++
++if COMPAT
++config COMPAT_FOR_U64_ALIGNMENT
++ def_bool y
++
++config SYSVIPC_COMPAT
++ def_bool y
++ depends on SYSVIPC
++
++config KEYS_COMPAT
++ def_bool y
++ depends on KEYS
++endif
++
++endmenu
++
++
++config HAVE_ATOMIC_IOMAP
++ def_bool y
++ depends on X86_32
++
++config HAVE_TEXT_POKE_SMP
++ bool
++ select STOP_MACHINE if SMP
++
++config X86_DEV_DMA_OPS
++ bool
++ depends on X86_64 || STA2X11
++
++config X86_DMA_REMAP
++ bool
++ depends on STA2X11
++
++source "net/Kconfig"
++
++source "drivers/Kconfig"
++
++source "drivers/firmware/Kconfig"
++
++source "fs/Kconfig"
++
++source "arch/x86/Kconfig.debug"
++
++source "security/Kconfig"
++
++source "crypto/Kconfig"
++
++source "arch/x86/kvm/Kconfig"
++
++source "lib/Kconfig"
diff --git a/toolchain/musl/Makefile b/toolchain/musl/Makefile
index 91a6add88..3782e5672 100644
--- a/toolchain/musl/Makefile
+++ b/toolchain/musl/Makefile
@@ -6,6 +6,13 @@ include ../rules.mk
include Makefile.inc
include ${TOPDIR}/mk/buildhlp.mk
+ifeq ($(CPU_ARCH),ppc)
+REAL_GNU_TARGET_NAME:= $(subst ppc,powerpc,$(REAL_GNU_TARGET_NAME))
+endif
+ifeq ($(CPU_ARCH),mips64el)
+REAL_GNU_TARGET_NAME:= $(subst mips64el,mips,$(REAL_GNU_TARGET_NAME))
+endif
+
$(WRKBUILD)/.headers:
(cd $(WRKBUILD); CC='$(TARGET_CC)' CROSS_COMPILE='$(TARGET_CROSS)' \
./configure --prefix=/usr \
@@ -21,6 +28,14 @@ $(WRKBUILD)/.compiled:
touch $@
$(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
+ # reconfigure musl, otherwise linking with libgcc or libgcc_eh is disabled
+ $(MAKE) CFLAGS='$(TARGET_CFLAGS)' -C $(WRKBUILD) clean
+ (cd $(WRKBUILD); CC='$(TARGET_CC)' CROSS_COMPILE='$(TARGET_CROSS)' \
+ ./configure --prefix=/usr \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --disable-gcc-wrapper \
+ )
+ $(MAKE) CFLAGS='$(TARGET_CFLAGS)' -C $(WRKBUILD) all
$(MAKE) -C $(WRKBUILD) DESTDIR=$(STAGING_TARGET_DIR) install
touch $@
diff --git a/toolchain/musl/patches/0.9.13/libgcc.patch b/toolchain/musl/patches/0.9.13/libgcc.patch
deleted file mode 100644
index d382ef1fa..000000000
--- a/toolchain/musl/patches/0.9.13/libgcc.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Nur musl-0.9.12.orig/Makefile musl-0.9.12/Makefile
---- musl-0.9.12.orig/Makefile 2013-07-29 09:20:33.000000000 +0200
-+++ musl-0.9.12/Makefile 2013-08-17 16:10:10.000000000 +0200
-@@ -100,7 +100,7 @@
- $(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $<
-
- lib/libc.so: $(LOBJS)
-- $(CC) $(CFLAGS_ALL_SHARED) $(LDFLAGS) -nostdlib -shared \
-+ $(CC) $(CFLAGS_ALL_SHARED) $(LDFLAGS) -static-libgcc -nostdlib -shared \
- -Wl,-e,_start -Wl,-Bsymbolic-functions \
- -o $@ $(LOBJS) $(LIBCC)
-
diff --git a/toolchain/musl/patches/0.9.13/musl-git.patch b/toolchain/musl/patches/0.9.13/musl-git.patch
new file mode 100644
index 000000000..a6a87390f
--- /dev/null
+++ b/toolchain/musl/patches/0.9.13/musl-git.patch
@@ -0,0 +1,8837 @@
+diff -Nur musl-0.9.13/.gitignore musl-git/.gitignore
+--- musl-0.9.13/.gitignore 1970-01-01 01:00:00.000000000 +0100
++++ musl-git/.gitignore 2013-09-16 20:31:39.000000000 +0200
+@@ -0,0 +1,10 @@
++*.o
++*.lo
++*.a
++*.so
++*.so.1
++arch/*/bits/alltypes.h
++config.mak
++include/bits
++tools/musl-gcc
++lib/musl-gcc.specs
+diff -Nur musl-0.9.13/Makefile musl-git/Makefile
+--- musl-0.9.13/Makefile 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/Makefile 2013-09-16 20:31:39.000000000 +0200
+@@ -157,7 +157,7 @@
+ $(INSTALL) -D -m 644 $< $@
+
+ $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so
+- $(INSTALL) -D -l $< $@ || true
++ $(INSTALL) -D -l $(libdir)/libc.so $@ || true
+
+ install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)
+
+diff -Nur musl-0.9.13/arch/microblaze/bits/limits.h musl-git/arch/microblaze/bits/limits.h
+--- musl-0.9.13/arch/microblaze/bits/limits.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/microblaze/bits/limits.h 2013-09-16 20:31:39.000000000 +0200
+@@ -1,6 +1,5 @@
+ #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+-#define PAGE_SIZE 4096
+ #define LONG_BIT 32
+ #endif
+
+diff -Nur musl-0.9.13/arch/microblaze/reloc.h musl-git/arch/microblaze/reloc.h
+--- musl-0.9.13/arch/microblaze/reloc.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/microblaze/reloc.h 2013-09-16 20:31:39.000000000 +0200
+@@ -49,7 +49,7 @@
+ for (a+=c+1; *a; a++);
+ for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
+ base = (char *)t[AT_BASE];
+- if (!base) base = (char *)(t[AT_PHDR] & -4096);
++ if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
+ for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
+ n = t[DT_RELASZ];
+ for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
+diff -Nur musl-0.9.13/arch/mips/bits/limits.h musl-git/arch/mips/bits/limits.h
+--- musl-0.9.13/arch/mips/bits/limits.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/mips/bits/limits.h 2013-09-16 20:31:39.000000000 +0200
+@@ -1,6 +1,5 @@
+ #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+-#define PAGE_SIZE 4096
+ #define LONG_BIT 32
+ #endif
+
+diff -Nur musl-0.9.13/arch/mips/bits/msg.h musl-git/arch/mips/bits/msg.h
+--- musl-0.9.13/arch/mips/bits/msg.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/mips/bits/msg.h 2013-09-16 20:31:39.000000000 +0200
+@@ -1,12 +1,21 @@
+ struct msqid_ds
+ {
+ struct ipc_perm msg_perm;
++#if _MIPSEL || __MIPSEL || __MIPSEL__
+ time_t msg_stime;
+ int __unused1;
+ time_t msg_rtime;
+ int __unused2;
+ time_t msg_ctime;
+ int __unused3;
++#else
++ int __unused1;
++ time_t msg_stime;
++ int __unused2;
++ time_t msg_rtime;
++ int __unused3;
++ time_t msg_ctime;
++#endif
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+diff -Nur musl-0.9.13/arch/mips/bits/shm.h musl-git/arch/mips/bits/shm.h
+--- musl-0.9.13/arch/mips/bits/shm.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/mips/bits/shm.h 2013-09-16 20:31:39.000000000 +0200
+@@ -5,11 +5,8 @@
+ struct ipc_perm shm_perm;
+ size_t shm_segsz;
+ time_t shm_atime;
+- int __unused1;
+ time_t shm_dtime;
+- int __unused2;
+ time_t shm_ctime;
+- int __unused3;
+ pid_t shm_cpid;
+ pid_t shm_lpid;
+ unsigned long shm_nattch;
+diff -Nur musl-0.9.13/arch/mips/reloc.h musl-git/arch/mips/reloc.h
+--- musl-0.9.13/arch/mips/reloc.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/mips/reloc.h 2013-09-16 20:31:39.000000000 +0200
+@@ -51,7 +51,7 @@
+ for (a+=c+1; *a; a++);
+ for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
+ base = (char *)t[AT_BASE];
+- if (!base) base = (char *)(t[AT_PHDR] & -4096);
++ if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
+ for (a=dynv; *a; a+=2) if (*a-0x70000000UL<20) t[*a&31] = a[1];
+ n = t[DT_MIPS_LOCAL_GOTNO - 0x70000000];
+ for (a=got; n; a++, n--) *a += (size_t)base;
+diff -Nur musl-0.9.13/arch/powerpc/bits/limits.h musl-git/arch/powerpc/bits/limits.h
+--- musl-0.9.13/arch/powerpc/bits/limits.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/powerpc/bits/limits.h 2013-09-16 20:31:39.000000000 +0200
+@@ -1,6 +1,5 @@
+ #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+-#define PAGE_SIZE 4096
+ #define LONG_BIT 32
+ #endif
+
+diff -Nur musl-0.9.13/arch/powerpc/reloc.h musl-git/arch/powerpc/reloc.h
+--- musl-0.9.13/arch/powerpc/reloc.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/arch/powerpc/reloc.h 2013-09-16 20:31:39.000000000 +0200
+@@ -46,7 +46,7 @@
+ for (a+=c+1; *a; a++);
+ for (a++; *a; a+=2) if (*a<20) t[*a] = a[1];
+ base = (char *)t[AT_BASE];
+- if (!base) base = (char *)(t[AT_PHDR] & -4096);
++ if (!base) base = (char *)(t[AT_PHDR] & -t[AT_PAGESZ]);
+ for (a=dynv; *a; a+=2) if (*a<20) t[*a] = a[1];
+ n = t[DT_RELASZ];
+ for (a=(void *)(base+t[DT_RELA]); n; a+=3, n-=12)
+diff -Nur musl-0.9.13/include/elf.h musl-git/include/elf.h
+--- musl-0.9.13/include/elf.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/elf.h 2013-09-16 20:31:39.000000000 +0200
+@@ -105,6 +105,7 @@
+ #define ELFOSABI_HPUX 1
+ #define ELFOSABI_NETBSD 2
+ #define ELFOSABI_LINUX 3
++#define ELFOSABI_GNU 3
+ #define ELFOSABI_SOLARIS 6
+ #define ELFOSABI_AIX 7
+ #define ELFOSABI_IRIX 8
+@@ -211,7 +212,11 @@
+ #define EM_OPENRISC 92
+ #define EM_ARC_A5 93
+ #define EM_XTENSA 94
+-#define EM_NUM 95
++#define EM_AARCH64 183
++#define EM_TILEPRO 188
++#define EM_MICROBLAZE 189
++#define EM_TILEGX 191
++#define EM_NUM 192
+ #define EM_ALPHA 0x9026
+
+ #define EV_NONE 0
+@@ -487,6 +492,8 @@
+ #define PT_HIPROC 0x7fffffff
+
+
++#define PN_XNUM 0xffff
++
+
+ #define PF_X (1 << 0)
+ #define PF_W (1 << 1)
+@@ -512,12 +519,31 @@
+ #define NT_LWPSTATUS 16
+ #define NT_LWPSINFO 17
+ #define NT_PRFPXREG 20
++#define NT_SIGINFO 0x53494749
++#define NT_FILE 0x46494c45
+ #define NT_PRXFPREG 0x46e62b7f
+ #define NT_PPC_VMX 0x100
+ #define NT_PPC_SPE 0x101
+ #define NT_PPC_VSX 0x102
+ #define NT_386_TLS 0x200
+ #define NT_386_IOPERM 0x201
++#define NT_X86_XSTATE 0x202
++#define NT_S390_HIGH_GPRS 0x300
++#define NT_S390_TIMER 0x301
++#define NT_S390_TODCMP 0x302
++#define NT_S390_TODPREG 0x303
++#define NT_S390_CTRS 0x304
++#define NT_S390_PREFIX 0x305
++#define NT_S390_LAST_BREAK 0x306
++#define NT_S390_SYSTEM_CALL 0x307
++#define NT_S390_TDB 0x308
++#define NT_ARM_VFP 0x400
++#define NT_ARM_TLS 0x401
++#define NT_ARM_HW_BREAK 0x402
++#define NT_ARM_HW_WATCH 0x403
++#define NT_METAG_CBUF 0x500
++#define NT_METAG_RPIPE 0x501
++#define NT_METAG_TLS 0x502
+ #define NT_VERSION 1
+
+
+@@ -666,7 +692,15 @@
+ #define DF_1_ENDFILTEE 0x00004000
+ #define DF_1_DISPRELDNE 0x00008000
+ #define DF_1_DISPRELPND 0x00010000
+-
++#define DF_1_NODIRECT 0x00020000
++#define DF_1_IGNMULDEF 0x00040000
++#define DF_1_NOKSYMS 0x00080000
++#define DF_1_NOHDR 0x00100000
++#define DF_1_EDITED 0x00200000
++#define DF_1_NORELOC 0x00400000
++#define DF_1_SYMINTPOSE 0x00800000
++#define DF_1_GLOBAUDIT 0x01000000
++#define DF_1_SINGLETON 0x02000000
+
+ #define DTF_1_PARINIT 0x00000001
+ #define DTF_1_CONFEXP 0x00000002
+@@ -832,6 +866,8 @@
+
+ #define AT_RANDOM 25
+
++#define AT_HWCAP2 26
++
+ #define AT_EXECFN 31
+
+
+@@ -979,6 +1015,7 @@
+ #define R_386_TLS_DTPMOD32 35
+ #define R_386_TLS_DTPOFF32 36
+ #define R_386_TLS_TPOFF32 37
++#define R_386_SIZE32 38
+ #define R_386_TLS_GOTDESC 39
+ #define R_386_TLS_DESC_CALL 40
+ #define R_386_TLS_DESC 41
+@@ -1109,20 +1146,6 @@
+ #define DT_SPARC_NUM 2
+
+
+-
+-#define HWCAP_SPARC_FLUSH 1
+-#define HWCAP_SPARC_STBAR 2
+-#define HWCAP_SPARC_SWAP 4
+-#define HWCAP_SPARC_MULDIV 8
+-#define HWCAP_SPARC_V9 16
+-#define HWCAP_SPARC_ULTRA3 32
+-#define HWCAP_SPARC_BLKINIT 64
+-#define HWCAP_SPARC_N2 128
+-
+-
+-
+-
+-
+ #define EF_MIPS_NOREORDER 1
+ #define EF_MIPS_PIC 2
+ #define EF_MIPS_CPIC 4
+@@ -1139,9 +1162,10 @@
+ #define EF_MIPS_ARCH_3 0x20000000
+ #define EF_MIPS_ARCH_4 0x30000000
+ #define EF_MIPS_ARCH_5 0x40000000
+-#define EF_MIPS_ARCH_32 0x60000000
+-#define EF_MIPS_ARCH_64 0x70000000
+-
++#define EF_MIPS_ARCH_32 0x50000000
++#define EF_MIPS_ARCH_64 0x60000000
++#define EF_MIPS_ARCH_32R2 0x70000000
++#define EF_MIPS_ARCH_64R2 0x80000000
+
+
+ #define E_MIPS_ARCH_1 0x00000000
+@@ -1149,8 +1173,8 @@
+ #define E_MIPS_ARCH_3 0x20000000
+ #define E_MIPS_ARCH_4 0x30000000
+ #define E_MIPS_ARCH_5 0x40000000
+-#define E_MIPS_ARCH_32 0x60000000
+-#define E_MIPS_ARCH_64 0x70000000
++#define E_MIPS_ARCH_32 0x50000000
++#define E_MIPS_ARCH_64 0x60000000
+
+
+
+@@ -2020,7 +2044,8 @@
+ #define EF_ARM_VFP_FLOAT 0x400
+ #define EF_ARM_MAVERICK_FLOAT 0x800
+
+-
++#define EF_ARM_ABI_FLOAT_SOFT 0x200
++#define EF_ARM_ABI_FLOAT_HARD 0x400
+
+
+ #define EF_ARM_SYMSARESORTED 0x04
+@@ -2064,6 +2089,17 @@
+ #define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3)
+
+
++#define R_AARCH64_NONE 0
++#define R_AARCH64_ABS64 257
++#define R_AARCH64_ABS32 258
++#define R_AARCH64_COPY 1024
++#define R_AARCH64_GLOB_DAT 1025
++#define R_AARCH64_JUMP_SLOT 1026
++#define R_AARCH64_RELATIVE 1027
++#define R_AARCH64_TLS_DTPMOD64 1028
++#define R_AARCH64_TLS_DTPREL64 1029
++#define R_AARCH64_TLS_TPREL64 1030
++#define R_AARCH64_TLSDESC 1031
+
+
+ #define R_ARM_NONE 0
+@@ -2079,7 +2115,7 @@
+ #define R_ARM_THM_PC22 10
+ #define R_ARM_THM_PC8 11
+ #define R_ARM_AMP_VCALL9 12
+-#define R_ARM_SWI24 13
++#define R_ARM_TLS_DESC 13
+ #define R_ARM_THM_SWI8 14
+ #define R_ARM_XPC25 15
+ #define R_ARM_THM_XPC22 16
+@@ -2094,12 +2130,78 @@
+ #define R_ARM_GOTPC 25
+ #define R_ARM_GOT32 26
+ #define R_ARM_PLT32 27
++#define R_ARM_CALL 28
++#define R_ARM_JUMP24 29
++#define R_ARM_THM_JUMP24 30
++#define R_ARM_BASE_ABS 31
+ #define R_ARM_ALU_PCREL_7_0 32
+ #define R_ARM_ALU_PCREL_15_8 33
+ #define R_ARM_ALU_PCREL_23_15 34
+ #define R_ARM_LDR_SBREL_11_0 35
+ #define R_ARM_ALU_SBREL_19_12 36
+ #define R_ARM_ALU_SBREL_27_20 37
++#define R_ARM_TARGET1 38
++#define R_ARM_SBREL31 39
++#define R_ARM_V4BX 40
++#define R_ARM_TARGET2 41
++#define R_ARM_PREL31 42
++#define R_ARM_MOVW_ABS_NC 43
++#define R_ARM_MOVT_ABS 44
++#define R_ARM_MOVW_PREL_NC 45
++#define R_ARM_MOVT_PREL 46
++#define R_ARM_THM_MOVW_ABS_NC 47
++#define R_ARM_THM_MOVT_ABS 48
++#define R_ARM_THM_MOVW_PREL_NC 49
++#define R_ARM_THM_MOVT_PREL 50
++#define R_ARM_THM_JUMP19 51
++#define R_ARM_THM_JUMP6 52
++#define R_ARM_THM_ALU_PREL_11_0 53
++#define R_ARM_THM_PC12 54
++#define R_ARM_ABS32_NOI 55
++#define R_ARM_REL32_NOI 56
++#define R_ARM_ALU_PC_G0_NC 57
++#define R_ARM_ALU_PC_G0 58
++#define R_ARM_ALU_PC_G1_NC 59
++#define R_ARM_ALU_PC_G1 60
++#define R_ARM_ALU_PC_G2 61
++#define R_ARM_LDR_PC_G1 62
++#define R_ARM_LDR_PC_G2 63
++#define R_ARM_LDRS_PC_G0 64
++#define R_ARM_LDRS_PC_G1 65
++#define R_ARM_LDRS_PC_G2 66
++#define R_ARM_LDC_PC_G0 67
++#define R_ARM_LDC_PC_G1 68
++#define R_ARM_LDC_PC_G2 69
++#define R_ARM_ALU_SB_G0_NC 70
++#define R_ARM_ALU_SB_G0 71
++#define R_ARM_ALU_SB_G1_NC 72
++#define R_ARM_ALU_SB_G1 73
++#define R_ARM_ALU_SB_G2 74
++#define R_ARM_LDR_SB_G0 75
++#define R_ARM_LDR_SB_G1 76
++#define R_ARM_LDR_SB_G2 77
++#define R_ARM_LDRS_SB_G0 78
++#define R_ARM_LDRS_SB_G1 79
++#define R_ARM_LDRS_SB_G2 80
++#define R_ARM_LDC_SB_G0 81
++#define R_ARM_LDC_SB_G1 82
++#define R_ARM_LDC_SB_G2 83
++#define R_ARM_MOVW_BREL_NC 84
++#define R_ARM_MOVT_BREL 85
++#define R_ARM_MOVW_BREL 86
++#define R_ARM_THM_MOVW_BREL_NC 87
++#define R_ARM_THM_MOVT_BREL 88
++#define R_ARM_THM_MOVW_BREL 89
++#define R_ARM_TLS_GOTDESC 90
++#define R_ARM_TLS_CALL 91
++#define R_ARM_TLS_DESCSEQ 92
++#define R_ARM_THM_TLS_CALL 93
++#define R_ARM_PLT32_ABS 94
++#define R_ARM_GOT_ABS 95
++#define R_ARM_GOT_PREL 96
++#define R_ARM_GOT_BREL12 97
++#define R_ARM_GOTOFF12 98
++#define R_ARM_GOTRELAX 99
+ #define R_ARM_GNU_VTENTRY 100
+ #define R_ARM_GNU_VTINHERIT 101
+ #define R_ARM_THM_PC11 102
+@@ -2113,7 +2215,15 @@
+ #define R_ARM_TLS_IE32 107
+
+ #define R_ARM_TLS_LE32 108
+-
++#define R_ARM_TLS_LDO12 109
++#define R_ARM_TLS_LE12 110
++#define R_ARM_TLS_IE12GP 111
++#define R_ARM_ME_TOO 128
++#define R_ARM_THM_TLS_DESCSEQ 129
++#define R_ARM_THM_TLS_DESCSEQ16 129
++#define R_ARM_THM_TLS_DESCSEQ32 130
++#define R_ARM_THM_GOT_BREL12 131
++#define R_ARM_IRELATIVE 160
+ #define R_ARM_RXPC25 249
+ #define R_ARM_RSBREL32 250
+ #define R_ARM_THM_RPC22 251
+@@ -2421,15 +2531,21 @@
+ #define R_X86_64_PC64 24
+ #define R_X86_64_GOTOFF64 25
+ #define R_X86_64_GOTPC32 26
+-
++#define R_X86_64_GOT64 27
++#define R_X86_64_GOTPCREL64 28
++#define R_X86_64_GOTPC64 29
++#define R_X86_64_GOTPLT64 30
++#define R_X86_64_PLTOFF64 31
++#define R_X86_64_SIZE32 32
++#define R_X86_64_SIZE64 33
+
+ #define R_X86_64_GOTPC32_TLSDESC 34
+ #define R_X86_64_TLSDESC_CALL 35
+
+ #define R_X86_64_TLSDESC 36
+ #define R_X86_64_IRELATIVE 37
+-
+-#define R_X86_64_NUM 38
++#define R_X86_64_RELATIVE64 38
++#define R_X86_64_NUM 39
+
+
+
+diff -Nur musl-0.9.13/include/limits.h musl-git/include/limits.h
+--- musl-0.9.13/include/limits.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/limits.h 2013-09-16 20:31:39.000000000 +0200
+@@ -40,7 +40,9 @@
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+ #define PIPE_BUF 4096
++#ifdef PAGE_SIZE
+ #define PAGESIZE PAGE_SIZE
++#endif
+ #define FILESIZEBITS 64
+ #define NAME_MAX 255
+ #define SYMLINK_MAX 255
+diff -Nur musl-0.9.13/include/net/if_arp.h musl-git/include/net/if_arp.h
+--- musl-0.9.13/include/net/if_arp.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/net/if_arp.h 2013-09-16 20:31:39.000000000 +0200
+@@ -52,6 +52,7 @@
+ #define ARPHRD_ROSE 270
+ #define ARPHRD_X25 271
+ #define ARPHRD_HWX25 272
++#define ARPHRD_CAN 280
+ #define ARPHRD_PPP 512
+ #define ARPHRD_CISCO 513
+ #define ARPHRD_HDLC ARPHRD_CISCO
+@@ -84,7 +85,12 @@
+ #define ARPHRD_IEEE80211_PRISM 802
+ #define ARPHRD_IEEE80211_RADIOTAP 803
+ #define ARPHRD_IEEE802154 804
+-#define ARPHRD_IEEE802154_PHY 805
++#define ARPHRD_IEEE802154_MONITOR 805
++#define ARPHRD_PHONET 820
++#define ARPHRD_PHONET_PIPE 821
++#define ARPHRD_CAIF 822
++#define ARPHRD_IP6GRE 823
++#define ARPHRD_NETLINK 824
+
+ #define ARPHRD_VOID 0xFFFF
+ #define ARPHRD_NONE 0xFFFE
+diff -Nur musl-0.9.13/include/netinet/in.h musl-git/include/netinet/in.h
+--- musl-0.9.13/include/netinet/in.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/netinet/in.h 2013-09-16 20:31:39.000000000 +0200
+@@ -91,10 +91,12 @@
+ #define IPPROTO_NONE 59
+ #define IPPROTO_DSTOPTS 60
+ #define IPPROTO_MTP 92
++#define IPPROTO_BEETPH 94
+ #define IPPROTO_ENCAP 98
+ #define IPPROTO_PIM 103
+ #define IPPROTO_COMP 108
+ #define IPPROTO_SCTP 132
++#define IPPROTO_MH 135
+ #define IPPROTO_UDPLITE 136
+ #define IPPROTO_RAW 255
+ #define IPPROTO_MAX 256
+diff -Nur musl-0.9.13/include/sys/ptrace.h musl-git/include/sys/ptrace.h
+--- musl-0.9.13/include/sys/ptrace.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/sys/ptrace.h 2013-09-16 20:31:39.000000000 +0200
+@@ -37,6 +37,8 @@
+ #define PTRACE_INTERRUPT 0x4207
+ #define PTRACE_LISTEN 0x4208
+ #define PTRACE_PEEKSIGINFO 0x4209
++#define PTRACE_GETSIGMASK 0x420a
++#define PTRACE_SETSIGMASK 0x420b
+
+ #define PT_READ_I PTRACE_PEEKTEXT
+ #define PT_READ_D PTRACE_PEEKDATA
+diff -Nur musl-0.9.13/include/sys/resource.h musl-git/include/sys/resource.h
+--- musl-0.9.13/include/sys/resource.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/sys/resource.h 2013-09-16 20:31:39.000000000 +0200
+@@ -59,6 +59,9 @@
+ #define prlimit64 prlimit
+ #endif
+
++#define PRIO_MIN (-20)
++#define PRIO_MAX 20
++
+ #define PRIO_PROCESS 0
+ #define PRIO_PGRP 1
+ #define PRIO_USER 2
+diff -Nur musl-0.9.13/include/sys/socket.h musl-git/include/sys/socket.h
+--- musl-0.9.13/include/sys/socket.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/include/sys/socket.h 2013-09-16 20:31:39.000000000 +0200
+@@ -199,6 +199,7 @@
+ #define SO_NOFCS 43
+ #define SO_LOCK_FILTER 44
+ #define SO_SELECT_ERR_QUEUE 45
++#define SO_BUSY_POLL 46
+
+ #ifndef SOL_SOCKET
+ #define SOL_SOCKET 1
+diff -Nur musl-0.9.13/include/wait.h musl-git/include/wait.h
+--- musl-0.9.13/include/wait.h 1970-01-01 01:00:00.000000000 +0100
++++ musl-git/include/wait.h 2013-09-16 20:31:39.000000000 +0200
+@@ -0,0 +1,2 @@
++#warning redirecting incorrect #include <wait.h> to <sys/wait.h>
++#include <sys/wait.h>
+diff -Nur musl-0.9.13/src/aio/aio_readwrite.c musl-git/src/aio/aio_readwrite.c
+--- musl-0.9.13/src/aio/aio_readwrite.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/aio/aio_readwrite.c 2013-09-16 20:31:39.000000000 +0200
+@@ -2,8 +2,8 @@
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <unistd.h>
+-#include <limits.h>
+ #include "pthread_impl.h"
++#include "libc.h"
+
+ static void dummy(void)
+ {
+diff -Nur musl-0.9.13/src/aio/lio_listio.c musl-git/src/aio/lio_listio.c
+--- musl-0.9.13/src/aio/lio_listio.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/aio/lio_listio.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,9 +1,9 @@
+ #include <aio.h>
+ #include <errno.h>
+-#include <limits.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include "pthread_impl.h"
++#include "libc.h"
+
+ struct lio_state {
+ struct sigevent *sev;
+diff -Nur musl-0.9.13/src/conf/fpathconf.c musl-git/src/conf/fpathconf.c
+--- musl-0.9.13/src/conf/fpathconf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/conf/fpathconf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -19,11 +19,11 @@
+ [_PC_PRIO_IO] = -1,
+ [_PC_SOCK_MAXBUF] = -1,
+ [_PC_FILESIZEBITS] = FILESIZEBITS,
+- [_PC_REC_INCR_XFER_SIZE] = PAGE_SIZE,
+- [_PC_REC_MAX_XFER_SIZE] = PAGE_SIZE,
+- [_PC_REC_MIN_XFER_SIZE] = PAGE_SIZE,
+- [_PC_REC_XFER_ALIGN] = PAGE_SIZE,
+- [_PC_ALLOC_SIZE_MIN] = PAGE_SIZE,
++ [_PC_REC_INCR_XFER_SIZE] = 4096,
++ [_PC_REC_MAX_XFER_SIZE] = 4096,
++ [_PC_REC_MIN_XFER_SIZE] = 4096,
++ [_PC_REC_XFER_ALIGN] = 4096,
++ [_PC_ALLOC_SIZE_MIN] = 4096,
+ [_PC_SYMLINK_MAX] = SYMLINK_MAX,
+ [_PC_2_SYMLINKS] = 1
+ };
+diff -Nur musl-0.9.13/src/conf/sysconf.c musl-git/src/conf/sysconf.c
+--- musl-0.9.13/src/conf/sysconf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/conf/sysconf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -3,6 +3,7 @@
+ #include <errno.h>
+ #include <sys/resource.h>
+ #include "syscall.h"
++#include "libc.h"
+
+ #define VER (-2)
+ #define OFLOW (-3)
+@@ -40,9 +41,9 @@
+ [_SC_AIO_PRIO_DELTA_MAX] = 0, /* ?? */
+ [_SC_DELAYTIMER_MAX] = _POSIX_DELAYTIMER_MAX,
+ [_SC_MQ_OPEN_MAX] = -1,
+- [_SC_MQ_PRIO_MAX] = MQ_PRIO_MAX,
++ [_SC_MQ_PRIO_MAX] = OFLOW,
+ [_SC_VERSION] = VER,
+- [_SC_PAGE_SIZE] = PAGE_SIZE,
++ [_SC_PAGE_SIZE] = OFLOW,
+ [_SC_RTSIG_MAX] = 63, /* ?? */
+ [_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX,
+ [_SC_SEM_VALUE_MAX] = OFLOW,
+@@ -221,6 +222,9 @@
+ } else if (values[name] == OFLOW) {
+ if (name == _SC_ARG_MAX) return ARG_MAX;
+ if (name == _SC_SEM_VALUE_MAX) return SEM_VALUE_MAX;
++ if (name == _SC_MQ_PRIO_MAX) return MQ_PRIO_MAX;
++ /* name == _SC_PAGE_SIZE */
++ return PAGE_SIZE;
+ } else if (values[name] == CPUCNT) {
+ unsigned char set[128] = {1};
+ int i, cnt;
+diff -Nur musl-0.9.13/src/env/__libc_start_main.c musl-git/src/env/__libc_start_main.c
+--- musl-0.9.13/src/env/__libc_start_main.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/env/__libc_start_main.c 2013-09-16 20:31:39.000000000 +0200
+@@ -26,6 +26,7 @@
+ for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
+ __hwcap = aux[AT_HWCAP];
+ __sysinfo = aux[AT_SYSINFO];
++ libc.page_size = aux[AT_PAGESZ];
+
+ if (pn) {
+ __progname = __progname_full = pn;
+diff -Nur musl-0.9.13/src/internal/libc.h musl-git/src/internal/libc.h
+--- musl-0.9.13/src/internal/libc.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/internal/libc.h 2013-09-16 20:31:39.000000000 +0200
+@@ -3,6 +3,7 @@
+
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <limits.h>
+
+ struct __libc {
+ void *main_thread;
+@@ -14,10 +15,15 @@
+ FILE *ofl_head;
+ int ofl_lock[2];
+ size_t tls_size;
++ size_t page_size;
+ };
+
+ extern size_t __hwcap;
+
++#ifndef PAGE_SIZE
++#define PAGE_SIZE libc.page_size
++#endif
++
+ #if !defined(__PIC__) || (100*__GNUC__+__GNUC_MINOR__ >= 303 && !defined(__PCC__))
+
+ #ifdef __PIC__
+diff -Nur musl-0.9.13/src/internal/libm.h musl-git/src/internal/libm.h
+--- musl-0.9.13/src/internal/libm.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/internal/libm.h 2013-09-16 20:31:39.000000000 +0200
+@@ -17,117 +17,115 @@
+ #include <float.h>
+ #include <math.h>
+ #include <complex.h>
++#include <endian.h>
+
+-#include "longdbl.h"
+-
+-#include "libc.h"
+-
+-union fshape {
+- float value;
+- uint32_t bits;
++#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
++#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
++union ldshape {
++ long double f;
++ struct {
++ uint64_t m;
++ uint16_t se;
++ } i;
+ };
+-
+-union dshape {
+- double value;
+- uint64_t bits;
++#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 && __BYTE_ORDER == __LITTLE_ENDIAN
++union ldshape {
++ long double f;
++ struct {
++ uint64_t lo;
++ uint32_t mid;
++ uint16_t top;
++ uint16_t se;
++ } i;
++ struct {
++ uint64_t lo;
++ uint64_t hi;
++ } i2;
+ };
++#else
++#error Unsupported long double representation
++#endif
+
+-#define FORCE_EVAL(x) do { \
+- if (sizeof(x) == sizeof(float)) { \
+- volatile float __x; \
+- __x = (x); \
+- } else if (sizeof(x) == sizeof(double)) { \
+- volatile double __x; \
+- __x = (x); \
+- } else { \
+- volatile long double __x; \
+- __x = (x); \
+- } \
++#define FORCE_EVAL(x) do { \
++ if (sizeof(x) == sizeof(float)) { \
++ volatile float __x; \
++ __x = (x); \
++ } else if (sizeof(x) == sizeof(double)) { \
++ volatile double __x; \
++ __x = (x); \
++ } else { \
++ volatile long double __x; \
++ __x = (x); \
++ } \
+ } while(0)
+
+ /* Get two 32 bit ints from a double. */
+-#define EXTRACT_WORDS(hi,lo,d) \
+-do { \
+- union dshape __u; \
+- __u.value = (d); \
+- (hi) = __u.bits >> 32; \
+- (lo) = (uint32_t)__u.bits; \
+-} while (0)
+-
+-/* Get a 64 bit int from a double. */
+-#define EXTRACT_WORD64(i,d) \
+-do { \
+- union dshape __u; \
+- __u.value = (d); \
+- (i) = __u.bits; \
++#define EXTRACT_WORDS(hi,lo,d) \
++do { \
++ union {double f; uint64_t i;} __u; \
++ __u.f = (d); \
++ (hi) = __u.i >> 32; \
++ (lo) = (uint32_t)__u.i; \
+ } while (0)
+
+ /* Get the more significant 32 bit int from a double. */
+-#define GET_HIGH_WORD(i,d) \
+-do { \
+- union dshape __u; \
+- __u.value = (d); \
+- (i) = __u.bits >> 32; \
++#define GET_HIGH_WORD(hi,d) \
++do { \
++ union {double f; uint64_t i;} __u; \
++ __u.f = (d); \
++ (hi) = __u.i >> 32; \
+ } while (0)
+
+ /* Get the less significant 32 bit int from a double. */
+-#define GET_LOW_WORD(i,d) \
+-do { \
+- union dshape __u; \
+- __u.value = (d); \
+- (i) = (uint32_t)__u.bits; \
++#define GET_LOW_WORD(lo,d) \
++do { \
++ union {double f; uint64_t i;} __u; \
++ __u.f = (d); \
++ (lo) = (uint32_t)__u.i; \
+ } while (0)
+
+ /* Set a double from two 32 bit ints. */
+-#define INSERT_WORDS(d,hi,lo) \
+-do { \
+- union dshape __u; \
+- __u.bits = ((uint64_t)(hi) << 32) | (uint32_t)(lo); \
+- (d) = __u.value; \
+-} while (0)
+-
+-/* Set a double from a 64 bit int. */
+-#define INSERT_WORD64(d,i) \
+-do { \
+- union dshape __u; \
+- __u.bits = (i); \
+- (d) = __u.value; \
++#define INSERT_WORDS(d,hi,lo) \
++do { \
++ union {double f; uint64_t i;} __u; \
++ __u.i = ((uint64_t)(hi)<<32) | (uint32_t)(lo); \
++ (d) = __u.f; \
+ } while (0)
+
+ /* Set the more significant 32 bits of a double from an int. */
+-#define SET_HIGH_WORD(d,hi) \
+-do { \
+- union dshape __u; \
+- __u.value = (d); \
+- __u.bits &= 0xffffffff; \
+- __u.bits |= (uint64_t)(hi) << 32; \
+- (d) = __u.value; \
++#define SET_HIGH_WORD(d,hi) \
++do { \
++ union {double f; uint64_t i;} __u; \
++ __u.f = (d); \
++ __u.i &= 0xffffffff; \
++ __u.i |= (uint64_t)(hi) << 32; \
++ (d) = __u.f; \
+ } while (0)
+
+ /* Set the less significant 32 bits of a double from an int. */
+-#define SET_LOW_WORD(d,lo) \
+-do { \
+- union dshape __u; \
+- __u.value = (d); \
+- __u.bits &= 0xffffffff00000000ull; \
+- __u.bits |= (uint32_t)(lo); \
+- (d) = __u.value; \
++#define SET_LOW_WORD(d,lo) \
++do { \
++ union {double f; uint64_t i;} __u; \
++ __u.f = (d); \
++ __u.i &= 0xffffffff00000000ull; \
++ __u.i |= (uint32_t)(lo); \
++ (d) = __u.f; \
+ } while (0)
+
+ /* Get a 32 bit int from a float. */
+-#define GET_FLOAT_WORD(i,d) \
+-do { \
+- union fshape __u; \
+- __u.value = (d); \
+- (i) = __u.bits; \
++#define GET_FLOAT_WORD(w,d) \
++do { \
++ union {float f; uint32_t i;} __u; \
++ __u.f = (d); \
++ (w) = __u.i; \
+ } while (0)
+
+ /* Set a float from a 32 bit int. */
+-#define SET_FLOAT_WORD(d,i) \
+-do { \
+- union fshape __u; \
+- __u.bits = (i); \
+- (d) = __u.value; \
++#define SET_FLOAT_WORD(d,w) \
++do { \
++ union {float f; uint32_t i;} __u; \
++ __u.i = (w); \
++ (d) = __u.f; \
+ } while (0)
+
+ /* fdlibm kernel functions */
+@@ -157,15 +155,4 @@
+ long double __polevll(long double, const long double *, int);
+ long double __p1evll(long double, const long double *, int);
+
+-#if 0
+-/* Attempt to get strict C99 semantics for assignment with non-C99 compilers. */
+-#define STRICT_ASSIGN(type, lval, rval) do { \
+- volatile type __v = (rval); \
+- (lval) = __v; \
+-} while (0)
+-#else
+-/* Should work with -fexcess-precision=standard (>=gcc-4.5) or -ffloat-store */
+-#define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval))
+-#endif
+-
+ #endif
+diff -Nur musl-0.9.13/src/internal/longdbl.h musl-git/src/internal/longdbl.h
+--- musl-0.9.13/src/internal/longdbl.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/internal/longdbl.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,137 +0,0 @@
+-#ifndef _LDHACK_H
+-#define _LDHACK_H
+-
+-#include <float.h>
+-#include <stdint.h>
+-
+-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-union ldshape {
+- long double value;
+- struct {
+- uint64_t m;
+- uint16_t exp:15;
+- uint16_t sign:1;
+- uint16_t pad;
+- } bits;
+-};
+-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+-union ldshape {
+- long double value;
+- struct {
+- uint64_t mlo;
+- uint64_t mhi:48;
+- uint16_t exp:15;
+- uint16_t sign:1;
+- } bits;
+-};
+-#else
+-#error Unsupported long double representation
+-#endif
+-
+-
+-// FIXME: hacks to make freebsd+openbsd long double code happy
+-
+-// union and macros for freebsd
+-
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-
+-union IEEEl2bits {
+- long double e;
+- struct {
+- uint32_t manl:32;
+- uint32_t manh:32;
+- uint32_t exp:15;
+- uint32_t sign:1;
+- uint32_t pad:16;
+- } bits;
+- struct {
+- uint64_t man:64;
+- uint32_t expsign:16;
+- uint32_t pad:16;
+- } xbits;
+-};
+-
+-#define LDBL_MANL_SIZE 32
+-#define LDBL_MANH_SIZE 32
+-#define LDBL_NBIT (1ull << LDBL_MANH_SIZE-1)
+-#undef LDBL_IMPLICIT_NBIT
+-#define mask_nbit_l(u) ((u).bits.manh &= ~LDBL_NBIT)
+-
+-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+-/*
+-// ld128 float.h
+-//#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
+-#define LDBL_MAX 0x1.ffffffffffffffffffffffffffffp+16383
+-#define LDBL_MAX_EXP 16384
+-#define LDBL_HAS_INFINITY 1
+-//#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
+-#define LDBL_MIN 0x1p-16382
+-#define LDBL_HAS_QUIET_NAN 1
+-#define LDBL_HAS_DENORM 1
+-//#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L
+-#define LDBL_EPSILON 0x1p-112
+-#define LDBL_MANT_DIG 113
+-#define LDBL_MIN_EXP (-16381)
+-#define LDBL_MAX_10_EXP 4932
+-#define LDBL_DENORM_MIN 0x0.0000000000000000000000000001p-16381
+-#define LDBL_MIN_10_EXP (-4931)
+-#define LDBL_DIG 33
+-*/
+-
+-union IEEEl2bits {
+- long double e;
+- struct {
+- uint64_t manl:64;
+- uint64_t manh:48;
+- uint32_t exp:15;
+- uint32_t sign:1;
+- } bits;
+- struct {
+- uint64_t unused0:64;
+- uint64_t unused1:48;
+- uint32_t expsign:16;
+- } xbits;
+-};
+-
+-#define LDBL_MANL_SIZE 64
+-#define LDBL_MANH_SIZE 48
+-#define LDBL_NBIT (1ull << LDBL_MANH_SIZE)
+-#define LDBL_IMPLICIT_NBIT 1
+-#define mask_nbit_l(u)
+-
+-#endif
+-
+-
+-// macros for openbsd
+-
+-#define GET_LDOUBLE_WORDS(se,mh,ml, f) do{ \
+- union IEEEl2bits u; \
+- u.e = (f); \
+- (se) = u.xbits.expsign; \
+- (mh) = u.bits.manh; \
+- (ml) = u.bits.manl; \
+-}while(0)
+-
+-#define SET_LDOUBLE_WORDS(f, se,mh,ml) do{ \
+- union IEEEl2bits u; \
+- u.xbits.expsign = (se); \
+- u.bits.manh = (mh); \
+- u.bits.manl = (ml); \
+- (f) = u.e; \
+-}while(0)
+-
+-#define GET_LDOUBLE_EXP(se, f) do{ \
+- union IEEEl2bits u; \
+- u.e = (f); \
+- (se) = u.xbits.expsign; \
+-}while(0)
+-
+-#define SET_LDOUBLE_EXP(f, se) do{ \
+- union IEEEl2bits u; \
+- u.e = (f); \
+- u.xbits.expsign = (se); \
+- (f) = u.e; \
+-}while(0)
+-
+-#endif
+diff -Nur musl-0.9.13/src/ldso/dynlink.c musl-git/src/ldso/dynlink.c
+--- musl-0.9.13/src/ldso/dynlink.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/ldso/dynlink.c 2013-09-16 20:31:39.000000000 +0200
+@@ -614,6 +614,8 @@
+ sys_path = "";
+ }
+ fclose(f);
++ } else if (errno != ENOENT) {
++ sys_path = "";
+ }
+ }
+ if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib";
+@@ -978,6 +980,7 @@
+ env_preload = 0;
+ libc.secure = 1;
+ }
++ libc.page_size = aux[AT_PAGESZ];
+
+ /* If the dynamic linker was invoked as a program itself, AT_BASE
+ * will not be set. In that case, we assume the base address is
+diff -Nur musl-0.9.13/src/legacy/getpagesize.c musl-git/src/legacy/getpagesize.c
+--- musl-0.9.13/src/legacy/getpagesize.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/legacy/getpagesize.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,5 +1,5 @@
+ #include <unistd.h>
+-#include <limits.h>
++#include "libc.h"
+
+ int getpagesize(void)
+ {
+diff -Nur musl-0.9.13/src/legacy/valloc.c musl-git/src/legacy/valloc.c
+--- musl-0.9.13/src/legacy/valloc.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/legacy/valloc.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,6 +1,6 @@
+ #define _BSD_SOURCE
+ #include <stdlib.h>
+-#include <limits.h>
++#include "libc.h"
+
+ void *valloc(size_t size)
+ {
+diff -Nur musl-0.9.13/src/math/__cosl.c musl-git/src/math/__cosl.c
+--- musl-0.9.13/src/math/__cosl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__cosl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,4 +1,5 @@
+ /* origin: FreeBSD /usr/src/lib/msun/ld80/k_cosl.c */
++/* origin: FreeBSD /usr/src/lib/msun/ld128/k_cosl.c */
+ /*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+@@ -14,7 +15,8 @@
+
+ #include "libm.h"
+
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
++#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
++#if LDBL_MANT_DIG == 64
+ /*
+ * ld80 version of __cos.c. See __cos.c for most comments.
+ */
+@@ -43,7 +45,6 @@
+ */
+ static const long double
+ C1 = 0.0416666666666666666136L; /* 0xaaaaaaaaaaaaaa9b.0p-68 */
+-
+ static const double
+ C2 = -0.0013888888888888874, /* -0x16c16c16c16c10.0p-62 */
+ C3 = 0.000024801587301571716, /* 0x1a01a01a018e22.0p-68 */
+@@ -51,13 +52,43 @@
+ C5 = 0.0000000020876754400407278, /* 0x11eed8caaeccf1.0p-81 */
+ C6 = -1.1470297442401303e-11, /* -0x19393412bd1529.0p-89 */
+ C7 = 4.7383039476436467e-14; /* 0x1aac9d9af5c43e.0p-97 */
++#define POLY(z) (z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*C7)))))))
++#elif LDBL_MANT_DIG == 113
++/*
++ * ld128 version of __cos.c. See __cos.c for most comments.
++ */
++/*
++ * Domain [-0.7854, 0.7854], range ~[-1.80e-37, 1.79e-37]:
++ * |cos(x) - c(x))| < 2**-122.0
++ *
++ * 113-bit precision requires more care than 64-bit precision, since
++ * simple methods give a minimax polynomial with coefficient for x^2
++ * that is 1 ulp below 0.5, but we want it to be precisely 0.5. See
++ * above for more details.
++ */
++static const long double
++C1 = 0.04166666666666666666666666666666658424671L,
++C2 = -0.001388888888888888888888888888863490893732L,
++C3 = 0.00002480158730158730158730158600795304914210L,
++C4 = -0.2755731922398589065255474947078934284324e-6L,
++C5 = 0.2087675698786809897659225313136400793948e-8L,
++C6 = -0.1147074559772972315817149986812031204775e-10L,
++C7 = 0.4779477332386808976875457937252120293400e-13L;
++static const double
++C8 = -0.1561920696721507929516718307820958119868e-15,
++C9 = 0.4110317413744594971475941557607804508039e-18,
++C10 = -0.8896592467191938803288521958313920156409e-21,
++C11 = 0.1601061435794535138244346256065192782581e-23;
++#define POLY(z) (z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*(C7+ \
++ z*(C8+z*(C9+z*(C10+z*C11)))))))))))
++#endif
+
+ long double __cosl(long double x, long double y)
+ {
+ long double hz,z,r,w;
+
+ z = x*x;
+- r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*C7))))));
++ r = POLY(z);
+ hz = 0.5*z;
+ w = 1.0-hz;
+ return w + (((1.0-w)-hz) + (z*r-x*y));
+diff -Nur musl-0.9.13/src/math/__fpclassify.c musl-git/src/math/__fpclassify.c
+--- musl-0.9.13/src/math/__fpclassify.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__fpclassify.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,11 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ int __fpclassify(double x)
+ {
+- union dshape u = { x };
+- int e = u.bits>>52 & 0x7ff;
+- if (!e) return u.bits<<1 ? FP_SUBNORMAL : FP_ZERO;
+- if (e==0x7ff) return u.bits<<12 ? FP_NAN : FP_INFINITE;
++ union {double f; uint64_t i;} u = {x};
++ int e = u.i>>52 & 0x7ff;
++ if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
++ if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
+ return FP_NORMAL;
+ }
+diff -Nur musl-0.9.13/src/math/__fpclassifyf.c musl-git/src/math/__fpclassifyf.c
+--- musl-0.9.13/src/math/__fpclassifyf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__fpclassifyf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,11 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ int __fpclassifyf(float x)
+ {
+- union fshape u = { x };
+- int e = u.bits>>23 & 0xff;
+- if (!e) return u.bits<<1 ? FP_SUBNORMAL : FP_ZERO;
+- if (e==0xff) return u.bits<<9 ? FP_NAN : FP_INFINITE;
++ union {float f; uint32_t i;} u = {x};
++ int e = u.i>>23 & 0xff;
++ if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
++ if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE;
+ return FP_NORMAL;
+ }
+diff -Nur musl-0.9.13/src/math/__fpclassifyl.c musl-git/src/math/__fpclassifyl.c
+--- musl-0.9.13/src/math/__fpclassifyl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__fpclassifyl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -5,26 +5,28 @@
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+ int __fpclassifyl(long double x)
+ {
+- union ldshape u = { x };
+- int e = u.bits.exp;
+- if (!e) {
+- if (u.bits.m >> 63) return FP_NAN;
+- else if (u.bits.m) return FP_SUBNORMAL;
+- else return FP_ZERO;
+- }
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++ int msb = u.i.m>>63;
++ if (!e && !msb)
++ return u.i.m ? FP_SUBNORMAL : FP_ZERO;
++ if (!msb)
++ return FP_NAN;
+ if (e == 0x7fff)
+- return u.bits.m & (uint64_t)-1>>1 ? FP_NAN : FP_INFINITE;
+- return u.bits.m & (uint64_t)1<<63 ? FP_NORMAL : FP_NAN;
++ return u.i.m << 1 ? FP_NAN : FP_INFINITE;
++ return FP_NORMAL;
+ }
+ #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+ int __fpclassifyl(long double x)
+ {
+- union ldshape u = { x };
+- int e = u.bits.exp;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
+ if (!e)
+- return u.bits.mlo | u.bits.mhi ? FP_SUBNORMAL : FP_ZERO;
+- if (e == 0x7fff)
+- return u.bits.mlo | u.bits.mhi ? FP_NAN : FP_INFINITE;
++ return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO;
++ if (e == 0x7fff) {
++ u.i.se = 0;
++ return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE;
++ }
+ return FP_NORMAL;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/__invtrigl.c musl-git/src/math/__invtrigl.c
+--- musl-0.9.13/src/math/__invtrigl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__invtrigl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,7 +1,7 @@
++#include <float.h>
+ #include "__invtrigl.h"
+
+ #if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-
+ static const long double
+ pS0 = 1.66666666666666666631e-01L,
+ pS1 = -4.16313987993683104320e-01L,
+@@ -28,4 +28,36 @@
+ q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*(qS4+z*qS5))));
+ return p/q;
+ }
++#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
++static const long double
++pS0 = 1.66666666666666666666666666666700314e-01L,
++pS1 = -7.32816946414566252574527475428622708e-01L,
++pS2 = 1.34215708714992334609030036562143589e+00L,
++pS3 = -1.32483151677116409805070261790752040e+00L,
++pS4 = 7.61206183613632558824485341162121989e-01L,
++pS5 = -2.56165783329023486777386833928147375e-01L,
++pS6 = 4.80718586374448793411019434585413855e-02L,
++pS7 = -4.42523267167024279410230886239774718e-03L,
++pS8 = 1.44551535183911458253205638280410064e-04L,
++pS9 = -2.10558957916600254061591040482706179e-07L,
++qS1 = -4.84690167848739751544716485245697428e+00L,
++qS2 = 9.96619113536172610135016921140206980e+00L,
++qS3 = -1.13177895428973036660836798461641458e+01L,
++qS4 = 7.74004374389488266169304117714658761e+00L,
++qS5 = -3.25871986053534084709023539900339905e+00L,
++qS6 = 8.27830318881232209752469022352928864e-01L,
++qS7 = -1.18768052702942805423330715206348004e-01L,
++qS8 = 8.32600764660522313269101537926539470e-03L,
++qS9 = -1.99407384882605586705979504567947007e-04L;
++
++const long double pio2_hi = 1.57079632679489661923132169163975140L;
++const long double pio2_lo = 4.33590506506189051239852201302167613e-35L;
++
++long double __invtrigl_R(long double z)
++{
++ long double p, q;
++ p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*(pS5+z*(pS6+z*(pS7+z*(pS8+z*pS9)))))))));
++ q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*(qS4+z*(qS5+z*(pS6+z*(pS7+z*(pS8+z*pS9))))))));
++ return p/q;
++}
+ #endif
+diff -Nur musl-0.9.13/src/math/__invtrigl.h musl-git/src/math/__invtrigl.h
+--- musl-0.9.13/src/math/__invtrigl.h 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__invtrigl.h 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,6 @@
+-#include <float.h>
+-
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+ /* shared by acosl, asinl and atan2l */
+ #define pio2_hi __pio2_hi
+ #define pio2_lo __pio2_lo
+ extern const long double pio2_hi, pio2_lo;
+
+ long double __invtrigl_R(long double z);
+-#endif
+diff -Nur musl-0.9.13/src/math/__rem_pio2.c musl-git/src/math/__rem_pio2.c
+--- musl-0.9.13/src/math/__rem_pio2.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__rem_pio2.c 2013-09-16 20:31:39.000000000 +0200
+@@ -112,7 +112,7 @@
+ uint32_t high;
+ medium:
+ /* Use a specialized rint() to get fn. Assume round-to-nearest. */
+- STRICT_ASSIGN(double, fn, x*invpio2 + 0x1.8p52);
++ fn = x*invpio2 + 0x1.8p52;
+ fn = fn - 0x1.8p52;
+ // FIXME
+ #ifdef HAVE_EFFICIENT_IRINT
+diff -Nur musl-0.9.13/src/math/__rem_pio2_large.c musl-git/src/math/__rem_pio2_large.c
+--- musl-0.9.13/src/math/__rem_pio2_large.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__rem_pio2_large.c 2013-09-16 20:31:39.000000000 +0200
+@@ -415,7 +415,8 @@
+ fw = 0.0;
+ for (i=jz; i>=0; i--)
+ fw += fq[i];
+- STRICT_ASSIGN(double,fw,fw);
++ // TODO: drop excess precision here once double_t is used
++ fw = (double)fw;
+ y[0] = ih==0 ? fw : -fw;
+ fw = fq[0]-fw;
+ for (i=1; i<=jz; i++)
+diff -Nur musl-0.9.13/src/math/__rem_pio2f.c musl-git/src/math/__rem_pio2f.c
+--- musl-0.9.13/src/math/__rem_pio2f.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__rem_pio2f.c 2013-09-16 20:31:39.000000000 +0200
+@@ -44,7 +44,7 @@
+ /* 25+53 bit pi is good enough for medium size */
+ if (ix < 0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
+ /* Use a specialized rint() to get fn. Assume round-to-nearest. */
+- STRICT_ASSIGN(double, fn, x*invpio2 + 0x1.8p52);
++ fn = x*invpio2 + 0x1.8p52;
+ fn = fn - 0x1.8p52;
+ // FIXME
+ #ifdef HAVE_EFFICIENT_IRINT
+diff -Nur musl-0.9.13/src/math/__rem_pio2l.c musl-git/src/math/__rem_pio2l.c
+--- musl-0.9.13/src/math/__rem_pio2l.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__rem_pio2l.c 2013-09-16 20:31:39.000000000 +0200
+@@ -13,15 +13,22 @@
+ * Optimized by Bruce D. Evans.
+ */
+ #include "libm.h"
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-/* ld80 version of __rem_pio2(x,y)
++#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
++/* ld80 and ld128 version of __rem_pio2(x,y)
+ *
+ * return the remainder of x rem pi/2 in y[0]+y[1]
+ * use __rem_pio2_large() for large x
+ */
+
+-#define BIAS (LDBL_MAX_EXP - 1)
+-
++#if LDBL_MANT_DIG == 64
++/* u ~< 0x1p25*pi/2 */
++#define SMALL(u) (((u.i.se & 0x7fffU)<<16 | u.i.m>>48) < ((0x3fff + 25)<<16 | 0x921f>>1 | 0x8000))
++#define TOINT 0x1.8p63
++#define QUOBITS(x) ((uint32_t)(int32_t)x & 0x7fffffff)
++#define ROUND1 22
++#define ROUND2 61
++#define NX 3
++#define NY 2
+ /*
+ * invpio2: 64 bits of 2/pi
+ * pio2_1: first 39 bits of pi/2
+@@ -32,60 +39,61 @@
+ * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
+ */
+ static const double
+-two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
+ pio2_1 = 1.57079632679597125389e+00, /* 0x3FF921FB, 0x54444000 */
+ pio2_2 = -1.07463465549783099519e-12, /* -0x12e7b967674000.0p-92 */
+ pio2_3 = 6.36831716351370313614e-25; /* 0x18a2e037074000.0p-133 */
+-
+ static const long double
+ invpio2 = 6.36619772367581343076e-01L, /* 0xa2f9836e4e44152a.0p-64 */
+ pio2_1t = -1.07463465549719416346e-12L, /* -0x973dcb3b399d747f.0p-103 */
+ pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */
+ pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
++#elif LDBL_MANT_DIG == 113
++/* u ~< 0x1p45*pi/2 */
++#define SMALL(u) (((u.i.se & 0x7fffU)<<16 | u.i.top) < ((0x3fff + 45)<<16 | 0x921f))
++#define TOINT 0x1.8p112
++#define QUOBITS(x) ((uint32_t)(int64_t)x & 0x7fffffff)
++#define ROUND1 51
++#define ROUND2 119
++#define NX 5
++#define NY 3
++static const long double
++invpio2 = 6.3661977236758134307553505349005747e-01L, /* 0x145f306dc9c882a53f84eafa3ea6a.0p-113 */
++pio2_1 = 1.5707963267948966192292994253909555e+00L, /* 0x1921fb54442d18469800000000000.0p-112 */
++pio2_1t = 2.0222662487959507323996846200947577e-21L, /* 0x13198a2e03707344a4093822299f3.0p-181 */
++pio2_2 = 2.0222662487959507323994779168837751e-21L, /* 0x13198a2e03707344a400000000000.0p-181 */
++pio2_2t = 2.0670321098263988236496903051604844e-43L, /* 0x127044533e63a0105df531d89cd91.0p-254 */
++pio2_3 = 2.0670321098263988236499468110329591e-43L, /* 0x127044533e63a0105e00000000000.0p-254 */
++pio2_3t = -2.5650587247459238361625433492959285e-65L; /* -0x159c4ec64ddaeb5f78671cbfb2210.0p-327 */
++#endif
+
+ int __rem_pio2l(long double x, long double *y)
+ {
+- union IEEEl2bits u,u1;
++ union ldshape u,uz;
+ long double z,w,t,r,fn;
+- double tx[3],ty[2];
+- int e0,ex,i,j,nx,n;
+- int16_t expsign;
+-
+- u.e = x;
+- expsign = u.xbits.expsign;
+- ex = expsign & 0x7fff;
+- if (ex < BIAS + 25 || (ex == BIAS + 25 && u.bits.manh < 0xc90fdaa2)) {
+- union IEEEl2bits u2;
+- int ex1;
++ double tx[NX],ty[NY];
++ int ex,ey,n,i;
+
+- /* |x| ~< 2^25*(pi/2), medium size */
+- /* Use a specialized rint() to get fn. Assume round-to-nearest. */
+- fn = x*invpio2 + 0x1.8p63;
+- fn = fn - 0x1.8p63;
+-// FIXME
+-//#ifdef HAVE_EFFICIENT_IRINT
+-// n = irint(fn);
+-//#else
+- n = fn;
+-//#endif
++ u.f = x;
++ ex = u.i.se & 0x7fff;
++ if (SMALL(u)) {
++ /* rint(x/(pi/2)), Assume round-to-nearest. */
++ fn = x*invpio2 + TOINT - TOINT;
++ n = QUOBITS(fn);
+ r = x-fn*pio2_1;
+- w = fn*pio2_1t; /* 1st round good to 102 bit */
+- j = ex;
++ w = fn*pio2_1t; /* 1st round good to 102/180 bits (ld80/ld128) */
+ y[0] = r-w;
+- u2.e = y[0];
+- ex1 = u2.xbits.expsign & 0x7fff;
+- i = j-ex1;
+- if (i > 22) { /* 2nd iteration needed, good to 141 */
++ u.f = y[0];
++ ey = u.i.se & 0x7fff;
++ if (ex - ey > ROUND1) { /* 2nd iteration needed, good to 141/248 (ld80/ld128) */
+ t = r;
+ w = fn*pio2_2;
+ r = t-w;
+ w = fn*pio2_2t-((t-r)-w);
+ y[0] = r-w;
+- u2.e = y[0];
+- ex1 = u2.xbits.expsign & 0x7fff;
+- i = j-ex1;
+- if (i > 61) { /* 3rd iteration need, 180 bits acc */
+- t = r; /* will cover all possible cases */
++ u.f = y[0];
++ ey = u.i.se & 0x7fff;
++ if (ex - ey > ROUND2) { /* 3rd iteration, good to 180/316 bits */
++ t = r; /* will cover all possible cases (not verified for ld128) */
+ w = fn*pio2_3;
+ r = t-w;
+ w = fn*pio2_3t-((t-r)-w);
+@@ -102,23 +110,26 @@
+ y[0] = y[1] = x - x;
+ return 0;
+ }
+- /* set z = scalbn(|x|,ilogb(x)-23) */
+- u1.e = x;
+- e0 = ex - BIAS - 23; /* e0 = ilogb(|x|)-23; */
+- u1.xbits.expsign = ex - e0;
+- z = u1.e;
+- for (i=0; i<2; i++) {
++ /* set z = scalbn(|x|,-ilogb(x)+23) */
++ uz.f = x;
++ uz.i.se = 0x3fff + 23;
++ z = uz.f;
++ for (i=0; i < NX - 1; i++) {
+ tx[i] = (double)(int32_t)z;
+- z = (z-tx[i])*two24;
++ z = (z-tx[i])*0x1p24;
+ }
+- tx[2] = z;
+- nx = 3;
+- while (tx[nx-1] == 0.0)
+- nx--; /* skip zero term */
+- n = __rem_pio2_large(tx,ty,e0,nx,2);
+- r = (long double)ty[0] + ty[1];
+- w = ty[1] - (r - ty[0]);
+- if (expsign < 0) {
++ tx[i] = z;
++ while (tx[i] == 0)
++ i--;
++ n = __rem_pio2_large(tx, ty, ex-0x3fff-23, i+1, NY);
++ w = ty[1];
++ if (NY == 3)
++ w += ty[2];
++ r = ty[0] + w;
++ /* TODO: for ld128 this does not follow the recommendation of the
++ comments of __rem_pio2_large which seem wrong if |ty[0]| > |ty[1]+ty[2]| */
++ w -= r - ty[0];
++ if (u.i.se >> 15) {
+ y[0] = -r;
+ y[1] = -w;
+ return -n;
+diff -Nur musl-0.9.13/src/math/__signbitl.c musl-git/src/math/__signbitl.c
+--- musl-0.9.13/src/math/__signbitl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__signbitl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,11 +1,9 @@
+ #include "libm.h"
+
+-// FIXME: should be a macro
+ #if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ int __signbitl(long double x)
+ {
+ union ldshape u = {x};
+-
+- return u.bits.sign;
++ return u.i.se >> 15;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/__sinl.c musl-git/src/math/__sinl.c
+--- musl-0.9.13/src/math/__sinl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__sinl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,4 +1,5 @@
+ /* origin: FreeBSD /usr/src/lib/msun/ld80/k_sinl.c */
++/* origin: FreeBSD /usr/src/lib/msun/ld128/k_sinl.c */
+ /*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+@@ -13,7 +14,8 @@
+
+ #include "libm.h"
+
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
++#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
++#if LDBL_MANT_DIG == 64
+ /*
+ * ld80 version of __sin.c. See __sin.c for most comments.
+ */
+@@ -23,10 +25,8 @@
+ *
+ * See __cosl.c for more details about the polynomial.
+ */
+-
+ static const long double
+ S1 = -0.166666666666666666671L; /* -0xaaaaaaaaaaaaaaab.0p-66 */
+-
+ static const double
+ S2 = 0.0083333333333333332, /* 0x11111111111111.0p-59 */
+ S3 = -0.00019841269841269427, /* -0x1a01a01a019f81.0p-65 */
+@@ -35,6 +35,34 @@
+ S6 = 1.6059006598854211e-10, /* 0x161242b90243b5.0p-85 */
+ S7 = -7.6429779983024564e-13, /* -0x1ae42ebd1b2e00.0p-93 */
+ S8 = 2.6174587166648325e-15; /* 0x179372ea0b3f64.0p-101 */
++#define POLY(z) (S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*S8))))))
++#elif LDBL_MANT_DIG == 113
++/*
++ * ld128 version of __sin.c. See __sin.c for most comments.
++ */
++/*
++ * Domain [-0.7854, 0.7854], range ~[-1.53e-37, 1.659e-37]
++ * |sin(x)/x - s(x)| < 2**-122.1
++ *
++ * See __cosl.c for more details about the polynomial.
++ */
++static const long double
++S1 = -0.16666666666666666666666666666666666606732416116558L,
++S2 = 0.0083333333333333333333333333333331135404851288270047L,
++S3 = -0.00019841269841269841269841269839935785325638310428717L,
++S4 = 0.27557319223985890652557316053039946268333231205686e-5L,
++S5 = -0.25052108385441718775048214826384312253862930064745e-7L,
++S6 = 0.16059043836821614596571832194524392581082444805729e-9L,
++S7 = -0.76471637318198151807063387954939213287488216303768e-12L,
++S8 = 0.28114572543451292625024967174638477283187397621303e-14L;
++static const double
++S9 = -0.82206352458348947812512122163446202498005154296863e-17,
++S10 = 0.19572940011906109418080609928334380560135358385256e-19,
++S11 = -0.38680813379701966970673724299207480965452616911420e-22,
++S12 = 0.64038150078671872796678569586315881020659912139412e-25;
++#define POLY(z) (S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*(S8+ \
++ z*(S9+z*(S10+z*(S11+z*S12))))))))))
++#endif
+
+ long double __sinl(long double x, long double y, int iy)
+ {
+@@ -42,7 +70,7 @@
+
+ z = x*x;
+ v = z*x;
+- r = S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*S8)))));
++ r = POLY(z);
+ if (iy == 0)
+ return x+v*(S1+z*r);
+ return x-((z*(0.5*y-v*r)-y)-v*S1);
+diff -Nur musl-0.9.13/src/math/__tanl.c musl-git/src/math/__tanl.c
+--- musl-0.9.13/src/math/__tanl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/__tanl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,4 +1,5 @@
+ /* origin: FreeBSD /usr/src/lib/msun/ld80/k_tanl.c */
++/* origin: FreeBSD /usr/src/lib/msun/ld128/k_tanl.c */
+ /*
+ * ====================================================
+ * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+@@ -12,7 +13,8 @@
+
+ #include "libm.h"
+
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
++#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
++#if LDBL_MANT_DIG == 64
+ /*
+ * ld80 version of __tan.c. See __tan.c for most comments.
+ */
+@@ -22,14 +24,12 @@
+ *
+ * See __cosl.c for more details about the polynomial.
+ */
+-
+ static const long double
+ T3 = 0.333333333333333333180L, /* 0xaaaaaaaaaaaaaaa5.0p-65 */
+ T5 = 0.133333333333333372290L, /* 0x88888888888893c3.0p-66 */
+ T7 = 0.0539682539682504975744L, /* 0xdd0dd0dd0dc13ba2.0p-68 */
+ pio4 = 0.785398163397448309628L, /* 0xc90fdaa22168c235.0p-64 */
+ pio4lo = -1.25413940316708300586e-20L; /* -0xece675d1fc8f8cbb.0p-130 */
+-
+ static const double
+ T9 = 0.021869488536312216, /* 0x1664f4882cc1c2.0p-58 */
+ T11 = 0.0088632355256619590, /* 0x1226e355c17612.0p-59 */
+@@ -44,6 +44,59 @@
+ T29 = 0.0000078293456938132840, /* 0x106b59141a6cb3.0p-69 */
+ T31 = -0.0000032609076735050182, /* -0x1b5abef3ba4b59.0p-71 */
+ T33 = 0.0000023261313142559411; /* 0x13835436c0c87f.0p-71 */
++#define RPOLY(w) (T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 + \
++ w * (T25 + w * (T29 + w * T33)))))))
++#define VPOLY(w) (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 + \
++ w * (T27 + w * T31))))))
++#elif LDBL_MANT_DIG == 113
++/*
++ * ld128 version of __tan.c. See __tan.c for most comments.
++ */
++/*
++ * Domain [-0.67434, 0.67434], range ~[-3.37e-36, 1.982e-37]
++ * |tan(x)/x - t(x)| < 2**-117.8 (XXX should be ~1e-37)
++ *
++ * See __cosl.c for more details about the polynomial.
++ */
++static const long double
++T3 = 0x1.5555555555555555555555555553p-2L,
++T5 = 0x1.1111111111111111111111111eb5p-3L,
++T7 = 0x1.ba1ba1ba1ba1ba1ba1ba1b694cd6p-5L,
++T9 = 0x1.664f4882c10f9f32d6bbe09d8bcdp-6L,
++T11 = 0x1.226e355e6c23c8f5b4f5762322eep-7L,
++T13 = 0x1.d6d3d0e157ddfb5fed8e84e27b37p-9L,
++T15 = 0x1.7da36452b75e2b5fce9ee7c2c92ep-10L,
++T17 = 0x1.355824803674477dfcf726649efep-11L,
++T19 = 0x1.f57d7734d1656e0aceb716f614c2p-13L,
++T21 = 0x1.967e18afcb180ed942dfdc518d6cp-14L,
++T23 = 0x1.497d8eea21e95bc7e2aa79b9f2cdp-15L,
++T25 = 0x1.0b132d39f055c81be49eff7afd50p-16L,
++T27 = 0x1.b0f72d33eff7bfa2fbc1059d90b6p-18L,
++T29 = 0x1.5ef2daf21d1113df38d0fbc00267p-19L,
++T31 = 0x1.1c77d6eac0234988cdaa04c96626p-20L,
++T33 = 0x1.cd2a5a292b180e0bdd701057dfe3p-22L,
++T35 = 0x1.75c7357d0298c01a31d0a6f7d518p-23L,
++T37 = 0x1.2f3190f4718a9a520f98f50081fcp-24L,
++pio4 = 0x1.921fb54442d18469898cc51701b8p-1L,
++pio4lo = 0x1.cd129024e088a67cc74020bbea60p-116L;
++static const double
++T39 = 0.000000028443389121318352, /* 0x1e8a7592977938.0p-78 */
++T41 = 0.000000011981013102001973, /* 0x19baa1b1223219.0p-79 */
++T43 = 0.0000000038303578044958070, /* 0x107385dfb24529.0p-80 */
++T45 = 0.0000000034664378216909893, /* 0x1dc6c702a05262.0p-81 */
++T47 = -0.0000000015090641701997785, /* -0x19ecef3569ebb6.0p-82 */
++T49 = 0.0000000029449552300483952, /* 0x194c0668da786a.0p-81 */
++T51 = -0.0000000022006995706097711, /* -0x12e763b8845268.0p-81 */
++T53 = 0.0000000015468200913196612, /* 0x1a92fc98c29554.0p-82 */
++T55 = -0.00000000061311613386849674, /* -0x151106cbc779a9.0p-83 */
++T57 = 1.4912469681508012e-10; /* 0x147edbdba6f43a.0p-85 */
++#define RPOLY(w) (T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 + \
++ w * (T25 + w * (T29 + w * (T33 + w * (T37 + w * (T41 + \
++ w * (T45 + w * (T49 + w * (T53 + w * T57)))))))))))))
++#define VPOLY(w) (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 + \
++ w * (T27 + w * (T31 + w * (T35 + w * (T39 + w * (T43 + \
++ w * (T47 + w * (T51 + w * T55))))))))))))
++#endif
+
+ long double __tanl(long double x, long double y, int odd) {
+ long double z, r, v, w, s, a, t;
+@@ -62,10 +115,8 @@
+ }
+ z = x * x;
+ w = z * z;
+- r = T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 +
+- w * (T25 + w * (T29 + w * T33))))));
+- v = z * (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 +
+- w * (T27 + w * T31))))));
++ r = RPOLY(w);
++ v = z * VPOLY(w);
+ s = z * x;
+ r = y + z * (s * (r + v) + y) + T3 * s;
+ w = x + r;
+@@ -76,7 +127,6 @@
+ }
+ if (!odd)
+ return w;
+-
+ /*
+ * if allow error up to 2 ulp, simply return
+ * -1.0 / (x+r) here
+diff -Nur musl-0.9.13/src/math/acoshf.c musl-git/src/math/acoshf.c
+--- musl-0.9.13/src/math/acoshf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/acoshf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -3,14 +3,15 @@
+ /* acosh(x) = log(x + sqrt(x*x-1)) */
+ float acoshf(float x)
+ {
+- union {float f; int32_t i;} u = {.f = x};
++ union {float f; uint32_t i;} u = {x};
++ uint32_t a = u.i & 0x7fffffff;
+
+- if (u.i < 0x3f800000+(1<<23))
+- /* x < 2, invalid if x < 1 or nan */
++ if (a < 0x3f800000+(1<<23))
++ /* |x| < 2, invalid if x < 1 or nan */
+ /* up to 2ulp error in [1,1.125] */
+ return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1)));
+- if (u.i < 0x3f800000+(12<<23))
+- /* x < 0x1p12 */
++ if (a < 0x3f800000+(12<<23))
++ /* |x| < 0x1p12 */
+ return logf(2*x - 1/(x+sqrtf(x*x-1)));
+ /* x >= 0x1p12 */
+ return logf(x) + 0.693147180559945309417232121458176568f;
+diff -Nur musl-0.9.13/src/math/acoshl.c musl-git/src/math/acoshl.c
+--- musl-0.9.13/src/math/acoshl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/acoshl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,16 +9,14 @@
+ /* acosh(x) = log(x + sqrt(x*x-1)) */
+ long double acoshl(long double x)
+ {
+- union {
+- long double f;
+- struct{uint64_t m; int16_t se; uint16_t pad;} i;
+- } u = {.f = x};
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
+
+- if (u.i.se < 0x3fff + 1)
+- /* x < 2, invalid if x < 1 or nan */
++ if (e < 0x3fff + 1)
++ /* |x| < 2, invalid if x < 1 or nan */
+ return log1pl(x-1 + sqrtl((x-1)*(x-1)+2*(x-1)));
+- if (u.i.se < 0x3fff + 32)
+- /* x < 0x1p32 */
++ if (e < 0x3fff + 32)
++ /* |x| < 0x1p32 */
+ return logl(2*x - 1/(x+sqrtl(x*x-1)));
+ return logl(x) + 0.693147180559945309417232121458176568L;
+ }
+diff -Nur musl-0.9.13/src/math/acosl.c musl-git/src/math/acosl.c
+--- musl-0.9.13/src/math/acosl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/acosl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -23,46 +23,45 @@
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ #include "__invtrigl.h"
++#if LDBL_MANT_DIG == 64
++#define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
++#elif LDBL_MANT_DIG == 113
++#define CLEARBOTTOM(u) (u.i.lo = 0)
++#endif
+
+ long double acosl(long double x)
+ {
+- union IEEEl2bits u;
+- long double z, w, s, c, df;
+- int16_t expsign, expt;
+- u.e = x;
+- expsign = u.xbits.expsign;
+- expt = expsign & 0x7fff;
++ union ldshape u = {x};
++ long double z, s, c, f;
++ uint16_t e = u.i.se & 0x7fff;
++
+ /* |x| >= 1 or nan */
+- if (expt >= 0x3fff) {
+- if (expt == 0x3fff &&
+- ((u.bits.manh & ~LDBL_NBIT) | u.bits.manl) == 0) {
+- if (expsign > 0)
+- return 0; /* acos(1) = 0 */
+- return 2*pio2_hi + 0x1p-120f; /* acos(-1)= pi */
+- }
+- return 0/(x-x); /* acos(|x|>1) is NaN */
++ if (e >= 0x3fff) {
++ if (x == 1)
++ return 0;
++ if (x == -1)
++ return 2*pio2_hi + 0x1p-120f;
++ return 0/(x-x);
+ }
+ /* |x| < 0.5 */
+- if (expt < 0x3fff - 1) {
+- if (expt < 0x3fff - 65)
+- return pio2_hi + 0x1p-120f; /* x < 0x1p-65: acosl(x)=pi/2 */
+- return pio2_hi - (x - (pio2_lo - x * __invtrigl_R(x*x)));
++ if (e < 0x3fff - 1) {
++ if (e < 0x3fff - LDBL_MANT_DIG - 1)
++ return pio2_hi + 0x1p-120f;
++ return pio2_hi - (__invtrigl_R(x*x)*x - pio2_lo + x);
+ }
+ /* x < -0.5 */
+- if (expsign < 0) {
+- z = (1.0 + x) * 0.5;
++ if (u.i.se >> 15) {
++ z = (1 + x)*0.5;
+ s = sqrtl(z);
+- w = __invtrigl_R(z) * s - pio2_lo;
+- return 2*(pio2_hi - (s + w));
++ return 2*(pio2_hi - (__invtrigl_R(z)*s - pio2_lo + s));
+ }
+ /* x > 0.5 */
+- z = (1.0 - x) * 0.5;
++ z = (1 - x)*0.5;
+ s = sqrtl(z);
+- u.e = s;
+- u.bits.manl = 0;
+- df = u.e;
+- c = (z - df * df) / (s + df);
+- w = __invtrigl_R(z) * s + c;
+- return 2*(df + w);
++ u.f = s;
++ CLEARBOTTOM(u);
++ f = u.f;
++ c = (z - f*f)/(s + f);
++ return 2*(__invtrigl_R(z)*s + c + f);
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/asinhl.c musl-git/src/math/asinhl.c
+--- musl-0.9.13/src/math/asinhl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/asinhl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,10 +9,7 @@
+ /* asinh(x) = sign(x)*log(|x|+sqrt(x*x+1)) ~= x - x^3/6 + o(x^5) */
+ long double asinhl(long double x)
+ {
+- union {
+- long double f;
+- struct{uint64_t m; uint16_t se; uint16_t pad;} i;
+- } u = {.f = x};
++ union ldshape u = {x};
+ unsigned e = u.i.se & 0x7fff;
+ unsigned s = u.i.se >> 15;
+
+diff -Nur musl-0.9.13/src/math/asinl.c musl-git/src/math/asinl.c
+--- musl-0.9.13/src/math/asinl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/asinl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -23,27 +23,29 @@
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ #include "__invtrigl.h"
+-/* 0.95 */
+-#define THRESH ((0xe666666666666666ULL>>(64-(LDBL_MANH_SIZE-1)))|LDBL_NBIT)
++#if LDBL_MANT_DIG == 64
++#define CLOSETO1(u) (u.i.m>>56 >= 0xf7)
++#define CLEARBOTTOM(u) (u.i.m &= -1ULL << 32)
++#elif LDBL_MANT_DIG == 113
++#define CLOSETO1(u) (u.i.top >= 0xee00)
++#define CLEARBOTTOM(u) (u.i.lo = 0)
++#endif
+
+ long double asinl(long double x)
+ {
+- union IEEEl2bits u;
+- long double z,r,s;
+- uint16_t expsign, expt;
++ union ldshape u = {x};
++ long double z, r, s;
++ uint16_t e = u.i.se & 0x7fff;
++ int sign = u.i.se >> 15;
+
+- u.e = x;
+- expsign = u.xbits.expsign;
+- expt = expsign & 0x7fff;
+- if (expt >= 0x3fff) { /* |x| >= 1 or nan */
+- if (expt == 0x3fff &&
+- ((u.bits.manh&~LDBL_NBIT)|u.bits.manl) == 0)
+- /* asin(+-1)=+-pi/2 with inexact */
++ if (e >= 0x3fff) { /* |x| >= 1 or nan */
++ /* asin(+-1)=+-pi/2 with inexact */
++ if (x == 1 || x == -1)
+ return x*pio2_hi + 0x1p-120f;
+ return 0/(x-x);
+ }
+- if (expt < 0x3fff - 1) { /* |x| < 0.5 */
+- if (expt < 0x3fff - 32) { /* |x|<0x1p-32, asinl(x)=x */
++ if (e < 0x3fff - 1) { /* |x| < 0.5 */
++ if (e < 0x3fff - (LDBL_MANT_DIG+1)/2) {
+ /* return x with inexact if x!=0 */
+ FORCE_EVAL(x + 0x1p120f);
+ return x;
+@@ -54,18 +56,16 @@
+ z = (1.0 - fabsl(x))*0.5;
+ s = sqrtl(z);
+ r = __invtrigl_R(z);
+- if (u.bits.manh >= THRESH) { /* if |x| is close to 1 */
++ if (CLOSETO1(u)) {
+ x = pio2_hi - (2*(s+s*r)-pio2_lo);
+ } else {
+ long double f, c;
+- u.e = s;
+- u.bits.manl = 0;
+- f = u.e;
+- c = (z-f*f)/(s+f);
++ u.f = s;
++ CLEARBOTTOM(u);
++ f = u.f;
++ c = (z - f*f)/(s + f);
+ x = 0.5*pio2_hi-(2*s*r - (pio2_lo-2*c) - (0.5*pio2_hi-2*f));
+ }
+- if (expsign>>15)
+- return -x;
+- return x;
++ return sign ? -x : x;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/atan2l.c musl-git/src/math/atan2l.c
+--- musl-0.9.13/src/math/atan2l.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/atan2l.c 2013-09-16 20:31:39.000000000 +0200
+@@ -27,56 +27,50 @@
+
+ long double atan2l(long double y, long double x)
+ {
+- union IEEEl2bits ux, uy;
++ union ldshape ux, uy;
+ long double z;
+- int m;
+- uint16_t exptx, expsignx, expty, expsigny;
++ int m, ex, ey;
+
+ if (isnan(x) || isnan(y))
+ return x+y;
+ if (x == 1)
+ return atanl(y);
+- uy.e = y;
+- expsigny = uy.xbits.expsign;
+- expty = expsigny & 0x7fff;
+- ux.e = x;
+- expsignx = ux.xbits.expsign;
+- exptx = expsignx & 0x7fff;
+- m = ((expsigny>>15)&1) | ((expsignx>>14)&2); /* 2*sign(x)+sign(y) */
+-
++ ux.f = x;
++ uy.f = y;
++ ex = ux.i.se & 0x7fff;
++ ey = uy.i.se & 0x7fff;
++ m = 2*(ux.i.se>>15) | uy.i.se>>15;
+ if (y == 0) {
+ switch(m) {
+ case 0:
+ case 1: return y; /* atan(+-0,+anything)=+-0 */
+- case 2: return 2*pio2_hi+0x1p-120f; /* atan(+0,-anything) = pi */
+- case 3: return -2*pio2_hi-0x1p-120f; /* atan(-0,-anything) =-pi */
++ case 2: return 2*pio2_hi; /* atan(+0,-anything) = pi */
++ case 3: return -2*pio2_hi; /* atan(-0,-anything) =-pi */
+ }
+ }
+ if (x == 0)
+- return m&1 ? -pio2_hi-0x1p-120f : pio2_hi+0x1p-120f;
+- /* when x is INF */
+- if (exptx == 0x7fff) {
+- if (expty == 0x7fff) {
++ return m&1 ? -pio2_hi : pio2_hi;
++ if (ex == 0x7fff) {
++ if (ey == 0x7fff) {
+ switch(m) {
+- case 0: return pio2_hi*0.5+0x1p-120f; /* atan(+INF,+INF) */
+- case 1: return -pio2_hi*0.5-0x1p-120f; /* atan(-INF,+INF) */
+- case 2: return 1.5*pio2_hi+0x1p-120f; /* atan(+INF,-INF) */
+- case 3: return -1.5*pio2_hi-0x1p-120f; /* atan(-INF,-INF) */
++ case 0: return pio2_hi/2; /* atan(+INF,+INF) */
++ case 1: return -pio2_hi/2; /* atan(-INF,+INF) */
++ case 2: return 1.5*pio2_hi; /* atan(+INF,-INF) */
++ case 3: return -1.5*pio2_hi; /* atan(-INF,-INF) */
+ }
+ } else {
+ switch(m) {
+ case 0: return 0.0; /* atan(+...,+INF) */
+ case 1: return -0.0; /* atan(-...,+INF) */
+- case 2: return 2*pio2_hi+0x1p-120f; /* atan(+...,-INF) */
+- case 3: return -2*pio2_hi-0x1p-120f; /* atan(-...,-INF) */
++ case 2: return 2*pio2_hi; /* atan(+...,-INF) */
++ case 3: return -2*pio2_hi; /* atan(-...,-INF) */
+ }
+ }
+ }
+- /* when y is INF */
+- if (exptx+120 < expty || expty == 0x7fff)
+- return m&1 ? -pio2_hi-0x1p-120f : pio2_hi+0x1p-120f;
+-
+- if ((m&2) && expty+120 < exptx) /* |y/x| tiny, x<0 */
++ if (ex+120 < ey || ey == 0x7fff)
++ return m&1 ? -pio2_hi : pio2_hi;
++ /* z = atan(|y/x|) without spurious underflow */
++ if ((m&2) && ey+120 < ex) /* |y/x| < 0x1p-120, x<0 */
+ z = 0.0;
+ else
+ z = atanl(fabsl(y/x));
+diff -Nur musl-0.9.13/src/math/atanh.c musl-git/src/math/atanh.c
+--- musl-0.9.13/src/math/atanh.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/atanh.c 2013-09-16 20:31:39.000000000 +0200
+@@ -6,16 +6,24 @@
+ union {double f; uint64_t i;} u = {.f = x};
+ unsigned e = u.i >> 52 & 0x7ff;
+ unsigned s = u.i >> 63;
++ double_t y;
+
+ /* |x| */
+ u.i &= (uint64_t)-1/2;
+- x = u.f;
++ y = u.f;
+
+ if (e < 0x3ff - 1) {
+- /* |x| < 0.5, up to 1.7ulp error */
+- x = 0.5*log1p(2*x + 2*x*x/(1-x));
++ if (e < 0x3ff - 32) {
++ /* handle underflow */
++ if (e == 0)
++ FORCE_EVAL((float)y);
++ } else {
++ /* |x| < 0.5, up to 1.7ulp error */
++ y = 0.5*log1p(2*y + 2*y*y/(1-y));
++ }
+ } else {
+- x = 0.5*log1p(2*x/(1-x));
++ /* avoid overflow */
++ y = 0.5*log1p(2*(y/(1-y)));
+ }
+- return s ? -x : x;
++ return s ? -y : y;
+ }
+diff -Nur musl-0.9.13/src/math/atanhf.c musl-git/src/math/atanhf.c
+--- musl-0.9.13/src/math/atanhf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/atanhf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -5,16 +5,24 @@
+ {
+ union {float f; uint32_t i;} u = {.f = x};
+ unsigned s = u.i >> 31;
++ float_t y;
+
+ /* |x| */
+ u.i &= 0x7fffffff;
+- x = u.f;
++ y = u.f;
+
+ if (u.i < 0x3f800000 - (1<<23)) {
+- /* |x| < 0.5, up to 1.7ulp error */
+- x = 0.5f*log1pf(2*x + 2*x*x/(1-x));
++ if (u.i < 0x3f800000 - (32<<23)) {
++ /* handle underflow */
++ if (u.i < (1<<23))
++ FORCE_EVAL((float)(y*y));
++ } else {
++ /* |x| < 0.5, up to 1.7ulp error */
++ y = 0.5f*log1pf(2*y + 2*y*y/(1-y));
++ }
+ } else {
+- x = 0.5f*log1pf(2*x/(1-x));
++ /* avoid overflow */
++ y = 0.5f*log1pf(2*(y/(1-y)));
+ }
+- return s ? -x : x;
++ return s ? -y : y;
+ }
+diff -Nur musl-0.9.13/src/math/atanhl.c musl-git/src/math/atanhl.c
+--- musl-0.9.13/src/math/atanhl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/atanhl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,10 +9,7 @@
+ /* atanh(x) = log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2 ~= x + x^3/3 + o(x^5) */
+ long double atanhl(long double x)
+ {
+- union {
+- long double f;
+- struct{uint64_t m; uint16_t se; uint16_t pad;} i;
+- } u = {.f = x};
++ union ldshape u = {x};
+ unsigned e = u.i.se & 0x7fff;
+ unsigned s = u.i.se >> 15;
+
+@@ -20,11 +17,18 @@
+ u.i.se = e;
+ x = u.f;
+
+- if (e < 0x3fff - 1) {
+- /* |x| < 0.5, up to 1.7ulp error */
+- x = 0.5*log1pl(2*x + 2*x*x/(1-x));
++ if (e < 0x3ff - 1) {
++ if (e < 0x3ff - LDBL_MANT_DIG/2) {
++ /* handle underflow */
++ if (e == 0)
++ FORCE_EVAL((float)x);
++ } else {
++ /* |x| < 0.5, up to 1.7ulp error */
++ x = 0.5*log1pl(2*x + 2*x*x/(1-x));
++ }
+ } else {
+- x = 0.5*log1pl(2*x/(1-x));
++ /* avoid overflow */
++ x = 0.5*log1pl(2*(x/(1-x)));
+ }
+ return s ? -x : x;
+ }
+diff -Nur musl-0.9.13/src/math/atanl.c musl-git/src/math/atanl.c
+--- musl-0.9.13/src/math/atanl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/atanl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -23,6 +23,9 @@
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+
++#if LDBL_MANT_DIG == 64
++#define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | (u.i.m>>55 & 0xff))
++
+ static const long double atanhi[] = {
+ 4.63647609000806116202e-01L,
+ 7.85398163397448309628e-01L,
+@@ -64,32 +67,85 @@
+ return aT[1] + x * (aT[3] + x * (aT[5] + x * (aT[7] +
+ x * (aT[9] + x * aT[11]))));
+ }
++#elif LDBL_MANT_DIG == 113
++#define EXPMAN(u) ((u.i.se & 0x7fff)<<8 | u.i.top>>8)
++
++const long double atanhi[] = {
++ 4.63647609000806116214256231461214397e-01L,
++ 7.85398163397448309615660845819875699e-01L,
++ 9.82793723247329067985710611014666038e-01L,
++ 1.57079632679489661923132169163975140e+00L,
++};
++
++const long double atanlo[] = {
++ 4.89509642257333492668618435220297706e-36L,
++ 2.16795253253094525619926100651083806e-35L,
++ -2.31288434538183565909319952098066272e-35L,
++ 4.33590506506189051239852201302167613e-35L,
++};
++
++const long double aT[] = {
++ 3.33333333333333333333333333333333125e-01L,
++ -1.99999999999999999999999999999180430e-01L,
++ 1.42857142857142857142857142125269827e-01L,
++ -1.11111111111111111111110834490810169e-01L,
++ 9.09090909090909090908522355708623681e-02L,
++ -7.69230769230769230696553844935357021e-02L,
++ 6.66666666666666660390096773046256096e-02L,
++ -5.88235294117646671706582985209643694e-02L,
++ 5.26315789473666478515847092020327506e-02L,
++ -4.76190476189855517021024424991436144e-02L,
++ 4.34782608678695085948531993458097026e-02L,
++ -3.99999999632663469330634215991142368e-02L,
++ 3.70370363987423702891250829918659723e-02L,
++ -3.44827496515048090726669907612335954e-02L,
++ 3.22579620681420149871973710852268528e-02L,
++ -3.03020767654269261041647570626778067e-02L,
++ 2.85641979882534783223403715930946138e-02L,
++ -2.69824879726738568189929461383741323e-02L,
++ 2.54194698498808542954187110873675769e-02L,
++ -2.35083879708189059926183138130183215e-02L,
++ 2.04832358998165364349957325067131428e-02L,
++ -1.54489555488544397858507248612362957e-02L,
++ 8.64492360989278761493037861575248038e-03L,
++ -2.58521121597609872727919154569765469e-03L,
++};
++
++static long double T_even(long double x)
++{
++ return (aT[0] + x * (aT[2] + x * (aT[4] + x * (aT[6] + x * (aT[8] +
++ x * (aT[10] + x * (aT[12] + x * (aT[14] + x * (aT[16] +
++ x * (aT[18] + x * (aT[20] + x * aT[22])))))))))));
++}
++
++static long double T_odd(long double x)
++{
++ return (aT[1] + x * (aT[3] + x * (aT[5] + x * (aT[7] + x * (aT[9] +
++ x * (aT[11] + x * (aT[13] + x * (aT[15] + x * (aT[17] +
++ x * (aT[19] + x * (aT[21] + x * aT[23])))))))))));
++}
++#endif
+
+ long double atanl(long double x)
+ {
+- union IEEEl2bits u;
+- long double w,s1,s2,z;
++ union ldshape u = {x};
++ long double w, s1, s2, z;
+ int id;
+- uint16_t expsign, expt;
+- uint32_t expman;
++ unsigned e = u.i.se & 0x7fff;
++ unsigned sign = u.i.se >> 15;
++ unsigned expman;
+
+- u.e = x;
+- expsign = u.xbits.expsign;
+- expt = expsign & 0x7fff;
+- if (expt >= 0x3fff + 65) { /* if |x| is large, atan(x)~=pi/2 */
+- if (expt == 0x7fff &&
+- ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)!=0) /* NaN */
+- return x+x;
+- z = atanhi[3] + 0x1p-120f;
+- return expsign>>15 ? -z : z;
++ if (e >= 0x3fff + LDBL_MANT_DIG + 1) { /* if |x| is large, atan(x)~=pi/2 */
++ if (isnan(x))
++ return x;
++ return sign ? -atanhi[3] : atanhi[3];
+ }
+ /* Extract the exponent and the first few bits of the mantissa. */
+- /* XXX There should be a more convenient way to do this. */
+- expman = (expt << 8) | ((u.bits.manh >> (LDBL_MANH_SIZE - 9)) & 0xff);
++ expman = EXPMAN(u);
+ if (expman < ((0x3fff - 2) << 8) + 0xc0) { /* |x| < 0.4375 */
+- if (expt < 0x3fff - 32) { /* if |x| is small, atanl(x)~=x */
++ if (e < 0x3fff - (LDBL_MANT_DIG+1)/2) { /* if |x| is small, atanl(x)~=x */
+ /* raise underflow if subnormal */
+- if (expt == 0)
++ if (e == 0)
+ FORCE_EVAL((float)x);
+ return x;
+ }
+@@ -108,7 +164,7 @@
+ if (expman < ((0x3fff + 1) << 8) + 0x38) { /* |x| < 2.4375 */
+ id = 2;
+ x = (x-1.5)/(1.0+1.5*x);
+- } else { /* 2.4375 <= |x| < 2^ATAN_CONST */
++ } else { /* 2.4375 <= |x| */
+ id = 3;
+ x = -1.0/x;
+ }
+@@ -123,6 +179,6 @@
+ if (id < 0)
+ return x - x*(s1+s2);
+ z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
+- return expsign>>15 ? -z : z;
++ return sign ? -z : z;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/cbrt.c musl-git/src/math/cbrt.c
+--- musl-0.9.13/src/math/cbrt.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/cbrt.c 2013-09-16 20:31:39.000000000 +0200
+@@ -15,7 +15,8 @@
+ * Return cube root of x
+ */
+
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ static const uint32_t
+ B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
+@@ -31,15 +32,10 @@
+
+ double cbrt(double x)
+ {
+- int32_t hx;
+- union dshape u;
+- double r,s,t=0.0,w;
+- uint32_t sign;
+- uint32_t high,low;
+-
+- EXTRACT_WORDS(hx, low, x);
+- sign = hx & 0x80000000;
+- hx ^= sign;
++ union {double f; uint64_t i;} u = {x};
++ double_t r,s,t,w;
++ uint32_t hx = u.i>>32 & 0x7fffffff;
++
+ if (hx >= 0x7ff00000) /* cbrt(NaN,INF) is itself */
+ return x+x;
+
+@@ -59,14 +55,16 @@
+ * division rounds towards minus infinity; this is also efficient.
+ */
+ if (hx < 0x00100000) { /* zero or subnormal? */
+- if ((hx|low) == 0)
++ u.f = x*0x1p54;
++ hx = u.i>>32 & 0x7fffffff;
++ if (hx == 0)
+ return x; /* cbrt(0) is itself */
+- SET_HIGH_WORD(t, 0x43500000); /* set t = 2**54 */
+- t *= x;
+- GET_HIGH_WORD(high, t);
+- INSERT_WORDS(t, sign|((high&0x7fffffff)/3+B2), 0);
++ hx = hx/3 + B2;
+ } else
+- INSERT_WORDS(t, sign|(hx/3+B1), 0);
++ hx = hx/3 + B1;
++ u.i &= 1ULL<<63;
++ u.i |= (uint64_t)hx << 32;
++ t = u.f;
+
+ /*
+ * New cbrt to 23 bits:
+@@ -76,7 +74,7 @@
+ * has produced t such than |t/cbrt(x) - 1| ~< 1/32, and cubing this
+ * gives us bounds for r = t**3/x.
+ *
+- * Try to optimize for parallel evaluation as in k_tanf.c.
++ * Try to optimize for parallel evaluation as in __tanf.c.
+ */
+ r = (t*t)*(t/x);
+ t = t*((P0+r*(P1+r*P2))+((r*r)*r)*(P3+r*P4));
+@@ -91,9 +89,9 @@
+ * 0.667; the error in the rounded t can be up to about 3 23-bit ulps
+ * before the final error is larger than 0.667 ulps.
+ */
+- u.value = t;
+- u.bits = (u.bits + 0x80000000) & 0xffffffffc0000000ULL;
+- t = u.value;
++ u.f = t;
++ u.i = (u.i + 0x80000000) & 0xffffffffc0000000ULL;
++ t = u.f;
+
+ /* one step Newton iteration to 53 bits with error < 0.667 ulps */
+ s = t*t; /* t*t is exact */
+diff -Nur musl-0.9.13/src/math/cbrtf.c musl-git/src/math/cbrtf.c
+--- musl-0.9.13/src/math/cbrtf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/cbrtf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -17,7 +17,8 @@
+ * Return cube root of x
+ */
+
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ static const unsigned
+ B1 = 709958130, /* B1 = (127-127.0/3-0.03306235651)*2**23 */
+@@ -25,15 +26,10 @@
+
+ float cbrtf(float x)
+ {
+- double r,T;
+- float t;
+- int32_t hx;
+- uint32_t sign;
+- uint32_t high;
+-
+- GET_FLOAT_WORD(hx, x);
+- sign = hx & 0x80000000;
+- hx ^= sign;
++ double_t r,T;
++ union {float f; uint32_t i;} u = {x};
++ uint32_t hx = u.i & 0x7fffffff;
++
+ if (hx >= 0x7f800000) /* cbrt(NaN,INF) is itself */
+ return x + x;
+
+@@ -41,28 +37,29 @@
+ if (hx < 0x00800000) { /* zero or subnormal? */
+ if (hx == 0)
+ return x; /* cbrt(+-0) is itself */
+- SET_FLOAT_WORD(t, 0x4b800000); /* set t = 2**24 */
+- t *= x;
+- GET_FLOAT_WORD(high, t);
+- SET_FLOAT_WORD(t, sign|((high&0x7fffffff)/3+B2));
++ u.f = x*0x1p24f;
++ hx = u.i & 0x7fffffff;
++ hx = hx/3 + B2;
+ } else
+- SET_FLOAT_WORD(t, sign|(hx/3+B1));
++ hx = hx/3 + B1;
++ u.i &= 0x80000000;
++ u.i |= hx;
+
+ /*
+ * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In
+ * double precision so that its terms can be arranged for efficiency
+ * without causing overflow or underflow.
+ */
+- T = t;
++ T = u.f;
+ r = T*T*T;
+- T = T*((double)x+x+r)/(x+r+r);
++ T = T*((double_t)x+x+r)/(x+r+r);
+
+ /*
+ * Second step Newton iteration to 47 bits. In double precision for
+ * efficiency and accuracy.
+ */
+ r = T*T*T;
+- T = T*((double)x+x+r)/(x+r+r);
++ T = T*((double_t)x+x+r)/(x+r+r);
+
+ /* rounding to 24 bits is perfect in round-to-nearest mode */
+ return T;
+diff -Nur musl-0.9.13/src/math/cbrtl.c musl-git/src/math/cbrtl.c
+--- musl-0.9.13/src/math/cbrtl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/cbrtl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -23,58 +23,50 @@
+ return cbrt(x);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#define BIAS (LDBL_MAX_EXP - 1)
+ static const unsigned B1 = 709958130; /* B1 = (127-127.0/3-0.03306235651)*2**23 */
+
+ long double cbrtl(long double x)
+ {
+- union IEEEl2bits u, v;
++ union ldshape u = {x}, v;
++ union {float f; uint32_t i;} uft;
+ long double r, s, t, w;
+- double dr, dt, dx;
+- float ft, fx;
+- uint32_t hx;
+- uint16_t expsign;
+- int k;
+-
+- u.e = x;
+- expsign = u.xbits.expsign;
+- k = expsign & 0x7fff;
++ double_t dr, dt, dx;
++ float_t ft;
++ int e = u.i.se & 0x7fff;
++ int sign = u.i.se & 0x8000;
+
+ /*
+ * If x = +-Inf, then cbrt(x) = +-Inf.
+ * If x = NaN, then cbrt(x) = NaN.
+ */
+- if (k == BIAS + LDBL_MAX_EXP)
++ if (e == 0x7fff)
+ return x + x;
+-
+- if (k == 0) {
++ if (e == 0) {
++ /* Adjust subnormal numbers. */
++ u.f *= 0x1p120;
++ e = u.i.se & 0x7fff;
+ /* If x = +-0, then cbrt(x) = +-0. */
+- if ((u.bits.manh | u.bits.manl) == 0)
++ if (e == 0)
+ return x;
+- /* Adjust subnormal numbers. */
+- u.e *= 0x1.0p514;
+- k = u.bits.exp;
+- k -= BIAS + 514;
+- } else
+- k -= BIAS;
+- u.xbits.expsign = BIAS;
+- v.e = 1;
+-
+- x = u.e;
+- switch (k % 3) {
++ e -= 120;
++ }
++ e -= 0x3fff;
++ u.i.se = 0x3fff;
++ x = u.f;
++ switch (e % 3) {
+ case 1:
+ case -2:
+- x = 2*x;
+- k--;
++ x *= 2;
++ e--;
+ break;
+ case 2:
+ case -1:
+- x = 4*x;
+- k -= 2;
++ x *= 4;
++ e -= 2;
+ break;
+ }
+- v.xbits.expsign = (expsign & 0x8000) | (BIAS + k / 3);
++ v.f = 1.0;
++ v.i.se = sign | (0x3fff + e/3);
+
+ /*
+ * The following is the guts of s_cbrtf, with the handling of
+@@ -83,9 +75,9 @@
+ */
+
+ /* ~5-bit estimate: */
+- fx = x;
+- GET_FLOAT_WORD(hx, fx);
+- SET_FLOAT_WORD(ft, ((hx & 0x7fffffff) / 3 + B1));
++ uft.f = x;
++ uft.i = (uft.i & 0x7fffffff)/3 + B1;
++ ft = uft.f;
+
+ /* ~16-bit estimate: */
+ dx = x;
+@@ -126,7 +118,7 @@
+ r = (r-t)/(w+r); /* r-t is exact; w+r ~= 3*t */
+ t = t+t*r; /* error <= 0.5 + 0.5/3 + epsilon */
+
+- t *= v.e;
++ t *= v.f;
+ return t;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/ceil.c musl-git/src/math/ceil.c
+--- musl-0.9.13/src/math/ceil.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/ceil.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,82 +1,24 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_ceil.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * ceil(x)
+- * Return x rounded toward -inf to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to ceil(x).
+- */
+-
+ #include "libm.h"
+
+-static const double huge = 1.0e300;
+-
+ double ceil(double x)
+ {
+- int32_t i0,i1,j0;
+- uint32_t i,j;
++ union {double f; uint64_t i;} u = {x};
++ int e = u.i >> 52 & 0x7ff;
++ double_t y;
+
+- EXTRACT_WORDS(i0, i1, x);
+- // FIXME signed shift
+- j0 = ((i0>>20)&0x7ff) - 0x3ff;
+- if (j0 < 20) {
+- if (j0 < 0) {
+- /* raise inexact if x != 0 */
+- if (huge+x > 0.0) {
+- if (i0 < 0) {
+- i0 = 0x80000000;
+- i1=0;
+- } else if ((i0|i1) != 0) {
+- i0=0x3ff00000;
+- i1=0;
+- }
+- }
+- } else {
+- i = 0x000fffff>>j0;
+- if (((i0&i)|i1) == 0) /* x is integral */
+- return x;
+- /* raise inexact flag */
+- if (huge+x > 0.0) {
+- if (i0 > 0)
+- i0 += 0x00100000>>j0;
+- i0 &= ~i;
+- i1 = 0;
+- }
+- }
+- } else if (j0 > 51) {
+- if (j0 == 0x400) /* inf or NaN */
+- return x+x;
+- return x; /* x is integral */
+- } else {
+- i = (uint32_t)0xffffffff>>(j0-20);
+- if ((i1&i) == 0)
+- return x; /* x is integral */
+- /* raise inexact flag */
+- if (huge+x > 0.0) {
+- if (i0 > 0) {
+- if (j0 == 20)
+- i0 += 1;
+- else {
+- j = i1 + (1<<(52-j0));
+- if (j < i1) /* got a carry */
+- i0 += 1;
+- i1 = j;
+- }
+- }
+- i1 &= ~i;
+- }
++ if (e >= 0x3ff+52 || x == 0)
++ return x;
++ /* y = int(x) - x, where int(x) is an integer neighbor of x */
++ if (u.i >> 63)
++ y = (double)(x - 0x1p52) + 0x1p52 - x;
++ else
++ y = (double)(x + 0x1p52) - 0x1p52 - x;
++ /* special case because of non-nearest rounding modes */
++ if (e <= 0x3ff-1) {
++ FORCE_EVAL(y);
++ return u.i >> 63 ? -0.0 : 1;
+ }
+- INSERT_WORDS(x, i0, i1);
+- return x;
++ if (y < 0)
++ return x + y + 1;
++ return x + y;
+ }
+diff -Nur musl-0.9.13/src/math/ceilf.c musl-git/src/math/ceilf.c
+--- musl-0.9.13/src/math/ceilf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/ceilf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,54 +1,27 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_ceilf.c */
+-/*
+- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+- */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-
+ #include "libm.h"
+
+-static const float huge = 1.0e30;
+-
+ float ceilf(float x)
+ {
+- int32_t i0,j0;
+- uint32_t i;
++ union {float f; uint32_t i;} u = {x};
++ int e = (int)(u.i >> 23 & 0xff) - 0x7f;
++ uint32_t m;
+
+- GET_FLOAT_WORD(i0, x);
+- j0 = ((i0>>23)&0xff) - 0x7f;
+- if (j0 < 23) {
+- if (j0 < 0) {
+- /* raise inexact if x != 0 */
+- if (huge+x > 0.0f) {
+- if (i0 < 0)
+- i0 = 0x80000000;
+- else if(i0 != 0)
+- i0 = 0x3f800000;
+- }
+- } else {
+- i = 0x007fffff>>j0;
+- if ((i0&i) == 0)
+- return x; /* x is integral */
+- /* raise inexact flag */
+- if (huge+x > 0.0f) {
+- if (i0 > 0)
+- i0 += 0x00800000>>j0;
+- i0 &= ~i;
+- }
+- }
++ if (e >= 23)
++ return x;
++ if (e >= 0) {
++ m = 0x007fffff >> e;
++ if ((u.i & m) == 0)
++ return x;
++ FORCE_EVAL(x + 0x1p120f);
++ if (u.i >> 31 == 0)
++ u.i += m;
++ u.i &= ~m;
+ } else {
+- if (j0 == 0x80) /* inf or NaN */
+- return x+x;
+- return x; /* x is integral */
++ FORCE_EVAL(x + 0x1p120f);
++ if (u.i >> 31)
++ u.f = -0.0;
++ else if (u.i << 1)
++ u.f = 1.0;
+ }
+- SET_FLOAT_WORD(x, i0);
+- return x;
++ return u.f;
+ }
+diff -Nur musl-0.9.13/src/math/ceill.c musl-git/src/math/ceill.c
+--- musl-0.9.13/src/math/ceill.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/ceill.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,23 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_ceill.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * ceill(x)
+- * Return x rounded toward -inf to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to ceill(x).
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -26,77 +6,31 @@
+ return ceil(x);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#ifdef LDBL_IMPLICIT_NBIT
+-#define MANH_SIZE (LDBL_MANH_SIZE + 1)
+-#define INC_MANH(u, c) do { \
+- uint64_t o = u.bits.manh; \
+- u.bits.manh += (c); \
+- if (u.bits.manh < o) \
+- u.bits.exp++; \
+-} while (0)
+-#else
+-#define MANH_SIZE LDBL_MANH_SIZE
+-#define INC_MANH(u, c) do { \
+- uint64_t o = u.bits.manh; \
+- u.bits.manh += (c); \
+- if (u.bits.manh < o) { \
+- u.bits.exp++; \
+- u.bits.manh |= 1llu << (LDBL_MANH_SIZE - 1); \
+- } \
+-} while (0)
++#if LDBL_MANT_DIG == 64
++#define TOINT 0x1p63
++#elif LDBL_MANT_DIG == 113
++#define TOINT 0x1p112
+ #endif
+-
+-static const long double huge = 1.0e300;
+-
+ long double ceill(long double x)
+ {
+- union IEEEl2bits u = { .e = x };
+- int e = u.bits.exp - LDBL_MAX_EXP + 1;
+-
+- if (e < MANH_SIZE - 1) {
+- if (e < 0) {
+- /* raise inexact if x != 0 */
+- if (huge + x > 0.0)
+- if (u.bits.exp > 0 ||
+- (u.bits.manh | u.bits.manl) != 0)
+- u.e = u.bits.sign ? -0.0 : 1.0;
+- } else {
+- uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
+- if (((u.bits.manh & m) | u.bits.manl) == 0)
+- return x; /* x is integral */
+- if (!u.bits.sign) {
+-#ifdef LDBL_IMPLICIT_NBIT
+- if (e == 0)
+- u.bits.exp++;
+- else
+-#endif
+- INC_MANH(u, 1llu << (MANH_SIZE - e - 1));
+- }
+- /* raise inexact flag */
+- if (huge + x > 0.0) {
+- u.bits.manh &= ~m;
+- u.bits.manl = 0;
+- }
+- }
+- } else if (e < LDBL_MANT_DIG - 1) {
+- uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
+- if ((u.bits.manl & m) == 0)
+- return x; /* x is integral */
+- if (!u.bits.sign) {
+- if (e == MANH_SIZE - 1)
+- INC_MANH(u, 1);
+- else {
+- uint64_t o = u.bits.manl;
+- u.bits.manl += 1llu << (LDBL_MANT_DIG - e - 1);
+- if (u.bits.manl < o) /* got a carry */
+- INC_MANH(u, 1);
+- }
+- }
+- /* raise inexact flag */
+- if (huge + x > 0.0)
+- u.bits.manl &= ~m;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++ long double y;
++
++ if (e >= 0x3fff+LDBL_MANT_DIG-1 || x == 0)
++ return x;
++ /* y = int(x) - x, where int(x) is an integer neighbor of x */
++ if (u.i.se >> 15)
++ y = x - TOINT + TOINT - x;
++ else
++ y = x + TOINT - TOINT - x;
++ /* special case because of non-nearest rounding modes */
++ if (e <= 0x3fff-1) {
++ FORCE_EVAL(y);
++ return u.i.se >> 15 ? -0.0 : 1;
+ }
+- return u.e;
++ if (y < 0)
++ return x + y + 1;
++ return x + y;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/copysign.c musl-git/src/math/copysign.c
+--- musl-0.9.13/src/math/copysign.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/copysign.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,11 +1,8 @@
+ #include "libm.h"
+
+ double copysign(double x, double y) {
+- union dshape ux, uy;
+-
+- ux.value = x;
+- uy.value = y;
+- ux.bits &= (uint64_t)-1>>1;
+- ux.bits |= uy.bits & (uint64_t)1<<63;
+- return ux.value;
++ union {double f; uint64_t i;} ux={x}, uy={y};
++ ux.i &= -1ULL/2;
++ ux.i |= uy.i & 1ULL<<63;
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/copysignf.c musl-git/src/math/copysignf.c
+--- musl-0.9.13/src/math/copysignf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/copysignf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,11 +1,10 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+-float copysignf(float x, float y) {
+- union fshape ux, uy;
+-
+- ux.value = x;
+- uy.value = y;
+- ux.bits &= (uint32_t)-1>>1;
+- ux.bits |= uy.bits & (uint32_t)1<<31;
+- return ux.value;
++float copysignf(float x, float y)
++{
++ union {float f; uint32_t i;} ux={x}, uy={y};
++ ux.i &= 0x7fffffff;
++ ux.i |= uy.i & 0x80000000;
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/copysignl.c musl-git/src/math/copysignl.c
+--- musl-0.9.13/src/math/copysignl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/copysignl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,8 +9,8 @@
+ long double copysignl(long double x, long double y)
+ {
+ union ldshape ux = {x}, uy = {y};
+-
+- ux.bits.sign = uy.bits.sign;
+- return ux.value;
++ ux.i.se &= 0x7fff;
++ ux.i.se |= uy.i.se & 0x8000;
++ return ux.f;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/coshl.c musl-git/src/math/coshl.c
+--- musl-0.9.13/src/math/coshl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/coshl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -8,10 +8,7 @@
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+ long double coshl(long double x)
+ {
+- union {
+- long double f;
+- struct{uint64_t m; uint16_t se; uint16_t pad;} i;
+- } u = {.f = x};
++ union ldshape u = {x};
+ unsigned ex = u.i.se & 0x7fff;
+ uint32_t w;
+ long double t;
+diff -Nur musl-0.9.13/src/math/cosl.c musl-git/src/math/cosl.c
+--- musl-0.9.13/src/math/cosl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/cosl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,34 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_cosl.c */
+-/*-
+- * Copyright (c) 2007 Steven G. Kargl
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice unmodified, this list of conditions, and the following
+- * disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-/*
+- * Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows
+- * an accuracy of <= 0.7412 ULP.
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -38,44 +7,33 @@
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ long double cosl(long double x)
+ {
+- union IEEEl2bits z;
++ union ldshape u = {x};
+ unsigned n;
+- long double y[2];
+- long double hi, lo;
+-
+- z.e = x;
+- z.bits.sign = 0;
++ long double y[2], hi, lo;
+
+- /* If x = NaN or Inf, then cos(x) = NaN. */
+- if (z.bits.exp == 0x7fff)
+- return (x - x) / (x - x);
+-
+- /* |x| < (double)pi/4 */
+- if (z.e < M_PI_4) {
+- /* |x| < 0x1p-64 */
+- if (z.bits.exp < 0x3fff - 64)
++ u.i.se &= 0x7fff;
++ if (u.i.se == 0x7fff)
++ return x - x;
++ x = u.f;
++ if (x < M_PI_4) {
++ if (u.i.se < 0x3fff - LDBL_MANT_DIG)
+ /* raise inexact if x!=0 */
+ return 1.0 + x;
+- return __cosl(z.e, 0);
++ return __cosl(x, 0);
+ }
+-
+ n = __rem_pio2l(x, y);
+ hi = y[0];
+ lo = y[1];
+ switch (n & 3) {
+ case 0:
+- hi = __cosl(hi, lo);
+- break;
++ return __cosl(hi, lo);
+ case 1:
+- hi = -__sinl(hi, lo, 1);
+- break;
++ return -__sinl(hi, lo, 1);
+ case 2:
+- hi = -__cosl(hi, lo);
+- break;
++ return -__cosl(hi, lo);
+ case 3:
+- hi = __sinl(hi, lo, 1);
+- break;
++ default:
++ return __sinl(hi, lo, 1);
+ }
+- return hi;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/erfl.c musl-git/src/math/erfl.c
+--- musl-0.9.13/src/math/erfl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/erfl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -253,8 +253,8 @@
+
+ static long double erfc2(uint32_t ix, long double x)
+ {
++ union ldshape u;
+ long double s,z,R,S;
+- uint32_t i0,i1;
+
+ if (ix < 0x3fffa000) /* 0.84375 <= |x| < 1.25 */
+ return erfc1(x);
+@@ -288,28 +288,22 @@
+ S = sc[0] + s * (sc[1] + s * (sc[2] + s * (sc[3] +
+ s * (sc[4] + s))));
+ }
+- z = x;
+- GET_LDOUBLE_WORDS(ix, i0, i1, z);
+- i1 = 0;
+- i0 &= 0xffffff00;
+- SET_LDOUBLE_WORDS(z, ix, i0, i1);
++ u.f = x;
++ u.i.m &= -1ULL << 40;
++ z = u.f;
+ return expl(-z*z - 0.5625) * expl((z - x) * (z + x) + R / S) / x;
+ }
+
+ long double erfl(long double x)
+ {
+ long double r, s, z, y;
+- uint32_t i0, i1, ix;
+- int sign;
++ union ldshape u = {x};
++ uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
++ int sign = u.i.se >> 15;
+
+- GET_LDOUBLE_WORDS(ix, i0, i1, x);
+- sign = ix >> 15;
+- ix &= 0x7fff;
+- if (ix == 0x7fff) {
++ if (ix >= 0x7fff0000)
+ /* erf(nan)=nan, erf(+-inf)=+-1 */
+ return 1 - 2*sign + 1/x;
+- }
+- ix = (ix << 16) | (i0 >> 16);
+ if (ix < 0x3ffed800) { /* |x| < 0.84375 */
+ if (ix < 0x3fde8000) { /* |x| < 2**-33 */
+ return 0.125 * (8 * x + efx8 * x); /* avoid underflow */
+@@ -332,17 +326,13 @@
+ long double erfcl(long double x)
+ {
+ long double r, s, z, y;
+- uint32_t i0, i1, ix;
+- int sign;
++ union ldshape u = {x};
++ uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
++ int sign = u.i.se >> 15;
+
+- GET_LDOUBLE_WORDS(ix, i0, i1, x);
+- sign = ix>>15;
+- ix &= 0x7fff;
+- if (ix == 0x7fff)
++ if (ix >= 0x7fff0000)
+ /* erfc(nan) = nan, erfc(+-inf) = 0,2 */
+ return 2*sign + 1/x;
+-
+- ix = (ix << 16) | (i0 >> 16);
+ if (ix < 0x3ffed800) { /* |x| < 0.84375 */
+ if (ix < 0x3fbe0000) /* |x| < 2**-65 */
+ return 1.0 - x;
+@@ -358,6 +348,7 @@
+ }
+ if (ix < 0x4005d600) /* |x| < 107 */
+ return sign ? 2 - erfc2(ix,x) : erfc2(ix,x);
+- return sign ? 2 - 0x1p-16382L : 0x1p-16382L*0x1p-16382L;
++ y = 0x1p-16382L;
++ return sign ? 2 - y : y*y;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/exp.c musl-git/src/math/exp.c
+--- musl-0.9.13/src/math/exp.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/exp.c 2013-09-16 20:31:39.000000000 +0200
+@@ -80,7 +80,7 @@
+
+ double exp(double x)
+ {
+- double hi, lo, c, xx;
++ double_t hi, lo, c, xx, y;
+ int k, sign;
+ uint32_t hx;
+
+@@ -89,20 +89,19 @@
+ hx &= 0x7fffffff; /* high word of |x| */
+
+ /* special cases */
+- if (hx >= 0x40862e42) { /* if |x| >= 709.78... */
++ if (hx >= 0x4086232b) { /* if |x| >= 708.39... */
+ if (isnan(x))
+ return x;
+- if (hx == 0x7ff00000 && sign) /* -inf */
+- return 0;
+ if (x > 709.782712893383973096) {
+ /* overflow if x!=inf */
+- STRICT_ASSIGN(double, x, 0x1p1023 * x);
++ x *= 0x1p1023;
+ return x;
+ }
+- if (x < -745.13321910194110842) {
+- /* underflow */
+- STRICT_ASSIGN(double, x, 0x1p-1000 * 0x1p-1000);
+- return x;
++ if (x < -708.39641853226410622) {
++ /* underflow if x!=-inf */
++ FORCE_EVAL((float)(-0x1p-149/x));
++ if (x < -745.13321910194110842)
++ return 0;
+ }
+ }
+
+@@ -114,7 +113,7 @@
+ k = 1 - sign - sign;
+ hi = x - k*ln2hi; /* k*ln2hi is exact here */
+ lo = k*ln2lo;
+- STRICT_ASSIGN(double, x, hi - lo);
++ x = hi - lo;
+ } else if (hx > 0x3e300000) { /* if |x| > 2**-28 */
+ k = 0;
+ hi = x;
+@@ -128,8 +127,8 @@
+ /* x is now in primary range */
+ xx = x*x;
+ c = x - xx*(P1+xx*(P2+xx*(P3+xx*(P4+xx*P5))));
+- x = 1 + (x*c/(2-c) - lo + hi);
++ y = 1 + (x*c/(2-c) - lo + hi);
+ if (k == 0)
+- return x;
+- return scalbn(x, k);
++ return y;
++ return scalbn(y, k);
+ }
+diff -Nur musl-0.9.13/src/math/exp2.c musl-git/src/math/exp2.c
+--- musl-0.9.13/src/math/exp2.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/exp2.c 2013-09-16 20:31:39.000000000 +0200
+@@ -305,7 +305,7 @@
+ * Method: (accurate tables)
+ *
+ * Reduce x:
+- * x = 2**k + y, for integer k and |y| <= 1/2.
++ * x = k + y, for integer k and |y| <= 1/2.
+ * Thus we have exp2(x) = 2**k * exp2(y).
+ *
+ * Reduce y:
+@@ -330,41 +330,41 @@
+ */
+ double exp2(double x)
+ {
+- double r, t, z;
+- uint32_t hx, ix, i0;
++ double_t r, t, z;
++ uint32_t ix, i0;
++ union {double f; uint64_t i;} u = {x};
+ union {uint32_t u; int32_t i;} k;
+
+ /* Filter out exceptional cases. */
+- GET_HIGH_WORD(hx, x);
+- ix = hx & 0x7fffffff;
+- if (ix >= 0x40900000) { /* |x| >= 1024 */
+- if (ix >= 0x7ff00000) {
+- GET_LOW_WORD(ix, x);
+- if (hx == 0xfff00000 && ix == 0) /* -inf */
+- return 0;
+- return x;
+- }
+- if (x >= 1024) {
+- STRICT_ASSIGN(double, x, x * 0x1p1023);
++ ix = u.i>>32 & 0x7fffffff;
++ if (ix >= 0x408ff000) { /* |x| >= 1022 or nan */
++ if (ix >= 0x40900000 && u.i>>63 == 0) { /* x >= 1024 or nan */
++ /* overflow */
++ x *= 0x1p1023;
+ return x;
+ }
+- if (x <= -1075) {
+- STRICT_ASSIGN(double, x, 0x1p-1000*0x1p-1000);
+- return x;
++ if (ix >= 0x7ff00000) /* -inf or -nan */
++ return -1/x;
++ if (u.i>>63) { /* x <= -1022 */
++ /* underflow */
++ if (x <= -1075 || x - 0x1p52 + 0x1p52 != x)
++ FORCE_EVAL((float)(-0x1p-149/x));
++ if (x <= -1075)
++ return 0;
+ }
+ } else if (ix < 0x3c900000) { /* |x| < 0x1p-54 */
+ return 1.0 + x;
+ }
+
+ /* Reduce x, computing z, i0, and k. */
+- STRICT_ASSIGN(double, t, x + redux);
+- GET_LOW_WORD(i0, t);
++ u.f = x + redux;
++ i0 = u.i;
+ i0 += TBLSIZE / 2;
+ k.u = i0 / TBLSIZE * TBLSIZE;
+ k.i /= TBLSIZE;
+ i0 %= TBLSIZE;
+- t -= redux;
+- z = x - t;
++ u.f -= redux;
++ z = x - u.f;
+
+ /* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
+ t = tbl[2*i0]; /* exp2t[i0] */
+diff -Nur musl-0.9.13/src/math/exp2f.c musl-git/src/math/exp2f.c
+--- musl-0.9.13/src/math/exp2f.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/exp2f.c 2013-09-16 20:31:39.000000000 +0200
+@@ -63,7 +63,7 @@
+ * Method: (equally-spaced tables)
+ *
+ * Reduce x:
+- * x = 2**k + y, for integer k and |y| <= 1/2.
++ * x = k + y, for integer k and |y| <= 1/2.
+ * Thus we have exp2f(x) = 2**k * exp2(y).
+ *
+ * Reduce y:
+@@ -83,46 +83,42 @@
+ */
+ float exp2f(float x)
+ {
+- double tv, twopk, u, z;
+- float t;
+- uint32_t hx, ix, i0, k;
++ double_t t, r, z;
++ union {float f; uint32_t i;} u = {x};
++ union {double f; uint64_t i;} uk;
++ uint32_t ix, i0, k;
+
+ /* Filter out exceptional cases. */
+- GET_FLOAT_WORD(hx, x);
+- ix = hx & 0x7fffffff;
+- if (ix >= 0x43000000) { /* |x| >= 128 */
+- if (ix >= 0x7f800000) {
+- if (hx == 0xff800000) /* -inf */
+- return 0;
+- return x;
+- }
+- if (x >= 128) {
+- STRICT_ASSIGN(float, x, x * 0x1p127f);
++ ix = u.i & 0x7fffffff;
++ if (ix > 0x42fc0000) { /* |x| > 126 */
++ if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */
++ x *= 0x1p127f;
+ return x;
+ }
+- if (x <= -150) {
+- STRICT_ASSIGN(float, x, 0x1p-100f*0x1p-100f);
+- return x;
++ if (u.i >= 0x80000000) { /* x < -126 */
++ if (u.i >= 0xc3160000 || (u.i & 0x0000ffff))
++ FORCE_EVAL(-0x1p-149f/x);
++ if (u.i >= 0xc3160000) /* x <= -150 */
++ return 0;
+ }
+ } else if (ix <= 0x33000000) { /* |x| <= 0x1p-25 */
+ return 1.0f + x;
+ }
+
+ /* Reduce x, computing z, i0, and k. */
+- STRICT_ASSIGN(float, t, x + redux);
+- GET_FLOAT_WORD(i0, t);
++ u.f = x + redux;
++ i0 = u.i;
+ i0 += TBLSIZE / 2;
+- k = (i0 / TBLSIZE) << 20;
++ k = i0 / TBLSIZE;
++ uk.i = (uint64_t)(0x3ff + k)<<52;
+ i0 &= TBLSIZE - 1;
+- t -= redux;
+- z = x - t;
+- INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
+-
++ u.f -= redux;
++ z = x - u.f;
+ /* Compute r = exp2(y) = exp2ft[i0] * p(z). */
+- tv = exp2ft[i0];
+- u = tv * z;
+- tv = tv + u * (P1 + z * P2) + u * (z * z) * (P3 + z * P4);
++ r = exp2ft[i0];
++ t = r * z;
++ r = r + t * (P1 + z * P2) + t * (z * z) * (P3 + z * P4);
+
+- /* Scale by 2**(k>>20). */
+- return tv * twopk;
++ /* Scale by 2**k */
++ return r * uk.f;
+ }
+diff -Nur musl-0.9.13/src/math/exp2l.c musl-git/src/math/exp2l.c
+--- musl-0.9.13/src/math/exp2l.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/exp2l.c 2013-09-16 20:31:39.000000000 +0200
+@@ -33,13 +33,9 @@
+ return exp2(x);
+ }
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-
+ #define TBLBITS 7
+ #define TBLSIZE (1 << TBLBITS)
+
+-#define BIAS (LDBL_MAX_EXP - 1)
+-#define EXPMASK (BIAS + LDBL_MAX_EXP)
+-
+ static const double
+ redux = 0x1.8p63 / TBLSIZE,
+ P1 = 0x1.62e42fefa39efp-1,
+@@ -203,29 +199,29 @@
+ */
+ long double exp2l(long double x)
+ {
+- union IEEEl2bits u, v;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
+ long double r, z;
+- uint32_t hx, ix, i0;
++ uint32_t i0;
+ union {uint32_t u; int32_t i;} k;
+
+ /* Filter out exceptional cases. */
+- u.e = x;
+- hx = u.xbits.expsign;
+- ix = hx & EXPMASK;
+- if (ix >= BIAS + 14) { /* |x| >= 16384 or x is NaN */
+- if (ix == EXPMASK) {
+- if (u.xbits.man == 1ULL << 63 && hx == 0xffff) /* -inf */
++ if (e >= 0x3fff + 13) { /* |x| >= 8192 or x is NaN */
++ if (u.i.se >= 0x3fff + 14 && u.i.se >> 15 == 0)
++ /* overflow */
++ return x * 0x1p16383L;
++ if (e == 0x7fff) /* -inf or -nan */
++ return -1/x;
++ if (x < -16382) {
++ if (x <= -16446 || x - 0x1p63 + 0x1p63 != x)
++ /* underflow */
++ FORCE_EVAL((float)(-0x1p-149/x));
++ if (x <= -16446)
+ return 0;
+- return x;
+- }
+- if (x >= 16384) {
+- x *= 0x1p16383L;
+- return x;
+ }
+- if (x <= -16446)
+- return 0x1p-10000L*0x1p-10000L;
+- } else if (ix < BIAS - 64) /* |x| < 0x1p-64 */
++ } else if (e < 0x3fff - 64) {
+ return 1 + x;
++ }
+
+ /*
+ * Reduce x, computing z, i0, and k. The low bits of x + redux
+@@ -238,13 +234,13 @@
+ * We split this into k = 0xabc and i0 = 0x12 (adjusted to
+ * index into the table), then we compute z = 0x0.003456p0.
+ */
+- u.e = x + redux;
+- i0 = u.bits.manl + TBLSIZE / 2;
++ u.f = x + redux;
++ i0 = u.i.m + TBLSIZE / 2;
+ k.u = i0 / TBLSIZE * TBLSIZE;
+ k.i /= TBLSIZE;
+ i0 %= TBLSIZE;
+- u.e -= redux;
+- z = x - u.e;
++ u.f -= redux;
++ z = x - u.f;
+
+ /* Compute r = exp2l(y) = exp2lt[i0] * p(z). */
+ long double t_hi = tbl[2*i0];
+diff -Nur musl-0.9.13/src/math/expf.c musl-git/src/math/expf.c
+--- musl-0.9.13/src/math/expf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/expf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -29,7 +29,7 @@
+
+ float expf(float x)
+ {
+- float hi, lo, c, xx;
++ float_t hi, lo, c, xx, y;
+ int k, sign;
+ uint32_t hx;
+
+@@ -38,20 +38,17 @@
+ hx &= 0x7fffffff; /* high word of |x| */
+
+ /* special cases */
+- if (hx >= 0x42b17218) { /* if |x| >= 88.722839f or NaN */
+- if (hx > 0x7f800000) /* NaN */
+- return x;
+- if (!sign) {
+- /* overflow if x!=inf */
+- STRICT_ASSIGN(float, x, x * 0x1p127f);
++ if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */
++ if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */
++ /* overflow */
++ x *= 0x1p127f;
+ return x;
+ }
+- if (hx == 0x7f800000) /* -inf */
+- return 0;
+- if (hx >= 0x42cff1b5) { /* x <= -103.972084f */
++ if (sign) {
+ /* underflow */
+- STRICT_ASSIGN(float, x, 0x1p-100f*0x1p-100f);
+- return x;
++ FORCE_EVAL(-0x1p-149f/x);
++ if (hx >= 0x42cff1b5) /* x <= -103.972084f */
++ return 0;
+ }
+ }
+
+@@ -63,7 +60,7 @@
+ k = 1 - sign - sign;
+ hi = x - k*ln2hi; /* k*ln2hi is exact here */
+ lo = k*ln2lo;
+- STRICT_ASSIGN(float, x, hi - lo);
++ x = hi - lo;
+ } else if (hx > 0x39000000) { /* |x| > 2**-14 */
+ k = 0;
+ hi = x;
+@@ -77,8 +74,8 @@
+ /* x is now in primary range */
+ xx = x*x;
+ c = x - xx*(P1+xx*P2);
+- x = 1 + (x*c/(2-c) - lo + hi);
++ y = 1 + (x*c/(2-c) - lo + hi);
+ if (k == 0)
+- return x;
+- return scalbnf(x, k);
++ return y;
++ return scalbnf(y, k);
+ }
+diff -Nur musl-0.9.13/src/math/expl.c musl-git/src/math/expl.c
+--- musl-0.9.13/src/math/expl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/expl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -100,7 +100,7 @@
+ if (x > 11356.5234062941439488L) /* x > ln(2^16384 - 0.5) */
+ return x * 0x1p16383L;
+ if (x < -11399.4985314888605581L) /* x < ln(2^-16446) */
+- return 0x1p-10000L * 0x1p-10000L;
++ return -0x1p-16445L/x;
+
+ /* Express e**x = e**f 2**k
+ * = e**(f + k ln(2))
+diff -Nur musl-0.9.13/src/math/expm1.c musl-git/src/math/expm1.c
+--- musl-0.9.13/src/math/expm1.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/expm1.c 2013-09-16 20:31:39.000000000 +0200
+@@ -31,7 +31,7 @@
+ * R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+ * = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+ * = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+- * We use a special Reme algorithm on [0,0.347] to generate
++ * We use a special Remez algorithm on [0,0.347] to generate
+ * a polynomial of degree 5 in r*r to approximate R1. The
+ * maximum error of this polynomial approximation is bounded
+ * by 2**-61. In other words,
+@@ -107,8 +107,6 @@
+ #include "libm.h"
+
+ static const double
+-huge = 1.0e+300,
+-tiny = 1.0e-300,
+ o_threshold = 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
+ ln2_hi = 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
+ ln2_lo = 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
+@@ -122,39 +120,27 @@
+
+ double expm1(double x)
+ {
+- double y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
+- int32_t k,xsb;
+- uint32_t hx;
+-
+- GET_HIGH_WORD(hx, x);
+- xsb = hx&0x80000000; /* sign bit of x */
+- hx &= 0x7fffffff; /* high word of |x| */
++ double_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
++ union {double f; uint64_t i;} u = {x};
++ uint32_t hx = u.i>>32 & 0x7fffffff;
++ int k, sign = u.i>>63;
+
+ /* filter out huge and non-finite argument */
+ if (hx >= 0x4043687A) { /* if |x|>=56*ln2 */
+- if (hx >= 0x40862E42) { /* if |x|>=709.78... */
+- if (hx >= 0x7ff00000) {
+- uint32_t low;
+-
+- GET_LOW_WORD(low, x);
+- if (((hx&0xfffff)|low) != 0) /* NaN */
+- return x+x;
+- return xsb==0 ? x : -1.0; /* exp(+-inf)={inf,-1} */
+- }
+- if(x > o_threshold)
+- return huge*huge; /* overflow */
+- }
+- if (xsb != 0) { /* x < -56*ln2, return -1.0 with inexact */
+- /* raise inexact */
+- if(x+tiny<0.0)
+- return tiny-1.0; /* return -1 */
++ if (isnan(x))
++ return x;
++ if (sign)
++ return -1;
++ if (x > o_threshold) {
++ x *= 0x1p1023;
++ return x;
+ }
+ }
+
+ /* argument reduction */
+ if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
+ if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
+- if (xsb == 0) {
++ if (!sign) {
+ hi = x - ln2_hi;
+ lo = ln2_lo;
+ k = 1;
+@@ -164,17 +150,17 @@
+ k = -1;
+ }
+ } else {
+- k = invln2*x + (xsb==0 ? 0.5 : -0.5);
++ k = invln2*x + (sign ? -0.5 : 0.5);
+ t = k;
+ hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
+ lo = t*ln2_lo;
+ }
+- STRICT_ASSIGN(double, x, hi - lo);
++ x = hi-lo;
+ c = (hi-x)-lo;
+ } else if (hx < 0x3c900000) { /* |x| < 2**-54, return x */
+- /* raise inexact flags when x != 0 */
+- t = huge+x;
+- return x - (t-(huge+x));
++ if (hx < 0x00100000)
++ FORCE_EVAL((float)x);
++ return x;
+ } else
+ k = 0;
+
+@@ -186,9 +172,9 @@
+ e = hxs*((r1-t)/(6.0 - x*t));
+ if (k == 0) /* c is 0 */
+ return x - (x*e-hxs);
+- INSERT_WORDS(twopk, 0x3ff00000+(k<<20), 0); /* 2^k */
+ e = x*(e-c) - c;
+ e -= hxs;
++ /* exp(x) ~ 2^k (x_reduced - e + 1) */
+ if (k == -1)
+ return 0.5*(x-e) - 0.5;
+ if (k == 1) {
+@@ -196,24 +182,20 @@
+ return -2.0*(e-(x+0.5));
+ return 1.0+2.0*(x-e);
+ }
+- if (k <= -2 || k > 56) { /* suffice to return exp(x)-1 */
+- y = 1.0 - (e-x);
++ u.i = (uint64_t)(0x3ff + k)<<52; /* 2^k */
++ twopk = u.f;
++ if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */
++ y = x - e + 1.0;
+ if (k == 1024)
+ y = y*2.0*0x1p1023;
+ else
+ y = y*twopk;
+ return y - 1.0;
+ }
+- t = 1.0;
+- if (k < 20) {
+- SET_HIGH_WORD(t, 0x3ff00000 - (0x200000>>k)); /* t=1-2^-k */
+- y = t-(e-x);
+- y = y*twopk;
+- } else {
+- SET_HIGH_WORD(t, ((0x3ff-k)<<20)); /* 2^-k */
+- y = x-(e+t);
+- y += 1.0;
+- y = y*twopk;
+- }
++ u.i = (uint64_t)(0x3ff - k)<<52; /* 2^-k */
++ if (k < 20)
++ y = (x-e+(1-u.f))*twopk;
++ else
++ y = (x-(e+u.f)+1)*twopk;
+ return y;
+ }
+diff -Nur musl-0.9.13/src/math/expm1f.c musl-git/src/math/expm1f.c
+--- musl-0.9.13/src/math/expm1f.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/expm1f.c 2013-09-16 20:31:39.000000000 +0200
+@@ -16,8 +16,6 @@
+ #include "libm.h"
+
+ static const float
+-huge = 1.0e+30,
+-tiny = 1.0e-30,
+ o_threshold = 8.8721679688e+01, /* 0x42b17180 */
+ ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
+ ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
+@@ -32,35 +30,27 @@
+
+ float expm1f(float x)
+ {
+- float y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
+- int32_t k,xsb;
+- uint32_t hx;
+-
+- GET_FLOAT_WORD(hx, x);
+- xsb = hx&0x80000000; /* sign bit of x */
+- hx &= 0x7fffffff; /* high word of |x| */
++ float_t y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
++ union {float f; uint32_t i;} u = {x};
++ uint32_t hx = u.i & 0x7fffffff;
++ int k, sign = u.i >> 31;
+
+ /* filter out huge and non-finite argument */
+ if (hx >= 0x4195b844) { /* if |x|>=27*ln2 */
+- if (hx >= 0x42b17218) { /* if |x|>=88.721... */
+- if (hx > 0x7f800000) /* NaN */
+- return x+x;
+- if (hx == 0x7f800000) /* exp(+-inf)={inf,-1} */
+- return xsb==0 ? x : -1.0;
+- if (x > o_threshold)
+- return huge*huge; /* overflow */
+- }
+- if (xsb != 0) { /* x < -27*ln2 */
+- /* raise inexact */
+- if (x+tiny < 0.0f)
+- return tiny-1.0f; /* return -1 */
++ if (hx > 0x7f800000) /* NaN */
++ return x;
++ if (sign)
++ return -1;
++ if (x > o_threshold) {
++ x *= 0x1p127f;
++ return x;
+ }
+ }
+
+ /* argument reduction */
+ if (hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
+ if (hx < 0x3F851592) { /* and |x| < 1.5 ln2 */
+- if (xsb == 0) {
++ if (!sign) {
+ hi = x - ln2_hi;
+ lo = ln2_lo;
+ k = 1;
+@@ -70,16 +60,17 @@
+ k = -1;
+ }
+ } else {
+- k = invln2*x + (xsb==0 ? 0.5f : -0.5f);
++ k = invln2*x + (sign ? -0.5f : 0.5f);
+ t = k;
+ hi = x - t*ln2_hi; /* t*ln2_hi is exact here */
+ lo = t*ln2_lo;
+ }
+- STRICT_ASSIGN(float, x, hi - lo);
++ x = hi-lo;
+ c = (hi-x)-lo;
+ } else if (hx < 0x33000000) { /* when |x|<2**-25, return x */
+- t = huge+x; /* return x with inexact flags when x!=0 */
+- return x - (t-(huge+x));
++ if (hx < 0x00800000)
++ FORCE_EVAL(x*x);
++ return x;
+ } else
+ k = 0;
+
+@@ -91,9 +82,9 @@
+ e = hxs*((r1-t)/(6.0f - x*t));
+ if (k == 0) /* c is 0 */
+ return x - (x*e-hxs);
+- SET_FLOAT_WORD(twopk, 0x3f800000+(k<<23)); /* 2^k */
+ e = x*(e-c) - c;
+ e -= hxs;
++ /* exp(x) ~ 2^k (x_reduced - e + 1) */
+ if (k == -1)
+ return 0.5f*(x-e) - 0.5f;
+ if (k == 1) {
+@@ -101,24 +92,20 @@
+ return -2.0f*(e-(x+0.5f));
+ return 1.0f + 2.0f*(x-e);
+ }
+- if (k <= -2 || k > 56) { /* suffice to return exp(x)-1 */
+- y = 1.0f - (e - x);
++ u.i = (0x7f+k)<<23; /* 2^k */
++ twopk = u.f;
++ if (k < 0 || k > 56) { /* suffice to return exp(x)-1 */
++ y = x - e + 1.0f;
+ if (k == 128)
+ y = y*2.0f*0x1p127f;
+ else
+ y = y*twopk;
+ return y - 1.0f;
+ }
+- t = 1.0f;
+- if (k < 23) {
+- SET_FLOAT_WORD(t, 0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */
+- y = t - (e - x);
+- y = y*twopk;
+- } else {
+- SET_FLOAT_WORD(t, (0x7f-k)<<23); /* 2^-k */
+- y = x - (e + t);
+- y += 1.0f;
+- y = y*twopk;
+- }
++ u.i = (0x7f-k)<<23; /* 2^-k */
++ if (k < 23)
++ y = (x-e+(1-u.f))*twopk;
++ else
++ y = (x-(e+u.f)+1)*twopk;
+ return y;
+ }
+diff -Nur musl-0.9.13/src/math/fabs.c musl-git/src/math/fabs.c
+--- musl-0.9.13/src/math/fabs.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fabs.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,9 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ double fabs(double x)
+ {
+- union dshape u;
+-
+- u.value = x;
+- u.bits &= (uint64_t)-1 / 2;
+- return u.value;
++ union {double f; uint64_t i;} u = {x};
++ u.i &= -1ULL/2;
++ return u.f;
+ }
+diff -Nur musl-0.9.13/src/math/fabsf.c musl-git/src/math/fabsf.c
+--- musl-0.9.13/src/math/fabsf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fabsf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,9 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ float fabsf(float x)
+ {
+- union fshape u;
+-
+- u.value = x;
+- u.bits &= (uint32_t)-1 / 2;
+- return u.value;
++ union {float f; uint32_t i;} u = {x};
++ u.i &= 0x7fffffff;
++ return u.f;
+ }
+diff -Nur musl-0.9.13/src/math/fabsl.c musl-git/src/math/fabsl.c
+--- musl-0.9.13/src/math/fabsl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fabsl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,7 +9,7 @@
+ {
+ union ldshape u = {x};
+
+- u.bits.sign = 0;
+- return u.value;
++ u.i.se &= 0x7fff;
++ return u.f;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/floor.c musl-git/src/math/floor.c
+--- musl-0.9.13/src/math/floor.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/floor.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,82 +1,24 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_floor.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * floor(x)
+- * Return x rounded toward -inf to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to floor(x).
+- */
+-
+ #include "libm.h"
+
+-static const double huge = 1.0e300;
+-
+ double floor(double x)
+ {
+- int32_t i0,i1,j0;
+- uint32_t i,j;
++ union {double f; uint64_t i;} u = {x};
++ int e = u.i >> 52 & 0x7ff;
++ double_t y;
+
+- EXTRACT_WORDS(i0, i1, x);
+- // FIXME: signed shift
+- j0 = ((i0>>20)&0x7ff) - 0x3ff;
+- if (j0 < 20) {
+- if (j0 < 0) { /* |x| < 1 */
+- /* raise inexact if x != 0 */
+- if (huge+x > 0.0) {
+- if (i0 >= 0) { /* x >= 0 */
+- i0 = i1 = 0;
+- } else if (((i0&0x7fffffff)|i1) != 0) {
+- i0 = 0xbff00000;
+- i1 = 0;
+- }
+- }
+- } else {
+- i = 0x000fffff>>j0;
+- if (((i0&i)|i1) == 0)
+- return x; /* x is integral */
+- /* raise inexact flag */
+- if (huge+x > 0.0) {
+- if (i0 < 0)
+- i0 += 0x00100000>>j0;
+- i0 &= ~i;
+- i1 = 0;
+- }
+- }
+- } else if (j0 > 51) {
+- if (j0 == 0x400)
+- return x+x; /* inf or NaN */
+- else
+- return x; /* x is integral */
+- } else {
+- i = (uint32_t)0xffffffff>>(j0-20);
+- if ((i1&i) == 0)
+- return x; /* x is integral */
+- /* raise inexact flag */
+- if (huge+x > 0.0) {
+- if (i0 < 0) {
+- if (j0 == 20)
+- i0++;
+- else {
+- j = i1+(1<<(52-j0));
+- if (j < i1)
+- i0++; /* got a carry */
+- i1 = j;
+- }
+- }
+- i1 &= ~i;
+- }
++ if (e >= 0x3ff+52 || x == 0)
++ return x;
++ /* y = int(x) - x, where int(x) is an integer neighbor of x */
++ if (u.i >> 63)
++ y = (double)(x - 0x1p52) + 0x1p52 - x;
++ else
++ y = (double)(x + 0x1p52) - 0x1p52 - x;
++ /* special case because of non-nearest rounding modes */
++ if (e <= 0x3ff-1) {
++ FORCE_EVAL(y);
++ return u.i >> 63 ? -1 : 0;
+ }
+- INSERT_WORDS(x, i0, i1);
+- return x;
++ if (y > 0)
++ return x + y - 1;
++ return x + y;
+ }
+diff -Nur musl-0.9.13/src/math/floorf.c musl-git/src/math/floorf.c
+--- musl-0.9.13/src/math/floorf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/floorf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,64 +1,27 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_floorf.c */
+-/*
+- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+- */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * floorf(x)
+- * Return x rounded toward -inf to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to floorf(x).
+- */
+-
+ #include "libm.h"
+
+-static const float huge = 1.0e30;
+-
+ float floorf(float x)
+ {
+- int32_t i0,j0;
+- uint32_t i;
++ union {float f; uint32_t i;} u = {x};
++ int e = (int)(u.i >> 23 & 0xff) - 0x7f;
++ uint32_t m;
+
+- GET_FLOAT_WORD(i0, x);
+- // FIXME: signed shift
+- j0 = ((i0>>23)&0xff) - 0x7f;
+- if (j0 < 23) {
+- if (j0 < 0) { /* |x| < 1 */
+- /* raise inexact if x != 0 */
+- if (huge+x > 0.0f) {
+- if (i0 >= 0) /* x >= 0 */
+- i0 = 0;
+- else if ((i0&0x7fffffff) != 0)
+- i0 = 0xbf800000;
+- }
+- } else {
+- i = 0x007fffff>>j0;
+- if ((i0&i) == 0)
+- return x; /* x is integral */
+- /* raise inexact flag */
+- if (huge+x > 0.0f) {
+- if (i0 < 0)
+- i0 += 0x00800000>>j0;
+- i0 &= ~i;
+- }
+- }
++ if (e >= 23)
++ return x;
++ if (e >= 0) {
++ m = 0x007fffff >> e;
++ if ((u.i & m) == 0)
++ return x;
++ FORCE_EVAL(x + 0x1p120f);
++ if (u.i >> 31)
++ u.i += m;
++ u.i &= ~m;
+ } else {
+- if (j0 == 0x80) /* inf or NaN */
+- return x+x;
+- else
+- return x; /* x is integral */
++ FORCE_EVAL(x + 0x1p120f);
++ if (u.i >> 31 == 0)
++ u.i = 0;
++ else if (u.i << 1)
++ u.f = -1.0;
+ }
+- SET_FLOAT_WORD(x, i0);
+- return x;
++ return u.f;
+ }
+diff -Nur musl-0.9.13/src/math/floorl.c musl-git/src/math/floorl.c
+--- musl-0.9.13/src/math/floorl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/floorl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,23 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_floorl.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * floorl(x)
+- * Return x rounded toward -inf to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to floorl(x).
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -26,77 +6,31 @@
+ return floor(x);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#ifdef LDBL_IMPLICIT_NBIT
+-#define MANH_SIZE (LDBL_MANH_SIZE + 1)
+-#define INC_MANH(u, c) do { \
+- uint64_t o = u.bits.manh; \
+- u.bits.manh += (c); \
+- if (u.bits.manh < o) \
+- u.bits.exp++; \
+-} while (0)
+-#else
+-#define MANH_SIZE LDBL_MANH_SIZE
+-#define INC_MANH(u, c) do { \
+- uint64_t o = u.bits.manh; \
+- u.bits.manh += (c); \
+- if (u.bits.manh < o) { \
+- u.bits.exp++; \
+- u.bits.manh |= 1llu << (LDBL_MANH_SIZE - 1); \
+- } \
+-} while (0)
++#if LDBL_MANT_DIG == 64
++#define TOINT 0x1p63
++#elif LDBL_MANT_DIG == 113
++#define TOINT 0x1p112
+ #endif
+-
+-static const long double huge = 1.0e300;
+-
+ long double floorl(long double x)
+ {
+- union IEEEl2bits u = { .e = x };
+- int e = u.bits.exp - LDBL_MAX_EXP + 1;
+-
+- if (e < MANH_SIZE - 1) {
+- if (e < 0) {
+- /* raise inexact if x != 0 */
+- if (huge + x > 0.0)
+- if (u.bits.exp > 0 ||
+- (u.bits.manh | u.bits.manl) != 0)
+- u.e = u.bits.sign ? -1.0 : 0.0;
+- } else {
+- uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
+- if (((u.bits.manh & m) | u.bits.manl) == 0)
+- return x; /* x is integral */
+- if (u.bits.sign) {
+-#ifdef LDBL_IMPLICIT_NBIT
+- if (e == 0)
+- u.bits.exp++;
+- else
+-#endif
+- INC_MANH(u, 1llu << (MANH_SIZE - e - 1));
+- }
+- /* raise inexact flag */
+- if (huge + x > 0.0) {
+- u.bits.manh &= ~m;
+- u.bits.manl = 0;
+- }
+- }
+- } else if (e < LDBL_MANT_DIG - 1) {
+- uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
+- if ((u.bits.manl & m) == 0)
+- return x; /* x is integral */
+- if (u.bits.sign) {
+- if (e == MANH_SIZE - 1)
+- INC_MANH(u, 1);
+- else {
+- uint64_t o = u.bits.manl;
+- u.bits.manl += 1llu << (LDBL_MANT_DIG - e - 1);
+- if (u.bits.manl < o) /* got a carry */
+- INC_MANH(u, 1);
+- }
+- }
+- /* raise inexact flag */
+- if (huge + x > 0.0)
+- u.bits.manl &= ~m;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++ long double y;
++
++ if (e >= 0x3fff+LDBL_MANT_DIG-1 || x == 0)
++ return x;
++ /* y = int(x) - x, where int(x) is an integer neighbor of x */
++ if (u.i.se >> 15)
++ y = x - TOINT + TOINT - x;
++ else
++ y = x + TOINT - TOINT - x;
++ /* special case because of non-nearest rounding modes */
++ if (e <= 0x3fff-1) {
++ FORCE_EVAL(y);
++ return u.i.se >> 15 ? -1 : 0;
+ }
+- return u.e;
++ if (y > 0)
++ return x + y - 1;
++ return x + y;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/fma.c musl-git/src/math/fma.c
+--- musl-0.9.13/src/math/fma.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fma.c 2013-09-16 20:31:39.000000000 +0200
+@@ -2,16 +2,6 @@
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG==64 && LDBL_MAX_EXP==16384
+-union ld80 {
+- long double x;
+- struct {
+- uint64_t m;
+- uint16_t e : 15;
+- uint16_t s : 1;
+- uint16_t pad;
+- } bits;
+-};
+-
+ /* exact add, assumes exponent_x >= exponent_y */
+ static void add(long double *hi, long double *lo, long double x, long double y)
+ {
+@@ -45,25 +35,25 @@
+ */
+ static long double adjust(long double hi, long double lo)
+ {
+- union ld80 uhi, ulo;
++ union ldshape uhi, ulo;
+
+ if (lo == 0)
+ return hi;
+- uhi.x = hi;
+- if (uhi.bits.m & 0x3ff)
++ uhi.f = hi;
++ if (uhi.i.m & 0x3ff)
+ return hi;
+- ulo.x = lo;
+- if (uhi.bits.s == ulo.bits.s)
+- uhi.bits.m++;
++ ulo.f = lo;
++ if ((uhi.i.se & 0x8000) == (ulo.i.se & 0x8000))
++ uhi.i.m++;
+ else {
+- uhi.bits.m--;
+ /* handle underflow and take care of ld80 implicit msb */
+- if (uhi.bits.m == (uint64_t)-1/2) {
+- uhi.bits.m *= 2;
+- uhi.bits.e--;
++ if (uhi.i.m << 1 == 0) {
++ uhi.i.m = 0;
++ uhi.i.se--;
+ }
++ uhi.i.m--;
+ }
+- return uhi.x;
++ return uhi.f;
+ }
+
+ /* adjusted add so the result is correct when rounded to double (or less) precision */
+@@ -82,9 +72,9 @@
+
+ static int getexp(long double x)
+ {
+- union ld80 u;
+- u.x = x;
+- return u.bits.e;
++ union ldshape u;
++ u.f = x;
++ return u.i.se & 0x7fff;
+ }
+
+ double fma(double x, double y, double z)
+@@ -242,16 +232,16 @@
+ static inline double add_adjusted(double a, double b)
+ {
+ struct dd sum;
+- uint64_t hibits, lobits;
++ union {double f; uint64_t i;} uhi, ulo;
+
+ sum = dd_add(a, b);
+ if (sum.lo != 0) {
+- EXTRACT_WORD64(hibits, sum.hi);
+- if ((hibits & 1) == 0) {
++ uhi.f = sum.hi;
++ if ((uhi.i & 1) == 0) {
+ /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+- EXTRACT_WORD64(lobits, sum.lo);
+- hibits += 1 - ((hibits ^ lobits) >> 62);
+- INSERT_WORD64(sum.hi, hibits);
++ ulo.f = sum.lo;
++ uhi.i += 1 - ((uhi.i ^ ulo.i) >> 62);
++ sum.hi = uhi.f;
+ }
+ }
+ return (sum.hi);
+@@ -265,7 +255,7 @@
+ static inline double add_and_denormalize(double a, double b, int scale)
+ {
+ struct dd sum;
+- uint64_t hibits, lobits;
++ union {double f; uint64_t i;} uhi, ulo;
+ int bits_lost;
+
+ sum = dd_add(a, b);
+@@ -281,13 +271,13 @@
+ * break the ties manually.
+ */
+ if (sum.lo != 0) {
+- EXTRACT_WORD64(hibits, sum.hi);
+- bits_lost = -((int)(hibits >> 52) & 0x7ff) - scale + 1;
+- if (bits_lost != 1 ^ (int)(hibits & 1)) {
++ uhi.f = sum.hi;
++ bits_lost = -((int)(uhi.i >> 52) & 0x7ff) - scale + 1;
++ if (bits_lost != 1 ^ (int)(uhi.i & 1)) {
+ /* hibits += (int)copysign(1.0, sum.hi * sum.lo) */
+- EXTRACT_WORD64(lobits, sum.lo);
+- hibits += 1 - (((hibits ^ lobits) >> 62) & 2);
+- INSERT_WORD64(sum.hi, hibits);
++ ulo.f = sum.lo;
++ uhi.i += 1 - (((uhi.i ^ ulo.i) >> 62) & 2);
++ sum.hi = uhi.f;
+ }
+ }
+ return scalbn(sum.hi, scale);
+diff -Nur musl-0.9.13/src/math/fmal.c musl-git/src/math/fmal.c
+--- musl-0.9.13/src/math/fmal.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fmal.c 2013-09-16 20:31:39.000000000 +0200
+@@ -34,6 +34,13 @@
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ #include <fenv.h>
++#if LDBL_MANT_DIG == 64
++#define LASTBIT(u) (u.i.m & 1)
++#define SPLIT (0x1p32L + 1)
++#elif LDBL_MANT_DIG == 113
++#define LASTBIT(u) (u.i.lo & 1)
++#define SPLIT (0x1p57L + 1)
++#endif
+
+ /*
+ * A struct dd represents a floating-point number with twice the precision
+@@ -75,12 +82,12 @@
+ static inline long double add_adjusted(long double a, long double b)
+ {
+ struct dd sum;
+- union IEEEl2bits u;
++ union ldshape u;
+
+ sum = dd_add(a, b);
+ if (sum.lo != 0) {
+- u.e = sum.hi;
+- if ((u.bits.manl & 1) == 0)
++ u.f = sum.hi;
++ if (!LASTBIT(u))
+ sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
+ }
+ return (sum.hi);
+@@ -95,7 +102,7 @@
+ {
+ struct dd sum;
+ int bits_lost;
+- union IEEEl2bits u;
++ union ldshape u;
+
+ sum = dd_add(a, b);
+
+@@ -110,9 +117,9 @@
+ * break the ties manually.
+ */
+ if (sum.lo != 0) {
+- u.e = sum.hi;
+- bits_lost = -u.bits.exp - scale + 1;
+- if (bits_lost != 1 ^ (int)(u.bits.manl & 1))
++ u.f = sum.hi;
++ bits_lost = -u.i.se - scale + 1;
++ if ((bits_lost != 1) ^ LASTBIT(u))
+ sum.hi = nextafterl(sum.hi, INFINITY * sum.lo);
+ }
+ return scalbnl(sum.hi, scale);
+@@ -125,20 +132,15 @@
+ */
+ static inline struct dd dd_mul(long double a, long double b)
+ {
+-#if LDBL_MANT_DIG == 64
+- static const long double split = 0x1p32L + 1.0;
+-#elif LDBL_MANT_DIG == 113
+- static const long double split = 0x1p57L + 1.0;
+-#endif
+ struct dd ret;
+ long double ha, hb, la, lb, p, q;
+
+- p = a * split;
++ p = a * SPLIT;
+ ha = a - p;
+ ha += p;
+ la = a - ha;
+
+- p = b * split;
++ p = b * SPLIT;
+ hb = b - p;
+ hb += p;
+ lb = b - hb;
+diff -Nur musl-0.9.13/src/math/fmod.c musl-git/src/math/fmod.c
+--- musl-0.9.13/src/math/fmod.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fmod.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,145 +1,68 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_fmod.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * fmod(x,y)
+- * Return x mod y in exact arithmetic
+- * Method: shift and subtract
+- */
+-
+-#include "libm.h"
+-
+-static const double Zero[] = {0.0, -0.0,};
++#include <math.h>
++#include <stdint.h>
+
+ double fmod(double x, double y)
+ {
+- int32_t n,hx,hy,hz,ix,iy,sx,i;
+- uint32_t lx,ly,lz;
++ union {double f; uint64_t i;} ux = {x}, uy = {y};
++ int ex = ux.i>>52 & 0x7ff;
++ int ey = uy.i>>52 & 0x7ff;
++ int sx = ux.i>>63;
++ uint64_t i;
++
++ /* in the followings uxi should be ux.i, but then gcc wrongly adds */
++ /* float load/store to inner loops ruining performance and code size */
++ uint64_t uxi = ux.i;
+
+- EXTRACT_WORDS(hx, lx, x);
+- EXTRACT_WORDS(hy, ly, y);
+- sx = hx & 0x80000000; /* sign of x */
+- hx ^= sx; /* |x| */
+- hy &= 0x7fffffff; /* |y| */
+-
+- /* purge off exception values */
+- if ((hy|ly) == 0 || hx >= 0x7ff00000 || /* y=0,or x not finite */
+- (hy|((ly|-ly)>>31)) > 0x7ff00000) /* or y is NaN */
++ if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff)
+ return (x*y)/(x*y);
+- if (hx <= hy) {
+- if (hx < hy || lx < ly) /* |x| < |y| */
+- return x;
+- if (lx == ly) /* |x| = |y|, return x*0 */
+- return Zero[(uint32_t)sx>>31];
+- }
+-
+- /* determine ix = ilogb(x) */
+- if (hx < 0x00100000) { /* subnormal x */
+- if (hx == 0) {
+- for (ix = -1043, i = lx; i > 0; i <<= 1)
+- ix -= 1;
+- } else {
+- for (ix = -1022, i = hx<<11; i > 0; i <<= 1)
+- ix -= 1;
+- }
+- } else
+- ix = (hx>>20) - 1023;
+-
+- /* determine iy = ilogb(y) */
+- if (hy < 0x00100000) { /* subnormal y */
+- if (hy == 0) {
+- for (iy = -1043, i = ly; i > 0; i <<= 1)
+- iy -= 1;
+- } else {
+- for (iy = -1022, i = hy<<11; i > 0; i <<= 1)
+- iy -= 1;
+- }
+- } else
+- iy = (hy>>20) - 1023;
+-
+- /* set up {hx,lx}, {hy,ly} and align y to x */
+- if (ix >= -1022)
+- hx = 0x00100000|(0x000fffff&hx);
+- else { /* subnormal x, shift x to normal */
+- n = -1022-ix;
+- if (n <= 31) {
+- hx = (hx<<n)|(lx>>(32-n));
+- lx <<= n;
+- } else {
+- hx = lx<<(n-32);
+- lx = 0;
+- }
+- }
+- if(iy >= -1022)
+- hy = 0x00100000|(0x000fffff&hy);
+- else { /* subnormal y, shift y to normal */
+- n = -1022-iy;
+- if (n <= 31) {
+- hy = (hy<<n)|(ly>>(32-n));
+- ly <<= n;
+- } else {
+- hy = ly<<(n-32);
+- ly = 0;
+- }
+- }
+-
+- /* fix point fmod */
+- n = ix - iy;
+- while (n--) {
+- hz = hx-hy;
+- lz = lx-ly;
+- if (lx < ly)
+- hz -= 1;
+- if (hz < 0) {
+- hx = hx+hx+(lx>>31);
+- lx = lx+lx;
+- } else {
+- if ((hz|lz) == 0) /* return sign(x)*0 */
+- return Zero[(uint32_t)sx>>31];
+- hx = hz+hz+(lz>>31);
+- lx = lz+lz;
+- }
+- }
+- hz = hx-hy;
+- lz = lx-ly;
+- if (lx < ly)
+- hz -= 1;
+- if (hz >= 0) {
+- hx = hz;
+- lx = lz;
+- }
+-
+- /* convert back to floating value and restore the sign */
+- if ((hx|lx) == 0) /* return sign(x)*0 */
+- return Zero[(uint32_t)sx>>31];
+- while (hx < 0x00100000) { /* normalize x */
+- hx = hx+hx+(lx>>31);
+- lx = lx+lx;
+- iy -= 1;
+- }
+- if (iy >= -1022) { /* normalize output */
+- hx = ((hx-0x00100000)|((iy+1023)<<20));
+- INSERT_WORDS(x, hx|sx, lx);
+- } else { /* subnormal output */
+- n = -1022 - iy;
+- if (n <= 20) {
+- lx = (lx>>n)|((uint32_t)hx<<(32-n));
+- hx >>= n;
+- } else if (n <= 31) {
+- lx = (hx<<(32-n))|(lx>>n);
+- hx = sx;
+- } else {
+- lx = hx>>(n-32); hx = sx;
+- }
+- INSERT_WORDS(x, hx|sx, lx);
+- }
+- return x; /* exact output */
++ if (uxi<<1 <= uy.i<<1) {
++ if (uxi<<1 == uy.i<<1)
++ return 0*x;
++ return x;
++ }
++
++ /* normalize x and y */
++ if (!ex) {
++ for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1);
++ uxi <<= -ex + 1;
++ } else {
++ uxi &= -1ULL >> 12;
++ uxi |= 1ULL << 52;
++ }
++ if (!ey) {
++ for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1);
++ uy.i <<= -ey + 1;
++ } else {
++ uy.i &= -1ULL >> 12;
++ uy.i |= 1ULL << 52;
++ }
++
++ /* x mod y */
++ for (; ex > ey; ex--) {
++ i = uxi - uy.i;
++ if (i >> 63 == 0) {
++ if (i == 0)
++ return 0*x;
++ uxi = i;
++ }
++ uxi <<= 1;
++ }
++ i = uxi - uy.i;
++ if (i >> 63 == 0) {
++ if (i == 0)
++ return 0*x;
++ uxi = i;
++ }
++ for (; uxi>>52 == 0; uxi <<= 1, ex--);
++
++ /* scale result */
++ if (ex > 0) {
++ uxi -= 1ULL << 52;
++ uxi |= (uint64_t)ex << 52;
++ } else {
++ uxi >>= -ex + 1;
++ }
++ uxi |= (uint64_t)sx << 63;
++ ux.i = uxi;
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/fmodf.c musl-git/src/math/fmodf.c
+--- musl-0.9.13/src/math/fmodf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fmodf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,104 +1,65 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_fmodf.c */
+-/*
+- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+- */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * fmodf(x,y)
+- * Return x mod y in exact arithmetic
+- * Method: shift and subtract
+- */
+-
+-#include "libm.h"
+-
+-static const float Zero[] = {0.0, -0.0,};
++#include <math.h>
++#include <stdint.h>
+
+ float fmodf(float x, float y)
+ {
+- int32_t n,hx,hy,hz,ix,iy,sx,i;
++ union {float f; uint32_t i;} ux = {x}, uy = {y};
++ int ex = ux.i>>23 & 0xff;
++ int ey = uy.i>>23 & 0xff;
++ uint32_t sx = ux.i & 0x80000000;
++ uint32_t i;
++ uint32_t uxi = ux.i;
+
+- GET_FLOAT_WORD(hx, x);
+- GET_FLOAT_WORD(hy, y);
+- sx = hx & 0x80000000; /* sign of x */
+- hx ^= sx; /* |x| */
+- hy &= 0x7fffffff; /* |y| */
+-
+- /* purge off exception values */
+- if (hy == 0 || hx >= 0x7f800000 || /* y=0,or x not finite */
+- hy > 0x7f800000) /* or y is NaN */
++ if (uy.i<<1 == 0 || isnan(y) || ex == 0xff)
+ return (x*y)/(x*y);
+- if (hx < hy) /* |x| < |y| */
++ if (uxi<<1 <= uy.i<<1) {
++ if (uxi<<1 == uy.i<<1)
++ return 0*x;
+ return x;
+- if (hx == hy) /* |x| = |y|, return x*0 */
+- return Zero[(uint32_t)sx>>31];
+-
+- /* determine ix = ilogb(x) */
+- if (hx < 0x00800000) { /* subnormal x */
+- for (ix = -126, i = hx<<8; i > 0; i <<= 1)
+- ix -= 1;
+- } else
+- ix = (hx>>23) - 127;
+-
+- /* determine iy = ilogb(y) */
+- if (hy < 0x00800000) { /* subnormal y */
+- for (iy = -126, i = hy<<8; i >= 0; i <<= 1)
+- iy -= 1;
+- } else
+- iy = (hy>>23) - 127;
++ }
+
+- /* set up {hx,lx}, {hy,ly} and align y to x */
+- if (ix >= -126)
+- hx = 0x00800000|(0x007fffff&hx);
+- else { /* subnormal x, shift x to normal */
+- n = -126-ix;
+- hx = hx<<n;
+- }
+- if (iy >= -126)
+- hy = 0x00800000|(0x007fffff&hy);
+- else { /* subnormal y, shift y to normal */
+- n = -126-iy;
+- hy = hy<<n;
++ /* normalize x and y */
++ if (!ex) {
++ for (i = uxi<<9; i>>31 == 0; ex--, i <<= 1);
++ uxi <<= -ex + 1;
++ } else {
++ uxi &= -1U >> 9;
++ uxi |= 1U << 23;
++ }
++ if (!ey) {
++ for (i = uy.i<<9; i>>31 == 0; ey--, i <<= 1);
++ uy.i <<= -ey + 1;
++ } else {
++ uy.i &= -1U >> 9;
++ uy.i |= 1U << 23;
+ }
+
+- /* fix point fmod */
+- n = ix - iy;
+- while (n--) {
+- hz = hx-hy;
+- if (hz<0)
+- hx = hx+hx;
+- else {
+- if(hz == 0) /* return sign(x)*0 */
+- return Zero[(uint32_t)sx>>31];
+- hx = hz+hz;
++ /* x mod y */
++ for (; ex > ey; ex--) {
++ i = uxi - uy.i;
++ if (i >> 31 == 0) {
++ if (i == 0)
++ return 0*x;
++ uxi = i;
+ }
++ uxi <<= 1;
++ }
++ i = uxi - uy.i;
++ if (i >> 31 == 0) {
++ if (i == 0)
++ return 0*x;
++ uxi = i;
+ }
+- hz = hx-hy;
+- if (hz >= 0)
+- hx = hz;
++ for (; uxi>>23 == 0; uxi <<= 1, ex--);
+
+- /* convert back to floating value and restore the sign */
+- if (hx == 0) /* return sign(x)*0 */
+- return Zero[(uint32_t)sx>>31];
+- while (hx < 0x00800000) { /* normalize x */
+- hx = hx+hx;
+- iy -= 1;
+- }
+- if (iy >= -126) { /* normalize output */
+- hx = ((hx-0x00800000)|((iy+127)<<23));
+- SET_FLOAT_WORD(x, hx|sx);
+- } else { /* subnormal output */
+- n = -126 - iy;
+- hx >>= n;
+- SET_FLOAT_WORD(x, hx|sx);
++ /* scale result up */
++ if (ex > 0) {
++ uxi -= 1U << 23;
++ uxi |= (uint32_t)ex << 23;
++ } else {
++ uxi >>= -ex + 1;
+ }
+- return x; /* exact output */
++ uxi |= sx;
++ ux.i = uxi;
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/fmodl.c musl-git/src/math/fmodl.c
+--- musl-0.9.13/src/math/fmodl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/fmodl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,15 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_fmodl.c */
+-/*-
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -18,141 +6,100 @@
+ return fmod(x, y);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#define BIAS (LDBL_MAX_EXP - 1)
+-
+-#if LDBL_MANL_SIZE > 32
+-typedef uint64_t manl_t;
+-#else
+-typedef uint32_t manl_t;
+-#endif
+-
+-#if LDBL_MANH_SIZE > 32
+-typedef uint64_t manh_t;
+-#else
+-typedef uint32_t manh_t;
+-#endif
+-
+-/*
+- * These macros add and remove an explicit integer bit in front of the
+- * fractional mantissa, if the architecture doesn't have such a bit by
+- * default already.
+- */
+-#ifdef LDBL_IMPLICIT_NBIT
+-#define SET_NBIT(hx) ((hx) | (1ULL << LDBL_MANH_SIZE))
+-#define HFRAC_BITS LDBL_MANH_SIZE
+-#else
+-#define SET_NBIT(hx) (hx)
+-#define HFRAC_BITS (LDBL_MANH_SIZE - 1)
+-#endif
+-
+-#define MANL_SHIFT (LDBL_MANL_SIZE - 1)
+-
+-static const long double Zero[] = {0.0, -0.0,};
+-
+-/*
+- * fmodl(x,y)
+- * Return x mod y in exact arithmetic
+- * Method: shift and subtract
+- *
+- * Assumptions:
+- * - The low part of the mantissa fits in a manl_t exactly.
+- * - The high part of the mantissa fits in an int64_t with enough room
+- * for an explicit integer bit in front of the fractional bits.
+- */
+ long double fmodl(long double x, long double y)
+ {
+- union IEEEl2bits ux, uy;
+- int64_t hx,hz; /* We need a carry bit even if LDBL_MANH_SIZE is 32. */
+- manh_t hy;
+- manl_t lx,ly,lz;
+- int ix,iy,n,sx;
+-
+- ux.e = x;
+- uy.e = y;
+- sx = ux.bits.sign;
++ union ldshape ux = {x}, uy = {y};
++ int ex = ux.i.se & 0x7fff;
++ int ey = uy.i.se & 0x7fff;
++ int sx = ux.i.se & 0x8000;
+
+- /* purge off exception values */
+- if ((uy.bits.exp|uy.bits.manh|uy.bits.manl) == 0 || /* y=0 */
+- ux.bits.exp == BIAS + LDBL_MAX_EXP || /* or x not finite */
+- (uy.bits.exp == BIAS + LDBL_MAX_EXP &&
+- ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0)) /* or y is NaN */
++ if (y == 0 || isnan(y) || ex == 0x7fff)
+ return (x*y)/(x*y);
+- if (ux.bits.exp <= uy.bits.exp) {
+- if (ux.bits.exp < uy.bits.exp ||
+- (ux.bits.manh<=uy.bits.manh &&
+- (ux.bits.manh<uy.bits.manh ||
+- ux.bits.manl<uy.bits.manl))) /* |x|<|y| return x or x-y */
+- return x;
+- if (ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl)
+- return Zero[sx]; /* |x| = |y| return x*0 */
+- }
+-
+- /* determine ix = ilogb(x) */
+- if (ux.bits.exp == 0) { /* subnormal x */
+- ux.e *= 0x1.0p512;
+- ix = ux.bits.exp - (BIAS + 512);
+- } else {
+- ix = ux.bits.exp - BIAS;
+- }
+-
+- /* determine iy = ilogb(y) */
+- if (uy.bits.exp == 0) { /* subnormal y */
+- uy.e *= 0x1.0p512;
+- iy = uy.bits.exp - (BIAS + 512);
+- } else {
+- iy = uy.bits.exp - BIAS;
+- }
+-
+- /* set up {hx,lx}, {hy,ly} and align y to x */
+- hx = SET_NBIT(ux.bits.manh);
+- hy = SET_NBIT(uy.bits.manh);
+- lx = ux.bits.manl;
+- ly = uy.bits.manl;
+-
+- /* fix point fmod */
+- n = ix - iy;
+-
+- while (n--) {
+- hz = hx-hy;
+- lz = lx-ly;
+- if (lx < ly)
+- hz -= 1;
+- if (hz < 0) {
+- hx = hx+hx+(lx>>MANL_SHIFT);
+- lx = lx+lx;
++ ux.i.se = ex;
++ uy.i.se = ey;
++ if (ux.f <= uy.f) {
++ if (ux.f == uy.f)
++ return 0*x;
++ return x;
++ }
++
++ /* normalize x and y */
++ if (!ex) {
++ ux.f *= 0x1p120f;
++ ex = ux.i.se - 120;
++ }
++ if (!ey) {
++ uy.f *= 0x1p120f;
++ ey = uy.i.se - 120;
++ }
++
++ /* x mod y */
++#if LDBL_MANT_DIG == 64
++ uint64_t i, mx, my;
++ mx = ux.i.m;
++ my = uy.i.m;
++ for (; ex > ey; ex--) {
++ i = mx - my;
++ if (mx >= my) {
++ if (i == 0)
++ return 0*x;
++ mx = 2*i;
++ } else if (2*mx < mx) {
++ mx = 2*mx - my;
+ } else {
+- if ((hz|lz)==0) /* return sign(x)*0 */
+- return Zero[sx];
+- hx = hz+hz+(lz>>MANL_SHIFT);
+- lx = lz+lz;
++ mx = 2*mx;
+ }
+ }
+- hz = hx-hy;
+- lz = lx-ly;
+- if (lx < ly)
+- hz -= 1;
+- if (hz >= 0) {
+- hx = hz;
+- lx = lz;
++ i = mx - my;
++ if (mx >= my) {
++ if (i == 0)
++ return 0*x;
++ mx = i;
++ }
++ for (; mx >> 63 == 0; mx *= 2, ex--);
++ ux.i.m = mx;
++#elif LDBL_MANT_DIG == 113
++ uint64_t hi, lo, xhi, xlo, yhi, ylo;
++ xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
++ yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
++ xlo = ux.i2.lo;
++ ylo = ux.i2.lo;
++ for (; ex > ey; ex--) {
++ hi = xhi - yhi;
++ lo = xlo - ylo;
++ if (xlo < ylo)
++ hi -= 1;
++ if (hi >> 63 == 0) {
++ if ((hi|lo) == 0)
++ return 0*x;
++ xhi = 2*hi + (lo>>63);
++ xlo = 2*lo;
++ } else {
++ xhi = 2*xhi + (xlo>>63);
++ xlo = 2*xlo;
++ }
+ }
++ hi = xhi - yhi;
++ lo = xlo - ylo;
++ if (xlo < ylo)
++ hi -= 1;
++ if (hi >> 63 == 0) {
++ if ((hi|lo) == 0)
++ return 0*x;
++ xhi = hi;
++ xlo = lo;
++ }
++ for (; xhi >> 48 == 0; xhi = 2*xhi + (xlo>>63), xlo = 2*xlo, ex--);
++ ux.i2.hi = xhi;
++ ux.i2.lo = xlo;
++#endif
+
+- /* convert back to floating value and restore the sign */
+- if ((hx|lx) == 0) /* return sign(x)*0 */
+- return Zero[sx];
+- while (hx < (1ULL<<HFRAC_BITS)) { /* normalize x */
+- hx = hx+hx+(lx>>MANL_SHIFT);
+- lx = lx+lx;
+- iy -= 1;
+- }
+- ux.bits.manh = hx; /* The mantissa is truncated here if needed. */
+- ux.bits.manl = lx;
+- if (iy < LDBL_MIN_EXP) {
+- ux.bits.exp = iy + (BIAS + 512);
+- ux.e *= 0x1p-512;
+- } else {
+- ux.bits.exp = iy + BIAS;
+- }
+- return ux.e; /* exact output */
++ /* scale result */
++ if (ex <= 0) {
++ ux.i.se = (ex+120)|sx;
++ ux.f *= 0x1p-120f;
++ } else
++ ux.i.se = ex|sx;
++ return ux.f;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/frexpl.c musl-git/src/math/frexpl.c
+--- musl-0.9.13/src/math/frexpl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/frexpl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,20 +1,20 @@
+-#include <math.h>
+-#include <stdint.h>
+-#include <float.h>
+-
+-#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-
+-/* This version is for 80-bit little endian long double */
++#include "libm.h"
+
++#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+ long double frexpl(long double x, int *e)
+ {
+- union { long double ld; uint16_t hw[5]; } y = { x };
+- int ee = y.hw[4]&0x7fff;
++ return frexp(x, e);
++}
++#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
++long double frexpl(long double x, int *e)
++{
++ union ldshape u = {x};
++ int ee = u.i.se & 0x7fff;
+
+ if (!ee) {
+ if (x) {
+- x = frexpl(x*0x1p64, e);
+- *e -= 64;
++ x = frexpl(x*0x1p120, e);
++ *e -= 120;
+ } else *e = 0;
+ return x;
+ } else if (ee == 0x7fff) {
+@@ -22,16 +22,8 @@
+ }
+
+ *e = ee - 0x3ffe;
+- y.hw[4] &= 0x8000;
+- y.hw[4] |= 0x3ffe;
+- return y.ld;
++ u.i.se &= 0x8000;
++ u.i.se |= 0x3ffe;
++ return u.f;
+ }
+-
+-#else
+-
+-long double frexpl(long double x, int *e)
+-{
+- return frexp(x, e);
+-}
+-
+ #endif
+diff -Nur musl-0.9.13/src/math/hypot.c musl-git/src/math/hypot.c
+--- musl-0.9.13/src/math/hypot.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/hypot.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,123 +1,67 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_hypot.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/* hypot(x,y)
+- *
+- * Method :
+- * If (assume round-to-nearest) z=x*x+y*y
+- * has error less than sqrt(2)/2 ulp, then
+- * sqrt(z) has error less than 1 ulp (exercise).
+- *
+- * So, compute sqrt(x*x+y*y) with some care as
+- * follows to get the error below 1 ulp:
+- *
+- * Assume x>y>0;
+- * (if possible, set rounding to round-to-nearest)
+- * 1. if x > 2y use
+- * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y
+- * where x1 = x with lower 32 bits cleared, x2 = x-x1; else
+- * 2. if x <= 2y use
+- * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y))
+- * where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1,
+- * y1= y with lower 32 bits chopped, y2 = y-y1.
+- *
+- * NOTE: scaling may be necessary if some argument is too
+- * large or too tiny
+- *
+- * Special cases:
+- * hypot(x,y) is INF if x or y is +INF or -INF; else
+- * hypot(x,y) is NAN if x or y is NAN.
+- *
+- * Accuracy:
+- * hypot(x,y) returns sqrt(x^2+y^2) with error less
+- * than 1 ulps (units in the last place)
+- */
++#include <math.h>
++#include <stdint.h>
++#include <float.h>
+
+-#include "libm.h"
++#if FLT_EVAL_METHOD > 1U && LDBL_MANT_DIG == 64
++#define SPLIT (0x1p32 + 1)
++#else
++#define SPLIT (0x1p27 + 1)
++#endif
++
++static void sq(double_t *hi, double_t *lo, double x)
++{
++ double_t xh, xl, xc;
++
++ xc = x*SPLIT;
++ xh = x - xc + xc;
++ xl = x - xh;
++ *hi = x*x;
++ *lo = xh*xh - *hi + 2*xh*xl + xl*xl;
++}
+
+ double hypot(double x, double y)
+ {
+- double a,b,t1,t2,y1,y2,w;
+- int32_t j,k,ha,hb;
++ union {double f; uint64_t i;} ux = {x}, uy = {y}, ut;
++ int ex, ey;
++ double_t hx, lx, hy, ly, z;
+
+- GET_HIGH_WORD(ha, x);
+- ha &= 0x7fffffff;
+- GET_HIGH_WORD(hb, y);
+- hb &= 0x7fffffff;
+- if (hb > ha) {
+- a = y;
+- b = x;
+- j=ha; ha=hb; hb=j;
+- } else {
+- a = x;
+- b = y;
++ /* arrange |x| >= |y| */
++ ux.i &= -1ULL>>1;
++ uy.i &= -1ULL>>1;
++ if (ux.i < uy.i) {
++ ut = ux;
++ ux = uy;
++ uy = ut;
+ }
+- a = fabs(a);
+- b = fabs(b);
+- if (ha - hb > 0x3c00000) /* x/y > 2**60 */
+- return a+b;
+- k = 0;
+- if (ha > 0x5f300000) { /* a > 2**500 */
+- if(ha >= 0x7ff00000) { /* Inf or NaN */
+- uint32_t low;
+- /* Use original arg order iff result is NaN; quieten sNaNs. */
+- w = fabs(x+0.0) - fabs(y+0.0);
+- GET_LOW_WORD(low, a);
+- if (((ha&0xfffff)|low) == 0) w = a;
+- GET_LOW_WORD(low, b);
+- if (((hb^0x7ff00000)|low) == 0) w = b;
+- return w;
+- }
+- /* scale a and b by 2**-600 */
+- ha -= 0x25800000; hb -= 0x25800000; k += 600;
+- SET_HIGH_WORD(a, ha);
+- SET_HIGH_WORD(b, hb);
+- }
+- if (hb < 0x20b00000) { /* b < 2**-500 */
+- if (hb <= 0x000fffff) { /* subnormal b or 0 */
+- uint32_t low;
+- GET_LOW_WORD(low, b);
+- if ((hb|low) == 0)
+- return a;
+- t1 = 0;
+- SET_HIGH_WORD(t1, 0x7fd00000); /* t1 = 2^1022 */
+- b *= t1;
+- a *= t1;
+- k -= 1022;
+- } else { /* scale a and b by 2^600 */
+- ha += 0x25800000; /* a *= 2^600 */
+- hb += 0x25800000; /* b *= 2^600 */
+- k -= 600;
+- SET_HIGH_WORD(a, ha);
+- SET_HIGH_WORD(b, hb);
+- }
+- }
+- /* medium size a and b */
+- w = a - b;
+- if (w > b) {
+- t1 = 0;
+- SET_HIGH_WORD(t1, ha);
+- t2 = a-t1;
+- w = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
+- } else {
+- a = a + a;
+- y1 = 0;
+- SET_HIGH_WORD(y1, hb);
+- y2 = b - y1;
+- t1 = 0;
+- SET_HIGH_WORD(t1, ha+0x00100000);
+- t2 = a - t1;
+- w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
++
++ /* special cases */
++ ex = ux.i>>52;
++ ey = uy.i>>52;
++ x = ux.f;
++ y = uy.f;
++ /* note: hypot(inf,nan) == inf */
++ if (ey == 0x7ff)
++ return y;
++ if (ex == 0x7ff || uy.i == 0)
++ return x;
++ /* note: hypot(x,y) ~= x + y*y/x/2 with inexact for small y/x */
++ /* 64 difference is enough for ld80 double_t */
++ if (ex - ey > 64)
++ return x + y;
++
++ /* precise sqrt argument in nearest rounding mode without overflow */
++ /* xh*xh must not overflow and xl*xl must not underflow in sq */
++ z = 1;
++ if (ex > 0x3ff+510) {
++ z = 0x1p700;
++ x *= 0x1p-700;
++ y *= 0x1p-700;
++ } else if (ey < 0x3ff-450) {
++ z = 0x1p-700;
++ x *= 0x1p700;
++ y *= 0x1p700;
+ }
+- if (k)
+- w = scalbn(w, k);
+- return w;
++ sq(&hx, &lx, x);
++ sq(&hy, &ly, y);
++ return z*sqrt(ly+lx+hy+hx);
+ }
+diff -Nur musl-0.9.13/src/math/hypotf.c musl-git/src/math/hypotf.c
+--- musl-0.9.13/src/math/hypotf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/hypotf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,86 +1,35 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_hypotf.c */
+-/*
+- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+- */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ float hypotf(float x, float y)
+ {
+- float a,b,t1,t2,y1,y2,w;
+- int32_t j,k,ha,hb;
++ union {float f; uint32_t i;} ux = {x}, uy = {y}, ut;
++ float_t z;
+
+- GET_FLOAT_WORD(ha,x);
+- ha &= 0x7fffffff;
+- GET_FLOAT_WORD(hb,y);
+- hb &= 0x7fffffff;
+- if (hb > ha) {
+- a = y;
+- b = x;
+- j=ha; ha=hb; hb=j;
+- } else {
+- a = x;
+- b = y;
+- }
+- a = fabsf(a);
+- b = fabsf(b);
+- if (ha - hb > 0xf000000) /* x/y > 2**30 */
+- return a+b;
+- k = 0;
+- if (ha > 0x58800000) { /* a > 2**50 */
+- if(ha >= 0x7f800000) { /* Inf or NaN */
+- /* Use original arg order iff result is NaN; quieten sNaNs. */
+- w = fabsf(x+0.0f) - fabsf(y+0.0f);
+- if (ha == 0x7f800000) w = a;
+- if (hb == 0x7f800000) w = b;
+- return w;
+- }
+- /* scale a and b by 2**-68 */
+- ha -= 0x22000000; hb -= 0x22000000; k += 68;
+- SET_FLOAT_WORD(a, ha);
+- SET_FLOAT_WORD(b, hb);
+- }
+- if (hb < 0x26800000) { /* b < 2**-50 */
+- if (hb <= 0x007fffff) { /* subnormal b or 0 */
+- if (hb == 0)
+- return a;
+- SET_FLOAT_WORD(t1, 0x7e800000); /* t1 = 2^126 */
+- b *= t1;
+- a *= t1;
+- k -= 126;
+- } else { /* scale a and b by 2^68 */
+- ha += 0x22000000; /* a *= 2^68 */
+- hb += 0x22000000; /* b *= 2^68 */
+- k -= 68;
+- SET_FLOAT_WORD(a, ha);
+- SET_FLOAT_WORD(b, hb);
+- }
++ ux.i &= -1U>>1;
++ uy.i &= -1U>>1;
++ if (ux.i < uy.i) {
++ ut = ux;
++ ux = uy;
++ uy = ut;
+ }
+- /* medium size a and b */
+- w = a - b;
+- if (w > b) {
+- SET_FLOAT_WORD(t1, ha&0xfffff000);
+- t2 = a - t1;
+- w = sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
+- } else {
+- a = a + a;
+- SET_FLOAT_WORD(y1, hb&0xfffff000);
+- y2 = b - y1;
+- SET_FLOAT_WORD(t1,(ha+0x00800000)&0xfffff000);
+- t2 = a - t1;
+- w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
++
++ x = ux.f;
++ y = uy.f;
++ if (uy.i == 0xff<<23)
++ return y;
++ if (ux.i >= 0xff<<23 || uy.i == 0 || ux.i - uy.i >= 25<<23)
++ return x + y;
++
++ z = 1;
++ if (ux.i >= (0x7f+60)<<23) {
++ z = 0x1p90f;
++ x *= 0x1p-90f;
++ y *= 0x1p-90f;
++ } else if (uy.i < (0x7f-60)<<23) {
++ z = 0x1p-90f;
++ x *= 0x1p90f;
++ y *= 0x1p90f;
+ }
+- if (k)
+- w = scalbnf(w, k);
+- return w;
++ return z*sqrtf((double)x*x + (double)y*y);
+ }
+diff -Nur musl-0.9.13/src/math/hypotl.c musl-git/src/math/hypotl.c
+--- musl-0.9.13/src/math/hypotl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/hypotl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,16 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_hypotl.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/* long double version of hypot(). See comments in hypot.c. */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -19,130 +6,61 @@
+ return hypot(x, y);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#define GET_LDBL_EXPSIGN(i, v) do { \
+- union IEEEl2bits uv; \
+- \
+- uv.e = v; \
+- i = uv.xbits.expsign; \
+-} while (0)
+-
+-#define GET_LDBL_MAN(h, l, v) do { \
+- union IEEEl2bits uv; \
+- \
+- uv.e = v; \
+- h = uv.bits.manh; \
+- l = uv.bits.manl; \
+-} while (0)
+-
+-#define SET_LDBL_EXPSIGN(v, i) do { \
+- union IEEEl2bits uv; \
+- \
+- uv.e = v; \
+- uv.xbits.expsign = i; \
+- v = uv.e; \
+-} while (0)
+-
+-#undef GET_HIGH_WORD
+-#define GET_HIGH_WORD(i, v) GET_LDBL_EXPSIGN(i, v)
+-#undef SET_HIGH_WORD
+-#define SET_HIGH_WORD(v, i) SET_LDBL_EXPSIGN(v, i)
+-
+-#define DESW(exp) (exp) /* delta expsign word */
+-#define ESW(exp) (MAX_EXP - 1 + (exp)) /* expsign word */
+-#define MANT_DIG LDBL_MANT_DIG
+-#define MAX_EXP LDBL_MAX_EXP
+-
+-#if LDBL_MANL_SIZE > 32
+-typedef uint64_t man_t;
+-#else
+-typedef uint32_t man_t;
++#if LDBL_MANT_DIG == 64
++#define SPLIT (0x1p32L+1)
++#elif LDBL_MANT_DIG == 113
++#define SPLIT (0x1p57L+1)
+ #endif
+
+-long double hypotl(long double x, long double y)
++static void sq(long double *hi, long double *lo, long double x)
+ {
+- long double a=x,b=y,t1,t2,y1,y2,w;
+- int32_t j,k,ha,hb;
++ long double xh, xl, xc;
++ xc = x*SPLIT;
++ xh = x - xc + xc;
++ xl = x - xh;
++ *hi = x*x;
++ *lo = xh*xh - *hi + 2*xh*xl + xl*xl;
++}
+
+- GET_HIGH_WORD(ha, x);
+- ha &= 0x7fff;
+- GET_HIGH_WORD(hb, y);
+- hb &= 0x7fff;
+- if (hb > ha) {
+- a = y;
+- b = x;
+- j=ha; ha=hb; hb=j;
+- } else {
+- a = x;
+- b = y;
+- }
+- a = fabsl(a);
+- b = fabsl(b);
+- if (ha - hb > DESW(MANT_DIG+7)) /* x/y > 2**(MANT_DIG+7) */
+- return a+b;
+- k = 0;
+- if (ha > ESW(MAX_EXP/2-12)) { /* a>2**(MAX_EXP/2-12) */
+- if (ha >= ESW(MAX_EXP)) { /* Inf or NaN */
+- man_t manh, manl;
+- /* Use original arg order iff result is NaN; quieten sNaNs. */
+- w = fabsl(x+0.0)-fabsl(y+0.0);
+- GET_LDBL_MAN(manh,manl,a);
+- if (manh == LDBL_NBIT && manl == 0) w = a;
+- GET_LDBL_MAN(manh,manl,b);
+- if (hb >= ESW(MAX_EXP) && manh == LDBL_NBIT && manl == 0) w = b;
+- return w;
+- }
+- /* scale a and b by 2**-(MAX_EXP/2+88) */
+- ha -= DESW(MAX_EXP/2+88); hb -= DESW(MAX_EXP/2+88);
+- k += MAX_EXP/2+88;
+- SET_HIGH_WORD(a, ha);
+- SET_HIGH_WORD(b, hb);
+- }
+- if (hb < ESW(-(MAX_EXP/2-12))) { /* b < 2**-(MAX_EXP/2-12) */
+- if (hb <= 0) { /* subnormal b or 0 */
+- man_t manh, manl;
+- GET_LDBL_MAN(manh,manl,b);
+- if ((manh|manl) == 0)
+- return a;
+- t1 = 0;
+- SET_HIGH_WORD(t1, ESW(MAX_EXP-2)); /* t1 = 2^(MAX_EXP-2) */
+- b *= t1;
+- a *= t1;
+- k -= MAX_EXP-2;
+- } else { /* scale a and b by 2^(MAX_EXP/2+88) */
+- ha += DESW(MAX_EXP/2+88);
+- hb += DESW(MAX_EXP/2+88);
+- k -= MAX_EXP/2+88;
+- SET_HIGH_WORD(a, ha);
+- SET_HIGH_WORD(b, hb);
+- }
+- }
+- /* medium size a and b */
+- w = a - b;
+- if (w > b) {
+- t1 = a;
+- union IEEEl2bits uv;
+- uv.e = t1; uv.bits.manl = 0; t1 = uv.e;
+- t2 = a-t1;
+- w = sqrtl(t1*t1-(b*(-b)-t2*(a+t1)));
++long double hypotl(long double x, long double y)
++{
++ union ldshape ux = {x}, uy = {y};
++ int ex, ey;
++ long double hx, lx, hy, ly, z;
++
++ ux.i.se &= 0x7fff;
++ uy.i.se &= 0x7fff;
++ if (ux.i.se < uy.i.se) {
++ ex = uy.i.se;
++ ey = ux.i.se;
++ x = uy.f;
++ y = ux.f;
+ } else {
+- a = a+a;
+- y1 = b;
+- union IEEEl2bits uv;
+- uv.e = y1; uv.bits.manl = 0; y1 = uv.e;
+- y2 = b - y1;
+- t1 = a;
+- uv.e = t1; uv.bits.manl = 0; t1 = uv.e;
+- t2 = a - t1;
+- w = sqrtl(t1*y1-(w*(-w)-(t1*y2+t2*b)));
++ ex = ux.i.se;
++ ey = uy.i.se;
++ x = ux.f;
++ y = uy.f;
+ }
+- if(k!=0) {
+- uint32_t high;
+- t1 = 1.0;
+- GET_HIGH_WORD(high, t1);
+- SET_HIGH_WORD(t1, high+DESW(k));
+- return t1*w;
++
++ if (ex == 0x7fff && isinf(y))
++ return y;
++ if (ex == 0x7fff || y == 0)
++ return x;
++ if (ex - ey > LDBL_MANT_DIG)
++ return x + y;
++
++ z = 1;
++ if (ex > 0x3fff+8000) {
++ z = 0x1p10000L;
++ x *= 0x1p-10000L;
++ y *= 0x1p-10000L;
++ } else if (ey < 0x3fff-8000) {
++ z = 0x1p-10000L;
++ x *= 0x1p10000L;
++ y *= 0x1p10000L;
+ }
+- return w;
++ sq(&hx, &lx, x);
++ sq(&hy, &ly, y);
++ return z*sqrtl(ly+lx+hy+hx);
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/i386/exp.s musl-git/src/math/i386/exp.s
+--- musl-0.9.13/src/math/i386/exp.s 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/i386/exp.s 2013-09-16 20:31:39.000000000 +0200
+@@ -95,42 +95,32 @@
+ .type exp2,@function
+ exp2:
+ fldl 4(%esp)
+-1: pushl $0x467ff000
+- flds (%esp) # 16380
+- xorl %eax,%eax
+- pushl $0x80000000
+- push %eax
+- fld %st(1)
+- fabs
+- fucomp %st(1)
+- fnstsw
+- fstp %st(0)
+- sahf
+- ja 3f # |x| > 16380
+- jp 2f # x is nan (avoid invalid except in fistp)
++1: sub $12,%esp
+ fld %st(0)
+- fistpl 8(%esp)
+- fildl 8(%esp)
+- fxch %st(1)
+- fsub %st(1)
+- mov $0x3fff,%eax
+- add %eax,8(%esp)
+- f2xm1
+- fld1
+- faddp # 2^(x-rint(x))
+- fldt (%esp) # 2^rint(x)
+- fmulp
+- fstp %st(1)
+-2: add $12,%esp
+- ret
+-
+-3: fld %st(0)
+ fstpt (%esp)
+- fld1
+ mov 8(%esp),%ax
+ and $0x7fff,%ax
+- cmp $0x7fff,%ax
+- je 1f # x = +-inf
++ cmp $0x3fff+13,%ax
++ jb 4f # |x| < 8192
++ cmp $0x3fff+15,%ax
++ jae 3f # |x| >= 32768
++ fsts (%esp)
++ cmpl $0xc67ff800,(%esp)
++ jb 2f # x > -16382
++ movl $0x5f000000,(%esp)
++ flds (%esp) # 0x1p63
++ fld %st(1)
++ fsub %st(1)
++ faddp
++ fucomp %st(1)
++ fnstsw
++ sahf
++ je 2f # x - 0x1p63 + 0x1p63 == x
++ movl $1,(%esp)
++ flds (%esp) # 0x1p-149
++ fdiv %st(1)
++ fstps (%esp) # raise underflow
++2: fld1
+ fld %st(1)
+ frndint
+ fxch %st(2)
+@@ -141,3 +131,19 @@
+ fstp %st(1)
+ add $12,%esp
+ ret
++3: xor %eax,%eax
++4: cmp $0x3fff-64,%ax
++ fld1
++ jb 1b # |x| < 0x1p-64
++ fstpt (%esp)
++ fistl 8(%esp)
++ fildl 8(%esp)
++ fsubrp %st(1)
++ addl $0x3fff,8(%esp)
++ f2xm1
++ fld1
++ faddp # 2^(x-rint(x))
++ fldt (%esp) # 2^rint(x)
++ fmulp
++ add $12,%esp
++ ret
+diff -Nur musl-0.9.13/src/math/ilogb.c musl-git/src/math/ilogb.c
+--- musl-0.9.13/src/math/ilogb.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/ilogb.c 2013-09-16 20:31:39.000000000 +0200
+@@ -3,22 +3,24 @@
+
+ int ilogb(double x)
+ {
+- union dshape u = {x};
+- int e = u.bits>>52 & 0x7ff;
++ #pragma STDC FENV_ACCESS ON
++ union {double f; uint64_t i;} u = {x};
++ uint64_t i = u.i;
++ int e = i>>52 & 0x7ff;
+
+ if (!e) {
+- u.bits <<= 12;
+- if (u.bits == 0) {
++ i <<= 12;
++ if (i == 0) {
+ FORCE_EVAL(0/0.0f);
+ return FP_ILOGB0;
+ }
+ /* subnormal x */
+- for (e = -0x3ff; u.bits < (uint64_t)1<<63; e--, u.bits<<=1);
++ for (e = -0x3ff; i>>63 == 0; e--, i<<=1);
+ return e;
+ }
+ if (e == 0x7ff) {
+ FORCE_EVAL(0/0.0f);
+- return u.bits<<12 ? FP_ILOGBNAN : INT_MAX;
++ return i<<12 ? FP_ILOGBNAN : INT_MAX;
+ }
+ return e - 0x3ff;
+ }
+diff -Nur musl-0.9.13/src/math/ilogbf.c musl-git/src/math/ilogbf.c
+--- musl-0.9.13/src/math/ilogbf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/ilogbf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -3,22 +3,24 @@
+
+ int ilogbf(float x)
+ {
+- union fshape u = {x};
+- int e = u.bits>>23 & 0xff;
++ #pragma STDC FENV_ACCESS ON
++ union {float f; uint32_t i;} u = {x};
++ uint32_t i = u.i;
++ int e = i>>23 & 0xff;
+
+ if (!e) {
+- u.bits <<= 9;
+- if (u.bits == 0) {
++ i <<= 9;
++ if (i == 0) {
+ FORCE_EVAL(0/0.0f);
+ return FP_ILOGB0;
+ }
+ /* subnormal x */
+- for (e = -0x7f; u.bits < (uint32_t)1<<31; e--, u.bits<<=1);
++ for (e = -0x7f; i>>31 == 0; e--, i<<=1);
+ return e;
+ }
+ if (e == 0xff) {
+ FORCE_EVAL(0/0.0f);
+- return u.bits<<9 ? FP_ILOGBNAN : INT_MAX;
++ return i<<9 ? FP_ILOGBNAN : INT_MAX;
+ }
+ return e - 0x7f;
+ }
+diff -Nur musl-0.9.13/src/math/ilogbl.c musl-git/src/math/ilogbl.c
+--- musl-0.9.13/src/math/ilogbl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/ilogbl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,9 +9,10 @@
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+ int ilogbl(long double x)
+ {
++ #pragma STDC FENV_ACCESS ON
+ union ldshape u = {x};
+- uint64_t m = u.bits.m;
+- int e = u.bits.exp;
++ uint64_t m = u.i.m;
++ int e = u.i.se & 0x7fff;
+
+ if (!e) {
+ if (m == 0) {
+@@ -19,13 +20,35 @@
+ return FP_ILOGB0;
+ }
+ /* subnormal x */
+- for (e = -0x3fff+1; m < (uint64_t)1<<63; e--, m<<=1);
++ for (e = -0x3fff+1; m>>63 == 0; e--, m<<=1);
+ return e;
+ }
+ if (e == 0x7fff) {
+ FORCE_EVAL(0/0.0f);
+- /* in ld80 msb is set in inf */
+- return m & (uint64_t)-1>>1 ? FP_ILOGBNAN : INT_MAX;
++ return m<<1 ? FP_ILOGBNAN : INT_MAX;
++ }
++ return e - 0x3fff;
++}
++#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
++int ilogbl(long double x)
++{
++ #pragma STDC FENV_ACCESS ON
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++
++ if (!e) {
++ if (x == 0) {
++ FORCE_EVAL(0/0.0f);
++ return FP_ILOGB0;
++ }
++ /* subnormal x */
++ x *= 0x1p120;
++ return ilogbl(x) - 120;
++ }
++ if (e == 0x7fff) {
++ FORCE_EVAL(0/0.0f);
++ u.i.se = 0;
++ return u.f ? FP_ILOGBNAN : INT_MAX;
+ }
+ return e - 0x3fff;
+ }
+diff -Nur musl-0.9.13/src/math/lgamma_r.c musl-git/src/math/lgamma_r.c
+--- musl-0.9.13/src/math/lgamma_r.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/lgamma_r.c 2013-09-16 20:31:39.000000000 +0200
+@@ -79,6 +79,7 @@
+ */
+
+ #include "libm.h"
++#include "libc.h"
+
+ static const double
+ two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+diff -Nur musl-0.9.13/src/math/lgammaf_r.c musl-git/src/math/lgammaf_r.c
+--- musl-0.9.13/src/math/lgammaf_r.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/lgammaf_r.c 2013-09-16 20:31:39.000000000 +0200
+@@ -14,6 +14,7 @@
+ */
+
+ #include "libm.h"
++#include "libc.h"
+
+ static const float
+ two23= 8.3886080000e+06, /* 0x4b000000 */
+diff -Nur musl-0.9.13/src/math/lgammal.c musl-git/src/math/lgammal.c
+--- musl-0.9.13/src/math/lgammal.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/lgammal.c 2013-09-16 20:31:39.000000000 +0200
+@@ -87,6 +87,7 @@
+
+ #define _GNU_SOURCE
+ #include "libm.h"
++#include "libc.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+ double __lgamma_r(double x, int *sg);
+@@ -202,13 +203,11 @@
+
+ static long double sin_pi(long double x)
+ {
++ union ldshape u = {x};
++ uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
+ long double y, z;
+- int n, ix;
+- uint32_t se, i0, i1;
++ int n;
+
+- GET_LDOUBLE_WORDS(se, i0, i1, x);
+- ix = se & 0x7fff;
+- ix = (ix << 16) | (i0 >> 16);
+ if (ix < 0x3ffd8000) /* 0.25 */
+ return sinl(pi * x);
+ y = -x; /* x is assume negative */
+@@ -229,8 +228,8 @@
+ } else {
+ if (ix < 0x403e8000) /* 2^63 */
+ z = y + two63; /* exact */
+- GET_LDOUBLE_WORDS(se, i0, i1, z);
+- n = i1 & 1;
++ u.f = z;
++ n = u.i.m & 1;
+ y = n;
+ n <<= 2;
+ }
+@@ -261,33 +260,28 @@
+
+ long double __lgammal_r(long double x, int *sg) {
+ long double t, y, z, nadj, p, p1, p2, q, r, w;
+- int i, ix;
+- uint32_t se, i0, i1;
++ union ldshape u = {x};
++ uint32_t ix = (u.i.se & 0x7fffU)<<16 | u.i.m>>48;
++ int sign = u.i.se >> 15;
++ int i;
+
+ *sg = 1;
+- GET_LDOUBLE_WORDS(se, i0, i1, x);
+- ix = se & 0x7fff;
+-
+- if ((ix | i0 | i1) == 0) {
+- if (se & 0x8000)
+- *sg = -1;
+- return 1.0 / fabsl(x);
+- }
+-
+- ix = (ix << 16) | (i0 >> 16);
+
+ /* purge off +-inf, NaN, +-0, and negative arguments */
+ if (ix >= 0x7fff0000)
+ return x * x;
+-
++ if (x == 0) {
++ *sg -= 2*sign;
++ return 1.0 / fabsl(x);
++ }
+ if (ix < 0x3fc08000) { /* |x|<2**-63, return -log(|x|) */
+- if (se & 0x8000) {
++ if (sign) {
+ *sg = -1;
+ return -logl(-x);
+ }
+ return -logl(x);
+ }
+- if (se & 0x8000) {
++ if (sign) {
+ t = sin_pi (x);
+ if (t == 0.0)
+ return 1.0 / fabsl(t); /* -integer */
+@@ -297,11 +291,7 @@
+ x = -x;
+ }
+
+- /* purge off 1 and 2 */
+- if ((((ix - 0x3fff8000) | i0 | i1) == 0) ||
+- (((ix - 0x40008000) | i0 | i1) == 0))
+- r = 0;
+- else if (ix < 0x40008000) { /* x < 2.0 */
++ if (ix < 0x40008000) { /* x < 2.0 */
+ if (ix <= 0x3ffee666) { /* 8.99993896484375e-1 */
+ /* lgamma(x) = lgamma(x+1) - log(x) */
+ r = -logl(x);
+@@ -380,7 +370,7 @@
+ r = (x - 0.5) * (t - 1.0) + w;
+ } else /* 2**66 <= x <= inf */
+ r = x * (logl(x) - 1.0);
+- if (se & 0x8000)
++ if (sign)
+ r = nadj - r;
+ return r;
+ }
+diff -Nur musl-0.9.13/src/math/log1p.c musl-git/src/math/log1p.c
+--- musl-0.9.13/src/math/log1p.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/log1p.c 2013-09-16 20:31:39.000000000 +0200
+@@ -122,7 +122,7 @@
+ return x+x;
+ if (k != 0) {
+ if (hx < 0x43400000) {
+- STRICT_ASSIGN(double, u, 1.0 + x);
++ u = 1 + x;
+ GET_HIGH_WORD(hu, u);
+ k = (hu>>20) - 1023;
+ c = k > 0 ? 1.0-(u-x) : x-(u-1.0); /* correction term */
+diff -Nur musl-0.9.13/src/math/log1pf.c musl-git/src/math/log1pf.c
+--- musl-0.9.13/src/math/log1pf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/log1pf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -61,7 +61,7 @@
+ return x+x;
+ if (k != 0) {
+ if (hx < 0x5a000000) {
+- STRICT_ASSIGN(float, u, 1.0f + x);
++ u = 1 + x;
+ GET_FLOAT_WORD(hu, u);
+ k = (hu>>23) - 127;
+ /* correction term */
+diff -Nur musl-0.9.13/src/math/logb.c musl-git/src/math/logb.c
+--- musl-0.9.13/src/math/logb.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/logb.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,4 +1,4 @@
+-#include "libm.h"
++#include <math.h>
+
+ /*
+ special cases:
+@@ -12,6 +12,6 @@
+ if (!isfinite(x))
+ return x * x;
+ if (x == 0)
+- return -1/(x+0);
++ return -1/(x*x);
+ return ilogb(x);
+ }
+diff -Nur musl-0.9.13/src/math/logbf.c musl-git/src/math/logbf.c
+--- musl-0.9.13/src/math/logbf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/logbf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,10 @@
+-#include "libm.h"
++#include <math.h>
+
+ float logbf(float x)
+ {
+ if (!isfinite(x))
+ return x * x;
+ if (x == 0)
+- return -1/(x+0);
++ return -1/(x*x);
+ return ilogbf(x);
+ }
+diff -Nur musl-0.9.13/src/math/logbl.c musl-git/src/math/logbl.c
+--- musl-0.9.13/src/math/logbl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/logbl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,4 +1,4 @@
+-#include "libm.h"
++#include <math.h>
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+ long double logbl(long double x)
+ {
+@@ -10,7 +10,7 @@
+ if (!isfinite(x))
+ return x * x;
+ if (x == 0)
+- return -1/(x+0);
++ return -1/(x*x);
+ return ilogbl(x);
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/modf.c musl-git/src/math/modf.c
+--- musl-0.9.13/src/math/modf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/modf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -2,36 +2,33 @@
+
+ double modf(double x, double *iptr)
+ {
+- union {double x; uint64_t n;} u = {x};
++ union {double f; uint64_t i;} u = {x};
+ uint64_t mask;
+- int e;
+-
+- e = (int)(u.n>>52 & 0x7ff) - 0x3ff;
++ int e = (int)(u.i>>52 & 0x7ff) - 0x3ff;
+
+ /* no fractional part */
+ if (e >= 52) {
+ *iptr = x;
+- if (e == 0x400 && u.n<<12 != 0) /* nan */
++ if (e == 0x400 && u.i<<12 != 0) /* nan */
+ return x;
+- u.n &= (uint64_t)1<<63;
+- return u.x;
++ u.i &= 1ULL<<63;
++ return u.f;
+ }
+
+ /* no integral part*/
+ if (e < 0) {
+- u.n &= (uint64_t)1<<63;
+- *iptr = u.x;
++ u.i &= 1ULL<<63;
++ *iptr = u.f;
+ return x;
+ }
+
+- mask = (uint64_t)-1>>12 >> e;
+- if ((u.n & mask) == 0) {
++ mask = -1ULL>>12>>e;
++ if ((u.i & mask) == 0) {
+ *iptr = x;
+- u.n &= (uint64_t)1<<63;
+- return u.x;
++ u.i &= 1ULL<<63;
++ return u.f;
+ }
+- u.n &= ~mask;
+- *iptr = u.x;
+- STRICT_ASSIGN(double, x, x - *iptr);
+- return x;
++ u.i &= ~mask;
++ *iptr = u.f;
++ return x - u.f;
+ }
+diff -Nur musl-0.9.13/src/math/modff.c musl-git/src/math/modff.c
+--- musl-0.9.13/src/math/modff.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/modff.c 2013-09-16 20:31:39.000000000 +0200
+@@ -2,36 +2,33 @@
+
+ float modff(float x, float *iptr)
+ {
+- union {float x; uint32_t n;} u = {x};
++ union {float f; uint32_t i;} u = {x};
+ uint32_t mask;
+- int e;
+-
+- e = (int)(u.n>>23 & 0xff) - 0x7f;
++ int e = (int)(u.i>>23 & 0xff) - 0x7f;
+
+ /* no fractional part */
+ if (e >= 23) {
+ *iptr = x;
+- if (e == 0x80 && u.n<<9 != 0) { /* nan */
++ if (e == 0x80 && u.i<<9 != 0) { /* nan */
+ return x;
+ }
+- u.n &= 0x80000000;
+- return u.x;
++ u.i &= 0x80000000;
++ return u.f;
+ }
+ /* no integral part */
+ if (e < 0) {
+- u.n &= 0x80000000;
+- *iptr = u.x;
++ u.i &= 0x80000000;
++ *iptr = u.f;
+ return x;
+ }
+
+ mask = 0x007fffff>>e;
+- if ((u.n & mask) == 0) {
++ if ((u.i & mask) == 0) {
+ *iptr = x;
+- u.n &= 0x80000000;
+- return u.x;
++ u.i &= 0x80000000;
++ return u.f;
+ }
+- u.n &= ~mask;
+- *iptr = u.x;
+- STRICT_ASSIGN(float, x, x - *iptr);
+- return x;
++ u.i &= ~mask;
++ *iptr = u.f;
++ return x - u.f;
+ }
+diff -Nur musl-0.9.13/src/math/modfl.c musl-git/src/math/modfl.c
+--- musl-0.9.13/src/math/modfl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/modfl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,40 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_modfl.c */
+-/*-
+- * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG>
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice, this list of conditions and the following disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+- * SUCH DAMAGE.
+- *
+- * Derived from s_modf.c, which has the following Copyright:
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -43,58 +6,46 @@
+ return modf(x, (double *)iptr);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#if LDBL_MANL_SIZE > 32
+-#define MASK ((uint64_t)-1)
+-#else
+-#define MASK ((uint32_t)-1)
++#if LDBL_MANT_DIG == 64
++#define TOINT 0x1p63
++#elif LDBL_MANT_DIG == 113
++#define TOINT 0x1p112
+ #endif
+-/* Return the last n bits of a word, representing the fractional part. */
+-#define GETFRAC(bits, n) ((bits) & ~(MASK << (n)))
+-/* The number of fraction bits in manh, not counting the integer bit */
+-#define HIBITS (LDBL_MANT_DIG - LDBL_MANL_SIZE)
+-
+-static const long double zero[] = { 0.0, -0.0 };
+-
+ long double modfl(long double x, long double *iptr)
+ {
+- union IEEEl2bits ux;
+- int e;
++ union ldshape u = {x};
++ uint64_t mask;
++ int e = (u.i.se & 0x7fff) - 0x3fff;
++ int s = u.i.se >> 15;
++ long double absx;
++ long double y;
+
+- ux.e = x;
+- e = ux.bits.exp - LDBL_MAX_EXP + 1;
+- if (e < HIBITS) { /* Integer part is in manh. */
+- if (e < 0) { /* |x|<1 */
+- *iptr = zero[ux.bits.sign];
+- return x;
+- }
+- if ((GETFRAC(ux.bits.manh, HIBITS - 1 - e)|ux.bits.manl) == 0) {
+- /* x is an integer. */
+- *iptr = x;
+- return zero[ux.bits.sign];
+- }
+- /* Clear all but the top e+1 bits. */
+- ux.bits.manh >>= HIBITS - 1 - e;
+- ux.bits.manh <<= HIBITS - 1 - e;
+- ux.bits.manl = 0;
+- *iptr = ux.e;
+- return x - ux.e;
+- } else if (e >= LDBL_MANT_DIG - 1) { /* x has no fraction part. */
++ /* no fractional part */
++ if (e >= LDBL_MANT_DIG-1) {
+ *iptr = x;
+- if (e == LDBL_MAX_EXP && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)) /* nan */
++ if (isnan(x))
+ return x;
+- return zero[ux.bits.sign];
+- } else { /* Fraction part is in manl. */
+- if (GETFRAC(ux.bits.manl, LDBL_MANT_DIG - 1 - e) == 0) {
+- /* x is integral. */
+- *iptr = x;
+- return zero[ux.bits.sign];
+- }
+- /* Clear all but the top e+1 bits. */
+- ux.bits.manl >>= LDBL_MANT_DIG - 1 - e;
+- ux.bits.manl <<= LDBL_MANT_DIG - 1 - e;
+- *iptr = ux.e;
+- return x - ux.e;
++ return s ? -0.0 : 0.0;
++ }
++
++ /* no integral part*/
++ if (e < 0) {
++ *iptr = s ? -0.0 : 0.0;
++ return x;
++ }
++
++ /* raises spurious inexact */
++ absx = s ? -x : x;
++ y = absx + TOINT - TOINT - absx;
++ if (y == 0) {
++ *iptr = x;
++ return s ? -0.0 : 0.0;
+ }
++ if (y > 0)
++ y -= 1;
++ if (s)
++ y = -y;
++ *iptr = x + y;
++ return -y;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/nextafter.c musl-git/src/math/nextafter.c
+--- musl-0.9.13/src/math/nextafter.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/nextafter.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,35 +1,31 @@
+ #include "libm.h"
+
+-#define SIGN ((uint64_t)1<<63)
+-
+ double nextafter(double x, double y)
+ {
+- union dshape ux, uy;
++ union {double f; uint64_t i;} ux={x}, uy={y};
+ uint64_t ax, ay;
+ int e;
+
+ if (isnan(x) || isnan(y))
+ return x + y;
+- ux.value = x;
+- uy.value = y;
+- if (ux.bits == uy.bits)
++ if (ux.i == uy.i)
+ return y;
+- ax = ux.bits & ~SIGN;
+- ay = uy.bits & ~SIGN;
++ ax = ux.i & -1ULL/2;
++ ay = uy.i & -1ULL/2;
+ if (ax == 0) {
+ if (ay == 0)
+ return y;
+- ux.bits = (uy.bits & SIGN) | 1;
+- } else if (ax > ay || ((ux.bits ^ uy.bits) & SIGN))
+- ux.bits--;
++ ux.i = (uy.i & 1ULL<<63) | 1;
++ } else if (ax > ay || ((ux.i ^ uy.i) & 1ULL<<63))
++ ux.i--;
+ else
+- ux.bits++;
+- e = ux.bits >> 52 & 0x7ff;
+- /* raise overflow if ux.value is infinite and x is finite */
++ ux.i++;
++ e = ux.i >> 52 & 0x7ff;
++ /* raise overflow if ux.f is infinite and x is finite */
+ if (e == 0x7ff)
+ FORCE_EVAL(x+x);
+- /* raise underflow if ux.value is subnormal or zero */
++ /* raise underflow if ux.f is subnormal or zero */
+ if (e == 0)
+- FORCE_EVAL(x*x + ux.value*ux.value);
+- return ux.value;
++ FORCE_EVAL(x*x + ux.f*ux.f);
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/nextafterf.c musl-git/src/math/nextafterf.c
+--- musl-0.9.13/src/math/nextafterf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/nextafterf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,34 +1,30 @@
+ #include "libm.h"
+
+-#define SIGN 0x80000000
+-
+ float nextafterf(float x, float y)
+ {
+- union fshape ux, uy;
++ union {float f; uint32_t i;} ux={x}, uy={y};
+ uint32_t ax, ay, e;
+
+ if (isnan(x) || isnan(y))
+ return x + y;
+- ux.value = x;
+- uy.value = y;
+- if (ux.bits == uy.bits)
++ if (ux.i == uy.i)
+ return y;
+- ax = ux.bits & ~SIGN;
+- ay = uy.bits & ~SIGN;
++ ax = ux.i & 0x7fffffff;
++ ay = uy.i & 0x7fffffff;
+ if (ax == 0) {
+ if (ay == 0)
+ return y;
+- ux.bits = (uy.bits & SIGN) | 1;
+- } else if (ax > ay || ((ux.bits ^ uy.bits) & SIGN))
+- ux.bits--;
++ ux.i = (uy.i & 0x80000000) | 1;
++ } else if (ax > ay || ((ux.i ^ uy.i) & 0x80000000))
++ ux.i--;
+ else
+- ux.bits++;
+- e = ux.bits & 0x7f800000;
+- /* raise overflow if ux.value is infinite and x is finite */
++ ux.i++;
++ e = ux.i & 0x7f800000;
++ /* raise overflow if ux.f is infinite and x is finite */
+ if (e == 0x7f800000)
+ FORCE_EVAL(x+x);
+- /* raise underflow if ux.value is subnormal or zero */
++ /* raise underflow if ux.f is subnormal or zero */
+ if (e == 0)
+- FORCE_EVAL(x*x + ux.value*ux.value);
+- return ux.value;
++ FORCE_EVAL(x*x + ux.f*ux.f);
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/nextafterl.c musl-git/src/math/nextafterl.c
+--- musl-0.9.13/src/math/nextafterl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/nextafterl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -6,7 +6,6 @@
+ return nextafter(x, y);
+ }
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+-#define MSB ((uint64_t)1<<63)
+ long double nextafterl(long double x, long double y)
+ {
+ union ldshape ux, uy;
+@@ -15,32 +14,32 @@
+ return x + y;
+ if (x == y)
+ return y;
+- ux.value = x;
++ ux.f = x;
+ if (x == 0) {
+- uy.value = y;
+- ux.bits.m = 1;
+- ux.bits.sign = uy.bits.sign;
+- } else if (x < y ^ ux.bits.sign) {
+- ux.bits.m++;
+- if ((ux.bits.m & ~MSB) == 0) {
+- ux.bits.m = MSB;
+- ux.bits.exp++;
++ uy.f = y;
++ ux.i.m = 1;
++ ux.i.se = uy.i.se & 0x8000;
++ } else if ((x < y) == !(ux.i.se & 0x8000)) {
++ ux.i.m++;
++ if (ux.i.m << 1 == 0) {
++ ux.i.m = 1ULL << 63;
++ ux.i.se++;
+ }
+ } else {
+- if ((ux.bits.m & ~MSB) == 0) {
+- ux.bits.exp--;
+- if (ux.bits.exp)
+- ux.bits.m = 0;
++ if (ux.i.m << 1 == 0) {
++ ux.i.se--;
++ if (ux.i.se)
++ ux.i.m = 0;
+ }
+- ux.bits.m--;
++ ux.i.m--;
+ }
+- /* raise overflow if ux.value is infinite and x is finite */
+- if (ux.bits.exp == 0x7fff)
++ /* raise overflow if ux is infinite and x is finite */
++ if ((ux.i.se & 0x7fff) == 0x7fff)
+ return x + x;
+- /* raise underflow if ux.value is subnormal or zero */
+- if (ux.bits.exp == 0)
+- FORCE_EVAL(x*x + ux.value*ux.value);
+- return ux.value;
++ /* raise underflow if ux is subnormal or zero */
++ if ((ux.i.se & 0x7fff) == 0)
++ FORCE_EVAL(x*x + ux.f*ux.f);
++ return ux.f;
+ }
+ #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
+ long double nextafterl(long double x, long double y)
+@@ -51,32 +50,26 @@
+ return x + y;
+ if (x == y)
+ return y;
+- ux.value = x;
++ ux.f = x;
+ if (x == 0) {
+- uy.value = y;
+- ux.bits.mlo = 1;
+- ux.bits.sign = uy.bits.sign;
+- } else if (x < y ^ ux.bits.sign) {
+- ux.bits.mlo++;
+- if (ux.bits.mlo == 0) {
+- ux.bits.mhi++;
+- if (ux.bits.mhi == 0)
+- ux.bits.exp++;
+- }
++ uy.f = y;
++ ux.i.lo = 1;
++ ux.i.se = uy.i.se & 0x8000;
++ } else if ((x < y) == !(ux.i.se & 0x8000)) {
++ ux.i2.lo++;
++ if (ux.i2.lo == 0)
++ ux.i2.hi++;
+ } else {
+- if (ux.bits.mlo == 0) {
+- if (ux.bits.mhi == 0)
+- ux.bits.exp--;
+- ux.bits.mhi--;
+- }
+- ux.bits.mlo--;
++ if (ux.i2.lo == 0)
++ ux.i2.hi--;
++ ux.i2.lo--;
+ }
+- /* raise overflow if ux.value is infinite and x is finite */
+- if (ux.bits.exp == 0x7fff)
++ /* raise overflow if ux is infinite and x is finite */
++ if ((ux.i.se & 0x7fff) == 0x7fff)
+ return x + x;
+- /* raise underflow if ux.value is subnormal or zero */
+- if (ux.bits.exp == 0)
+- FORCE_EVAL(x*x + ux.value*ux.value);
+- return ux.value;
++ /* raise underflow if ux is subnormal or zero */
++ if ((ux.i.se & 0x7fff) == 0)
++ FORCE_EVAL(x*x + ux.f*ux.f);
++ return ux.f;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/nexttoward.c musl-git/src/math/nexttoward.c
+--- musl-0.9.13/src/math/nexttoward.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/nexttoward.c 2013-09-16 20:31:39.000000000 +0200
+@@ -6,40 +6,37 @@
+ return nextafter(x, y);
+ }
+ #else
+-#define SIGN ((uint64_t)1<<63)
+-
+ double nexttoward(double x, long double y)
+ {
+- union dshape ux;
++ union {double f; uint64_t i;} ux = {x};
+ int e;
+
+ if (isnan(x) || isnan(y))
+ return x + y;
+ if (x == y)
+ return y;
+- ux.value = x;
+ if (x == 0) {
+- ux.bits = 1;
++ ux.i = 1;
+ if (signbit(y))
+- ux.bits |= SIGN;
++ ux.i |= 1ULL<<63;
+ } else if (x < y) {
+ if (signbit(x))
+- ux.bits--;
++ ux.i--;
+ else
+- ux.bits++;
++ ux.i++;
+ } else {
+ if (signbit(x))
+- ux.bits++;
++ ux.i++;
+ else
+- ux.bits--;
++ ux.i--;
+ }
+- e = ux.bits>>52 & 0x7ff;
+- /* raise overflow if ux.value is infinite and x is finite */
++ e = ux.i>>52 & 0x7ff;
++ /* raise overflow if ux.f is infinite and x is finite */
+ if (e == 0x7ff)
+ FORCE_EVAL(x+x);
+- /* raise underflow if ux.value is subnormal or zero */
++ /* raise underflow if ux.f is subnormal or zero */
+ if (e == 0)
+- FORCE_EVAL(x*x + ux.value*ux.value);
+- return ux.value;
++ FORCE_EVAL(x*x + ux.f*ux.f);
++ return ux.f;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/nexttowardf.c musl-git/src/math/nexttowardf.c
+--- musl-0.9.13/src/math/nexttowardf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/nexttowardf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -2,35 +2,34 @@
+
+ float nexttowardf(float x, long double y)
+ {
+- union fshape ux;
++ union {float f; uint32_t i;} ux = {x};
+ uint32_t e;
+
+ if (isnan(x) || isnan(y))
+ return x + y;
+ if (x == y)
+ return y;
+- ux.value = x;
+ if (x == 0) {
+- ux.bits = 1;
++ ux.i = 1;
+ if (signbit(y))
+- ux.bits |= 0x80000000;
++ ux.i |= 0x80000000;
+ } else if (x < y) {
+ if (signbit(x))
+- ux.bits--;
++ ux.i--;
+ else
+- ux.bits++;
++ ux.i++;
+ } else {
+ if (signbit(x))
+- ux.bits++;
++ ux.i++;
+ else
+- ux.bits--;
++ ux.i--;
+ }
+- e = ux.bits & 0x7f800000;
+- /* raise overflow if ux.value is infinite and x is finite */
++ e = ux.i & 0x7f800000;
++ /* raise overflow if ux.f is infinite and x is finite */
+ if (e == 0x7f800000)
+ FORCE_EVAL(x+x);
+- /* raise underflow if ux.value is subnormal or zero */
++ /* raise underflow if ux.f is subnormal or zero */
+ if (e == 0)
+- FORCE_EVAL(x*x + ux.value*ux.value);
+- return ux.value;
++ FORCE_EVAL(x*x + ux.f*ux.f);
++ return ux.f;
+ }
+diff -Nur musl-0.9.13/src/math/remainder.c musl-git/src/math/remainder.c
+--- musl-0.9.13/src/math/remainder.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/remainder.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,66 +1,7 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_remainder.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/* remainder(x,p)
+- * Return :
+- * returns x REM p = x - [x/p]*p as if in infinite
+- * precise arithmetic, where [x/p] is the (infinite bit)
+- * integer nearest x/p (in half way case choose the even one).
+- * Method :
+- * Based on fmod() return x-[x/p]chopped*p exactlp.
+- */
++#include <math.h>
+
+-#include "libm.h"
+-
+-double remainder(double x, double p)
++double remainder(double x, double y)
+ {
+- int32_t hx,hp;
+- uint32_t sx,lx,lp;
+- double p_half;
+-
+- EXTRACT_WORDS(hx, lx, x);
+- EXTRACT_WORDS(hp, lp, p);
+- sx = hx & 0x80000000;
+- hp &= 0x7fffffff;
+- hx &= 0x7fffffff;
+-
+- /* purge off exception values */
+- if ((hp|lp) == 0 || /* p = 0 */
+- hx >= 0x7ff00000 || /* x not finite */
+- (hp >= 0x7ff00000 && (hp-0x7ff00000 | lp) != 0)) /* p is NaN */
+- return (x*p)/(x*p);
+-
+- if (hp <= 0x7fdfffff)
+- x = fmod(x, p+p); /* now x < 2p */
+- if (((hx-hp)|(lx-lp)) == 0)
+- return 0.0*x;
+- x = fabs(x);
+- p = fabs(p);
+- if (hp < 0x00200000) {
+- if (x + x > p) {
+- x -= p;
+- if (x + x >= p)
+- x -= p;
+- }
+- } else {
+- p_half = 0.5*p;
+- if (x > p_half) {
+- x -= p;
+- if (x >= p_half)
+- x -= p;
+- }
+- }
+- GET_HIGH_WORD(hx, x);
+- if ((hx&0x7fffffff) == 0)
+- hx = 0;
+- SET_HIGH_WORD(x, hx^sx);
+- return x;
++ int q;
++ return remquo(x, y, &q);
+ }
+diff -Nur musl-0.9.13/src/math/remainderf.c musl-git/src/math/remainderf.c
+--- musl-0.9.13/src/math/remainderf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/remainderf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,59 +1,7 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/e_remainderf.c */
+-/*
+- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+- */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
++#include <math.h>
+
+-#include "libm.h"
+-
+-float remainderf(float x, float p)
++float remainderf(float x, float y)
+ {
+- int32_t hx,hp;
+- uint32_t sx;
+- float p_half;
+-
+- GET_FLOAT_WORD(hx, x);
+- GET_FLOAT_WORD(hp, p);
+- sx = hx & 0x80000000;
+- hp &= 0x7fffffff;
+- hx &= 0x7fffffff;
+-
+- /* purge off exception values */
+- if (hp == 0 || hx >= 0x7f800000 || hp > 0x7f800000) /* p = 0, x not finite, p is NaN */
+- return (x*p)/(x*p);
+-
+- if (hp <= 0x7effffff)
+- x = fmodf(x, p + p); /* now x < 2p */
+- if (hx - hp == 0)
+- return 0.0f*x;
+- x = fabsf(x);
+- p = fabsf(p);
+- if (hp < 0x01000000) {
+- if (x + x > p) {
+- x -= p;
+- if (x + x >= p)
+- x -= p;
+- }
+- } else {
+- p_half = 0.5f*p;
+- if (x > p_half) {
+- x -= p;
+- if (x >= p_half)
+- x -= p;
+- }
+- }
+- GET_FLOAT_WORD(hx, x);
+- if ((hx & 0x7fffffff) == 0)
+- hx = 0;
+- SET_FLOAT_WORD(x, hx ^ sx);
+- return x;
++ int q;
++ return remquof(x, y, &q);
+ }
+diff -Nur musl-0.9.13/src/math/remquo.c musl-git/src/math/remquo.c
+--- musl-0.9.13/src/math/remquo.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/remquo.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,171 +1,82 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_remquo.c */
+-/*-
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * Return the IEEE remainder and set *quo to the last n bits of the
+- * quotient, rounded to the nearest integer. We choose n=31 because
+- * we wind up computing all the integer bits of the quotient anyway as
+- * a side-effect of computing the remainder by the shift and subtract
+- * method. In practice, this is far more bits than are needed to use
+- * remquo in reduction algorithms.
+- */
+-
+-#include "libm.h"
+-
+-static const double Zero[] = {0.0, -0.0,};
++#include <math.h>
++#include <stdint.h>
+
+ double remquo(double x, double y, int *quo)
+ {
+- int32_t n,hx,hy,hz,ix,iy,sx,i;
+- uint32_t lx,ly,lz,q,sxy;
+-
+- EXTRACT_WORDS(hx, lx, x);
+- EXTRACT_WORDS(hy, ly, y);
+- sxy = (hx ^ hy) & 0x80000000;
+- sx = hx & 0x80000000; /* sign of x */
+- hx ^= sx; /* |x| */
+- hy &= 0x7fffffff; /* |y| */
++ union {double f; uint64_t i;} ux = {x}, uy = {y};
++ int ex = ux.i>>52 & 0x7ff;
++ int ey = uy.i>>52 & 0x7ff;
++ int sx = ux.i>>63;
++ int sy = uy.i>>63;
++ uint32_t q;
++ uint64_t i;
++ uint64_t uxi = ux.i;
+
+- /* purge off exception values */
+- if ((hy|ly) == 0 || hx >= 0x7ff00000 || /* y = 0, or x not finite */
+- (hy|((ly|-ly)>>31)) > 0x7ff00000) /* or y is NaN */
++ *quo = 0;
++ if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff)
+ return (x*y)/(x*y);
+- if (hx <= hy) {
+- if (hx < hy || lx < ly) { /* |x| < |y| return x or x-y */
+- q = 0;
+- goto fixup;
+- }
+- if (lx == ly) { /* |x| = |y| return x*0 */
+- *quo = sxy ? -1 : 1;
+- return Zero[(uint32_t)sx>>31];
+- }
+- }
++ if (ux.i<<1 == 0)
++ return x;
+
+- // FIXME: use ilogb?
+-
+- /* determine ix = ilogb(x) */
+- if (hx < 0x00100000) { /* subnormal x */
+- if (hx == 0) {
+- for (ix = -1043, i=lx; i>0; i<<=1) ix--;
+- } else {
+- for (ix = -1022, i=hx<<11; i>0; i<<=1) ix--;
+- }
+- } else
+- ix = (hx>>20) - 1023;
+-
+- /* determine iy = ilogb(y) */
+- if (hy < 0x00100000) { /* subnormal y */
+- if (hy == 0) {
+- for (iy = -1043, i=ly; i>0; i<<=1) iy--;
+- } else {
+- for (iy = -1022, i=hy<<11; i>0; i<<=1) iy--;
+- }
+- } else
+- iy = (hy>>20) - 1023;
+-
+- /* set up {hx,lx}, {hy,ly} and align y to x */
+- if (ix >= -1022)
+- hx = 0x00100000|(0x000fffff&hx);
+- else { /* subnormal x, shift x to normal */
+- n = -1022 - ix;
+- if (n <= 31) {
+- hx = (hx<<n)|(lx>>(32-n));
+- lx <<= n;
+- } else {
+- hx = lx<<(n-32);
+- lx = 0;
+- }
+- }
+- if (iy >= -1022)
+- hy = 0x00100000|(0x000fffff&hy);
+- else { /* subnormal y, shift y to normal */
+- n = -1022 - iy;
+- if (n <= 31) {
+- hy = (hy<<n)|(ly>>(32-n));
+- ly <<= n;
+- } else {
+- hy = ly<<(n-32);
+- ly = 0;
+- }
++ /* normalize x and y */
++ if (!ex) {
++ for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1);
++ uxi <<= -ex + 1;
++ } else {
++ uxi &= -1ULL >> 12;
++ uxi |= 1ULL << 52;
++ }
++ if (!ey) {
++ for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1);
++ uy.i <<= -ey + 1;
++ } else {
++ uy.i &= -1ULL >> 12;
++ uy.i |= 1ULL << 52;
+ }
+
+- /* fix point fmod */
+- n = ix - iy;
+ q = 0;
+- while (n--) {
+- hz = hx - hy;
+- lz = lx - ly;
+- if (lx < ly)
+- hz--;
+- if (hz < 0) {
+- hx = hx + hx + (lx>>31);
+- lx = lx + lx;
+- } else {
+- hx = hz + hz + (lz>>31);
+- lx = lz + lz;
++ if (ex < ey) {
++ if (ex+1 == ey)
++ goto end;
++ return x;
++ }
++
++ /* x mod y */
++ for (; ex > ey; ex--) {
++ i = uxi - uy.i;
++ if (i >> 63 == 0) {
++ uxi = i;
+ q++;
+ }
++ uxi <<= 1;
+ q <<= 1;
+ }
+- hz = hx - hy;
+- lz = lx - ly;
+- if (lx < ly)
+- hz--;
+- if (hz >= 0) {
+- hx = hz;
+- lx = lz;
++ i = uxi - uy.i;
++ if (i >> 63 == 0) {
++ uxi = i;
+ q++;
+ }
+-
+- /* convert back to floating value and restore the sign */
+- if ((hx|lx) == 0) { /* return sign(x)*0 */
+- q &= 0x7fffffff;
+- *quo = sxy ? -q : q;
+- return Zero[(uint32_t)sx>>31];
+- }
+- while (hx < 0x00100000) { /* normalize x */
+- hx = hx + hx + (lx>>31);
+- lx = lx + lx;
+- iy--;
+- }
+- if (iy >= -1022) { /* normalize output */
+- hx = (hx-0x00100000)|((iy+1023)<<20);
+- } else { /* subnormal output */
+- n = -1022 - iy;
+- if (n <= 20) {
+- lx = (lx>>n)|((uint32_t)hx<<(32-n));
+- hx >>= n;
+- } else if (n <= 31) {
+- lx = (hx<<(32-n))|(lx>>n);
+- hx = 0;
+- } else {
+- lx = hx>>(n-32);
+- hx = 0;
+- }
+- }
+-fixup:
+- INSERT_WORDS(x, hx, lx);
+- y = fabs(y);
+- if (y < 0x1p-1021) {
+- if (x + x > y || (x + x == y && (q & 1))) {
+- q++;
+- x -= y;
+- }
+- } else if (x > 0.5*y || (x == 0.5*y && (q & 1))) {
+- q++;
++ if (uxi == 0)
++ ex = -60;
++ else
++ for (; uxi>>52 == 0; uxi <<= 1, ex--);
++end:
++ /* scale result and decide between |x| and |x|-|y| */
++ if (ex > 0) {
++ uxi -= 1ULL << 52;
++ uxi |= (uint64_t)ex << 52;
++ } else {
++ uxi >>= -ex + 1;
++ }
++ ux.i = uxi;
++ x = ux.f;
++ if (sy)
++ y = -y;
++ if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
+ x -= y;
++ q++;
+ }
+- GET_HIGH_WORD(hx, x);
+- SET_HIGH_WORD(x, hx ^ sx);
+ q &= 0x7fffffff;
+- *quo = sxy ? -q : q;
+- return x;
++ *quo = sx^sy ? -(int)q : (int)q;
++ return sx ? -x : x;
+ }
+diff -Nur musl-0.9.13/src/math/remquof.c musl-git/src/math/remquof.c
+--- musl-0.9.13/src/math/remquof.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/remquof.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,126 +1,82 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_remquof.c */
+-/*-
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * Return the IEEE remainder and set *quo to the last n bits of the
+- * quotient, rounded to the nearest integer. We choose n=31 because
+- * we wind up computing all the integer bits of the quotient anyway as
+- * a side-effect of computing the remainder by the shift and subtract
+- * method. In practice, this is far more bits than are needed to use
+- * remquo in reduction algorithms.
+- */
+-
+-#include "libm.h"
+-
+-static const float Zero[] = {0.0, -0.0,};
++#include <math.h>
++#include <stdint.h>
+
+ float remquof(float x, float y, int *quo)
+ {
+- int32_t n,hx,hy,hz,ix,iy,sx,i;
+- uint32_t q,sxy;
++ union {float f; uint32_t i;} ux = {x}, uy = {y};
++ int ex = ux.i>>23 & 0xff;
++ int ey = uy.i>>23 & 0xff;
++ int sx = ux.i>>31;
++ int sy = uy.i>>31;
++ uint32_t q;
++ uint32_t i;
++ uint32_t uxi = ux.i;
+
+- GET_FLOAT_WORD(hx, x);
+- GET_FLOAT_WORD(hy, y);
+- sxy = (hx ^ hy) & 0x80000000;
+- sx = hx & 0x80000000; /* sign of x */
+- hx ^= sx; /* |x| */
+- hy &= 0x7fffffff; /* |y| */
+-
+- /* purge off exception values */
+- if (hy == 0 || hx >= 0x7f800000 || hy > 0x7f800000) /* y=0,NaN;or x not finite */
++ *quo = 0;
++ if (uy.i<<1 == 0 || isnan(y) || ex == 0xff)
+ return (x*y)/(x*y);
+- if (hx < hy) { /* |x| < |y| return x or x-y */
+- q = 0;
+- goto fixup;
+- } else if(hx==hy) { /* |x| = |y| return x*0*/
+- *quo = sxy ? -1 : 1;
+- return Zero[(uint32_t)sx>>31];
+- }
++ if (ux.i<<1 == 0)
++ return x;
+
+- /* determine ix = ilogb(x) */
+- if (hx < 0x00800000) { /* subnormal x */
+- for (ix = -126, i=hx<<8; i>0; i<<=1) ix--;
+- } else
+- ix = (hx>>23) - 127;
+-
+- /* determine iy = ilogb(y) */
+- if (hy < 0x00800000) { /* subnormal y */
+- for (iy = -126, i=hy<<8; i>0; i<<=1) iy--;
+- } else
+- iy = (hy>>23) - 127;
+-
+- /* set up {hx,lx}, {hy,ly} and align y to x */
+- if (ix >= -126)
+- hx = 0x00800000|(0x007fffff&hx);
+- else { /* subnormal x, shift x to normal */
+- n = -126 - ix;
+- hx <<= n;
+- }
+- if (iy >= -126)
+- hy = 0x00800000|(0x007fffff&hy);
+- else { /* subnormal y, shift y to normal */
+- n = -126 - iy;
+- hy <<= n;
++ /* normalize x and y */
++ if (!ex) {
++ for (i = uxi<<9; i>>31 == 0; ex--, i <<= 1);
++ uxi <<= -ex + 1;
++ } else {
++ uxi &= -1U >> 9;
++ uxi |= 1U << 23;
++ }
++ if (!ey) {
++ for (i = uy.i<<9; i>>31 == 0; ey--, i <<= 1);
++ uy.i <<= -ey + 1;
++ } else {
++ uy.i &= -1U >> 9;
++ uy.i |= 1U << 23;
+ }
+
+- /* fix point fmod */
+- n = ix - iy;
+ q = 0;
+- while (n--) {
+- hz = hx - hy;
+- if (hz < 0)
+- hx = hx << 1;
+- else {
+- hx = hz << 1;
++ if (ex < ey) {
++ if (ex+1 == ey)
++ goto end;
++ return x;
++ }
++
++ /* x mod y */
++ for (; ex > ey; ex--) {
++ i = uxi - uy.i;
++ if (i >> 31 == 0) {
++ uxi = i;
+ q++;
+ }
++ uxi <<= 1;
+ q <<= 1;
+ }
+- hz = hx - hy;
+- if (hz >= 0) {
+- hx = hz;
++ i = uxi - uy.i;
++ if (i >> 31 == 0) {
++ uxi = i;
+ q++;
+ }
+-
+- /* convert back to floating value and restore the sign */
+- if (hx == 0) { /* return sign(x)*0 */
+- q &= 0x7fffffff;
+- *quo = sxy ? -q : q;
+- return Zero[(uint32_t)sx>>31];
+- }
+- while (hx < 0x00800000) { /* normalize x */
+- hx <<= 1;
+- iy--;
+- }
+- if (iy >= -126) { /* normalize output */
+- hx = (hx-0x00800000)|((iy+127)<<23);
+- } else { /* subnormal output */
+- n = -126 - iy;
+- hx >>= n;
+- }
+-fixup:
+- SET_FLOAT_WORD(x,hx);
+- y = fabsf(y);
+- if (y < 0x1p-125f) {
+- if (x + x > y || (x + x == y && (q & 1))) {
+- q++;
+- x -= y;
+- }
+- } else if (x > 0.5f*y || (x == 0.5f*y && (q & 1))) {
+- q++;
++ if (uxi == 0)
++ ex = -30;
++ else
++ for (; uxi>>23 == 0; uxi <<= 1, ex--);
++end:
++ /* scale result and decide between |x| and |x|-|y| */
++ if (ex > 0) {
++ uxi -= 1U << 23;
++ uxi |= (uint32_t)ex << 23;
++ } else {
++ uxi >>= -ex + 1;
++ }
++ ux.i = uxi;
++ x = ux.f;
++ if (sy)
++ y = -y;
++ if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
+ x -= y;
++ q++;
+ }
+- GET_FLOAT_WORD(hx, x);
+- SET_FLOAT_WORD(x, hx ^ sx);
+ q &= 0x7fffffff;
+- *quo = sxy ? -q : q;
+- return x;
++ *quo = sx^sy ? -(int)q : (int)q;
++ return sx ? -x : x;
+ }
+diff -Nur musl-0.9.13/src/math/remquol.c musl-git/src/math/remquol.c
+--- musl-0.9.13/src/math/remquol.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/remquol.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,15 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_remquol.c */
+-/*-
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunSoft, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -18,177 +6,119 @@
+ return remquo(x, y, quo);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#define BIAS (LDBL_MAX_EXP - 1)
+-
+-#if LDBL_MANL_SIZE > 32
+-typedef uint64_t manl_t;
+-#else
+-typedef uint32_t manl_t;
+-#endif
+-
+-#if LDBL_MANH_SIZE > 32
+-typedef uint64_t manh_t;
+-#else
+-typedef uint32_t manh_t;
+-#endif
+-
+-/*
+- * These macros add and remove an explicit integer bit in front of the
+- * fractional mantissa, if the architecture doesn't have such a bit by
+- * default already.
+- */
+-#ifdef LDBL_IMPLICIT_NBIT
+-#define SET_NBIT(hx) ((hx) | (1ULL << LDBL_MANH_SIZE))
+-#define HFRAC_BITS LDBL_MANH_SIZE
+-#else
+-#define SET_NBIT(hx) (hx)
+-#define HFRAC_BITS (LDBL_MANH_SIZE - 1)
+-#endif
+-
+-#define MANL_SHIFT (LDBL_MANL_SIZE - 1)
+-
+-static const long double Zero[] = {0.0, -0.0};
+-
+-/*
+- * Return the IEEE remainder and set *quo to the last n bits of the
+- * quotient, rounded to the nearest integer. We choose n=31 because
+- * we wind up computing all the integer bits of the quotient anyway as
+- * a side-effect of computing the remainder by the shift and subtract
+- * method. In practice, this is far more bits than are needed to use
+- * remquo in reduction algorithms.
+- *
+- * Assumptions:
+- * - The low part of the mantissa fits in a manl_t exactly.
+- * - The high part of the mantissa fits in an int64_t with enough room
+- * for an explicit integer bit in front of the fractional bits.
+- */
+ long double remquol(long double x, long double y, int *quo)
+ {
+- union IEEEl2bits ux, uy;
+- int64_t hx,hz; /* We need a carry bit even if LDBL_MANH_SIZE is 32. */
+- manh_t hy;
+- manl_t lx,ly,lz;
+- int ix,iy,n,q,sx,sxy;
++ union ldshape ux = {x}, uy = {y};
++ int ex = ux.i.se & 0x7fff;
++ int ey = uy.i.se & 0x7fff;
++ int sx = ux.i.se >> 15;
++ int sy = uy.i.se >> 15;
++ uint32_t q;
+
+- ux.e = x;
+- uy.e = y;
+- sx = ux.bits.sign;
+- sxy = sx ^ uy.bits.sign;
+- ux.bits.sign = 0; /* |x| */
+- uy.bits.sign = 0; /* |y| */
+- x = ux.e;
+-
+- /* purge off exception values */
+- if ((uy.bits.exp|uy.bits.manh|uy.bits.manl)==0 || /* y=0 */
+- (ux.bits.exp == BIAS + LDBL_MAX_EXP) || /* or x not finite */
+- (uy.bits.exp == BIAS + LDBL_MAX_EXP &&
+- ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0)) /* or y is NaN */
++ *quo = 0;
++ if (y == 0 || isnan(y) || ex == 0x7fff)
+ return (x*y)/(x*y);
+- if (ux.bits.exp <= uy.bits.exp) {
+- if ((ux.bits.exp < uy.bits.exp) ||
+- (ux.bits.manh <= uy.bits.manh &&
+- (ux.bits.manh < uy.bits.manh ||
+- ux.bits.manl < uy.bits.manl))) {
+- q = 0;
+- goto fixup; /* |x|<|y| return x or x-y */
+- }
+- if (ux.bits.manh == uy.bits.manh && ux.bits.manl == uy.bits.manl) {
+- *quo = sxy ? -1 : 1;
+- return Zero[sx]; /* |x|=|y| return x*0*/
+- }
+- }
+-
+- /* determine ix = ilogb(x) */
+- if (ux.bits.exp == 0) { /* subnormal x */
+- ux.e *= 0x1.0p512;
+- ix = ux.bits.exp - (BIAS + 512);
+- } else {
+- ix = ux.bits.exp - BIAS;
+- }
++ if (x == 0)
++ return x;
+
+- /* determine iy = ilogb(y) */
+- if (uy.bits.exp == 0) { /* subnormal y */
+- uy.e *= 0x1.0p512;
+- iy = uy.bits.exp - (BIAS + 512);
+- } else {
+- iy = uy.bits.exp - BIAS;
++ /* normalize x and y */
++ if (!ex) {
++ ux.i.se = ex;
++ ux.f *= 0x1p120f;
++ ex = ux.i.se - 120;
++ }
++ if (!ey) {
++ uy.i.se = ey;
++ uy.f *= 0x1p120f;
++ ey = uy.i.se - 120;
+ }
+
+- /* set up {hx,lx}, {hy,ly} and align y to x */
+- hx = SET_NBIT(ux.bits.manh);
+- hy = SET_NBIT(uy.bits.manh);
+- lx = ux.bits.manl;
+- ly = uy.bits.manl;
+-
+- /* fix point fmod */
+- n = ix - iy;
+ q = 0;
+-
+- while (n--) {
+- hz = hx - hy;
+- lz = lx - ly;
+- if (lx < ly)
+- hz -= 1;
+- if (hz < 0) {
+- hx = hx + hx + (lx>>MANL_SHIFT);
+- lx = lx + lx;
+- } else {
+- hx = hz + hz + (lz>>MANL_SHIFT);
+- lx = lz + lz;
++ if (ex >= ey) {
++ /* x mod y */
++#if LDBL_MANT_DIG == 64
++ uint64_t i, mx, my;
++ mx = ux.i.m;
++ my = uy.i.m;
++ for (; ex > ey; ex--) {
++ i = mx - my;
++ if (mx >= my) {
++ mx = 2*i;
++ q++;
++ q <<= 1;
++ } else if (2*mx < mx) {
++ mx = 2*mx - my;
++ q <<= 1;
++ q++;
++ } else {
++ mx = 2*mx;
++ q <<= 1;
++ }
++ }
++ i = mx - my;
++ if (mx >= my) {
++ mx = i;
+ q++;
+ }
+- q <<= 1;
+- }
+- hz = hx - hy;
+- lz = lx - ly;
+- if (lx < ly)
+- hz -= 1;
+- if (hz >= 0) {
+- hx = hz;
+- lx = lz;
+- q++;
+- }
+-
+- /* convert back to floating value and restore the sign */
+- if ((hx|lx) == 0) { /* return sign(x)*0 */
+- q &= 0x7fffffff;
+- *quo = sxy ? -q : q;
+- return Zero[sx];
+- }
+- while (hx < (1ULL<<HFRAC_BITS)) { /* normalize x */
+- hx = hx + hx + (lx>>MANL_SHIFT);
+- lx = lx + lx;
+- iy -= 1;
+- }
+- ux.bits.manh = hx; /* The integer bit is truncated here if needed. */
+- ux.bits.manl = lx;
+- if (iy < LDBL_MIN_EXP) {
+- ux.bits.exp = iy + (BIAS + 512);
+- ux.e *= 0x1p-512;
+- } else {
+- ux.bits.exp = iy + BIAS;
+- }
+- ux.bits.sign = 0;
+- x = ux.e;
+-fixup:
+- y = fabsl(y);
+- if (y < LDBL_MIN * 2) {
+- if (x + x > y || (x + x == y && (q & 1))) {
++ if (mx == 0)
++ ex = -120;
++ else
++ for (; mx >> 63 == 0; mx *= 2, ex--);
++ ux.i.m = mx;
++#elif LDBL_MANT_DIG == 113
++ uint64_t hi, lo, xhi, xlo, yhi, ylo;
++ xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
++ yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
++ xlo = ux.i2.lo;
++ ylo = ux.i2.lo;
++ for (; ex > ey; ex--) {
++ hi = xhi - yhi;
++ lo = xlo - ylo;
++ if (xlo < ylo)
++ hi -= 1;
++ if (hi >> 63 == 0) {
++ xhi = 2*hi + (lo>>63);
++ xlo = 2*lo;
++ q++;
++ } else {
++ xhi = 2*xhi + (xlo>>63);
++ xlo = 2*xlo;
++ }
++ q <<= 1;
++ }
++ hi = xhi - yhi;
++ lo = xlo - ylo;
++ if (xlo < ylo)
++ hi -= 1;
++ if (hi >> 63 == 0) {
++ xhi = hi;
++ xlo = lo;
+ q++;
+- x-=y;
+ }
+- } else if (x > 0.5*y || (x == 0.5*y && (q & 1))) {
+- q++;
+- x-=y;
++ if ((xhi|xlo) == 0)
++ ex = -120;
++ else
++ for (; xhi >> 48 == 0; xhi = 2*xhi + (xlo>>63), xlo = 2*xlo, ex--);
++ ux.i2.hi = xhi;
++ ux.i2.lo = xlo;
++#endif
+ }
+
+- ux.e = x;
+- ux.bits.sign ^= sx;
+- x = ux.e;
+-
++ /* scale result and decide between |x| and |x|-|y| */
++ if (ex <= 0) {
++ ux.i.se = ex + 120;
++ ux.f *= 0x1p-120f;
++ } else
++ ux.i.se = ex;
++ x = ux.f;
++ if (sy)
++ y = -y;
++ if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
++ x -= y;
++ q++;
++ }
+ q &= 0x7fffffff;
+- *quo = sxy ? -q : q;
+- return x;
++ *quo = sx^sy ? -(int)q : (int)q;
++ return sx ? -x : x;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/rint.c musl-git/src/math/rint.c
+--- musl-0.9.13/src/math/rint.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/rint.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,90 +1,20 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_rint.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * rint(x)
+- * Return x rounded to integral value according to the prevailing
+- * rounding mode.
+- * Method:
+- * Using floating addition.
+- * Exception:
+- * Inexact flag raised if x not equal to rint(x).
+- */
+-
+-#include "libm.h"
+-
+-static const double
+-TWO52[2] = {
+- 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
+- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
+-};
++#include <math.h>
++#include <stdint.h>
+
+ double rint(double x)
+ {
+- int32_t i0,j0,sx;
+- uint32_t i,i1;
+- double w,t;
++ union {double f; uint64_t i;} u = {x};
++ int e = u.i>>52 & 0x7ff;
++ int s = u.i>>63;
++ double_t y;
+
+- EXTRACT_WORDS(i0, i1, x);
+- // FIXME: signed shift
+- sx = (i0>>31) & 1;
+- j0 = ((i0>>20)&0x7ff) - 0x3ff;
+- if (j0 < 20) {
+- if (j0 < 0) {
+- if (((i0&0x7fffffff)|i1) == 0)
+- return x;
+- i1 |= i0 & 0x0fffff;
+- i0 &= 0xfffe0000;
+- i0 |= ((i1|-i1)>>12) & 0x80000;
+- SET_HIGH_WORD(x, i0);
+- STRICT_ASSIGN(double, w, TWO52[sx] + x);
+- t = w - TWO52[sx];
+- GET_HIGH_WORD(i0, t);
+- SET_HIGH_WORD(t, (i0&0x7fffffff)|(sx<<31));
+- return t;
+- } else {
+- i = 0x000fffff>>j0;
+- if (((i0&i)|i1) == 0)
+- return x; /* x is integral */
+- i >>= 1;
+- if (((i0&i)|i1) != 0) {
+- /*
+- * Some bit is set after the 0.5 bit. To avoid the
+- * possibility of errors from double rounding in
+- * w = TWO52[sx]+x, adjust the 0.25 bit to a lower
+- * guard bit. We do this for all j0<=51. The
+- * adjustment is trickiest for j0==18 and j0==19
+- * since then it spans the word boundary.
+- */
+- if (j0 == 19)
+- i1 = 0x40000000;
+- else if (j0 == 18)
+- i1 = 0x80000000;
+- else
+- i0 = (i0 & ~i)|(0x20000>>j0);
+- }
+- }
+- } else if (j0 > 51) {
+- if (j0 == 0x400)
+- return x+x; /* inf or NaN */
+- return x; /* x is integral */
+- } else {
+- i = (uint32_t)0xffffffff>>(j0-20);
+- if ((i1&i) == 0)
+- return x; /* x is integral */
+- i >>= 1;
+- if ((i1&i) != 0)
+- i1 = (i1 & ~i)|(0x40000000>>(j0-20));
+- }
+- INSERT_WORDS(x, i0, i1);
+- STRICT_ASSIGN(double, w, TWO52[sx] + x);
+- return w - TWO52[sx];
++ if (e >= 0x3ff+52)
++ return x;
++ if (s)
++ y = (double)(x - 0x1p52) + 0x1p52;
++ else
++ y = (double)(x + 0x1p52) - 0x1p52;
++ if (y == 0)
++ return s ? -0.0 : 0;
++ return y;
+ }
+diff -Nur musl-0.9.13/src/math/rintf.c musl-git/src/math/rintf.c
+--- musl-0.9.13/src/math/rintf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/rintf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,48 +1,20 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_rintf.c */
+-/*
+- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+- */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-
+-#include "libm.h"
+-
+-static const float
+-TWO23[2] = {
+- 8.3886080000e+06, /* 0x4b000000 */
+- -8.3886080000e+06, /* 0xcb000000 */
+-};
++#include <math.h>
++#include <stdint.h>
+
+ float rintf(float x)
+ {
+- int32_t i0,j0,sx;
+- float w,t;
++ union {float f; uint32_t i;} u = {x};
++ int e = u.i>>23 & 0xff;
++ int s = u.i>>31;
++ float_t y;
+
+- GET_FLOAT_WORD(i0, x);
+- sx = (i0>>31) & 1;
+- j0 = ((i0>>23)&0xff) - 0x7f;
+- if (j0 < 23) {
+- if (j0 < 0) {
+- if ((i0&0x7fffffff) == 0)
+- return x;
+- STRICT_ASSIGN(float, w, TWO23[sx] + x);
+- t = w - TWO23[sx];
+- GET_FLOAT_WORD(i0, t);
+- SET_FLOAT_WORD(t, (i0&0x7fffffff)|(sx<<31));
+- return t;
+- }
+- STRICT_ASSIGN(float, w, TWO23[sx] + x);
+- return w - TWO23[sx];
+- }
+- if (j0 == 0x80)
+- return x+x; /* inf or NaN */
+- return x; /* x is integral */
++ if (e >= 0x7f+23)
++ return x;
++ if (s)
++ y = (float)(x - 0x1p23f) + 0x1p23f;
++ else
++ y = (float)(x + 0x1p23f) - 0x1p23f;
++ if (y == 0)
++ return s ? -0.0f : 0.0f;
++ return y;
+ }
+diff -Nur musl-0.9.13/src/math/rintl.c musl-git/src/math/rintl.c
+--- musl-0.9.13/src/math/rintl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/rintl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,30 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_rintl.c */
+-/*-
+- * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice, this list of conditions and the following disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+- * SUCH DAMAGE.
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -33,53 +6,26 @@
+ return rint(x);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-
+-#define BIAS (LDBL_MAX_EXP - 1)
+-
+-static const float
+-shift[2] = {
+ #if LDBL_MANT_DIG == 64
+- 0x1.0p63, -0x1.0p63
++#define TOINT 0x1p63
+ #elif LDBL_MANT_DIG == 113
+- 0x1.0p112, -0x1.0p112
++#define TOINT 0x1p112
+ #endif
+-};
+-static const float zero[2] = { 0.0, -0.0 };
+-
+ long double rintl(long double x)
+ {
+- union IEEEl2bits u;
+- uint32_t expsign;
+- int ex, sign;
+-
+- u.e = x;
+- expsign = u.xbits.expsign;
+- ex = expsign & 0x7fff;
+-
+- if (ex >= BIAS + LDBL_MANT_DIG - 1) {
+- if (ex == BIAS + LDBL_MAX_EXP)
+- return x + x; /* Inf, NaN, or unsupported format */
+- return x; /* finite and already an integer */
+- }
+- sign = expsign >> 15;
+-
+- /*
+- * The following code assumes that intermediate results are
+- * evaluated in long double precision. If they are evaluated in
+- * greater precision, double rounding may occur, and if they are
+- * evaluated in less precision (as on i386), results will be
+- * wildly incorrect.
+- */
+- x += shift[sign];
+- x -= shift[sign];
+-
+- /*
+- * If the result is +-0, then it must have the same sign as x, but
+- * the above calculation doesn't always give this. Fix up the sign.
+- */
+- if (ex < BIAS && x == 0.0)
+- return zero[sign];
+-
+- return x;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++ int s = u.i.se >> 15;
++ long double y;
++
++ if (e >= 0x3fff+LDBL_MANT_DIG-1)
++ return x;
++ if (s)
++ y = x - TOINT + TOINT;
++ else
++ y = x + TOINT - TOINT;
++ if (y == 0)
++ return 0*x;
++ return y;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/round.c musl-git/src/math/round.c
+--- musl-0.9.13/src/math/round.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/round.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,48 +1,28 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_round.c */
+-/*-
+- * Copyright (c) 2003, Steven G. Kargl
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice unmodified, this list of conditions, and the following
+- * disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#include <math.h>
++#include "libm.h"
+
+ double round(double x)
+ {
+- double t;
++ union {double f; uint64_t i;} u = {x};
++ int e = u.i >> 52 & 0x7ff;
++ double_t y;
+
+- if (!isfinite(x))
++ if (e >= 0x3ff+52)
+ return x;
+-
+- if (x >= 0.0) {
+- t = floor(x);
+- if (t - x <= -0.5)
+- t += 1.0;
+- return t;
+- } else {
+- t = floor(-x);
+- if (t + x <= -0.5)
+- t += 1.0;
+- return -t;
++ if (u.i >> 63)
++ x = -x;
++ if (e < 0x3ff-1) {
++ /* raise inexact if x!=0 */
++ FORCE_EVAL(x + 0x1p52);
++ return 0*u.f;
+ }
++ y = (double)(x + 0x1p52) - 0x1p52 - x;
++ if (y > 0.5)
++ y = y + x - 1;
++ else if (y <= -0.5)
++ y = y + x + 1;
++ else
++ y = y + x;
++ if (u.i >> 63)
++ y = -y;
++ return y;
+ }
+diff -Nur musl-0.9.13/src/math/roundf.c musl-git/src/math/roundf.c
+--- musl-0.9.13/src/math/roundf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/roundf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,48 +1,27 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_roundf.c */
+-/*-
+- * Copyright (c) 2003, Steven G. Kargl
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice unmodified, this list of conditions, and the following
+- * disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#include <math.h>
++#include "libm.h"
+
+ float roundf(float x)
+ {
+- float t;
++ union {float f; uint32_t i;} u = {x};
++ int e = u.i >> 23 & 0xff;
++ float_t y;
+
+- if (!isfinite(x))
++ if (e >= 0x7f+23)
+ return x;
+-
+- if (x >= 0.0) {
+- t = floorf(x);
+- if (t - x <= -0.5)
+- t += 1.0;
+- return t;
+- } else {
+- t = floorf(-x);
+- if (t + x <= -0.5)
+- t += 1.0;
+- return -t;
++ if (u.i >> 31)
++ x = -x;
++ if (e < 0x7f-1) {
++ FORCE_EVAL(x + 0x1p23f);
++ return 0*u.f;
+ }
++ y = (float)(x + 0x1p23f) - 0x1p23f - x;
++ if (y > 0.5f)
++ y = y + x - 1;
++ else if (y <= -0.5f)
++ y = y + x + 1;
++ else
++ y = y + x;
++ if (u.i >> 31)
++ y = -y;
++ return y;
+ }
+diff -Nur musl-0.9.13/src/math/roundl.c musl-git/src/math/roundl.c
+--- musl-0.9.13/src/math/roundl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/roundl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,56 +1,39 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_roundl.c */
+-/*-
+- * Copyright (c) 2003, Steven G. Kargl
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice unmodified, this list of conditions, and the following
+- * disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#include <math.h>
+-#include <float.h>
++#include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+ long double roundl(long double x)
+ {
+ return round(x);
+ }
+-#else
++#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
++#if LDBL_MANT_DIG == 64
++#define TOINT 0x1p63
++#elif LDBL_MANT_DIG == 113
++#define TOINT 0x1p112
++#endif
+ long double roundl(long double x)
+ {
+- long double t;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++ long double y;
+
+- if (!isfinite(x))
++ if (e >= 0x3fff+LDBL_MANT_DIG-1)
+ return x;
+-
+- if (x >= 0.0) {
+- t = floorl(x);
+- if (t - x <= -0.5)
+- t += 1.0;
+- return t;
+- } else {
+- t = floorl(-x);
+- if (t + x <= -0.5)
+- t += 1.0;
+- return -t;
++ if (u.i.se >> 15)
++ x = -x;
++ if (e < 0x3fff-1) {
++ FORCE_EVAL(x + TOINT);
++ return 0*u.f;
+ }
++ y = x + TOINT - TOINT - x;
++ if (y > 0.5)
++ y = y + x - 1;
++ else if (y <= -0.5)
++ y = y + x + 1;
++ else
++ y = y + x;
++ if (u.i.se >> 15)
++ y = -y;
++ return y;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/scalbn.c musl-git/src/math/scalbn.c
+--- musl-0.9.13/src/math/scalbn.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/scalbn.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,29 +1,31 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ double scalbn(double x, int n)
+ {
+- double scale;
++ union {double f; uint64_t i;} u;
++ double_t y = x;
+
+ if (n > 1023) {
+- x *= 0x1p1023;
++ y *= 0x1p1023;
+ n -= 1023;
+ if (n > 1023) {
+- x *= 0x1p1023;
++ y *= 0x1p1023;
+ n -= 1023;
+ if (n > 1023)
+ n = 1023;
+ }
+ } else if (n < -1022) {
+- x *= 0x1p-1022;
++ y *= 0x1p-1022;
+ n += 1022;
+ if (n < -1022) {
+- x *= 0x1p-1022;
++ y *= 0x1p-1022;
+ n += 1022;
+ if (n < -1022)
+ n = -1022;
+ }
+ }
+- INSERT_WORDS(scale, (uint32_t)(0x3ff+n)<<20, 0);
+- STRICT_ASSIGN(double, x, x * scale);
++ u.i = (uint64_t)(0x3ff+n)<<52;
++ x = y * u.f;
+ return x;
+ }
+diff -Nur musl-0.9.13/src/math/scalbnf.c musl-git/src/math/scalbnf.c
+--- musl-0.9.13/src/math/scalbnf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/scalbnf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,29 +1,31 @@
+-#include "libm.h"
++#include <math.h>
++#include <stdint.h>
+
+ float scalbnf(float x, int n)
+ {
+- float scale;
++ union {float f; uint32_t i;} u;
++ float_t y = x;
+
+ if (n > 127) {
+- x *= 0x1p127f;
++ y *= 0x1p127f;
+ n -= 127;
+ if (n > 127) {
+- x *= 0x1p127f;
++ y *= 0x1p127f;
+ n -= 127;
+ if (n > 127)
+ n = 127;
+ }
+ } else if (n < -126) {
+- x *= 0x1p-126f;
++ y *= 0x1p-126f;
+ n += 126;
+ if (n < -126) {
+- x *= 0x1p-126f;
++ y *= 0x1p-126f;
+ n += 126;
+ if (n < -126)
+ n = -126;
+ }
+ }
+- SET_FLOAT_WORD(scale, (uint32_t)(0x7f+n)<<23);
+- STRICT_ASSIGN(float, x, x * scale);
++ u.i = (uint32_t)(0x7f+n)<<23;
++ x = y * u.f;
+ return x;
+ }
+diff -Nur musl-0.9.13/src/math/scalbnl.c musl-git/src/math/scalbnl.c
+--- musl-0.9.13/src/math/scalbnl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/scalbnl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -8,7 +8,7 @@
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ long double scalbnl(long double x, int n)
+ {
+- union IEEEl2bits scale;
++ union ldshape u;
+
+ if (n > 16383) {
+ x *= 0x1p16383L;
+@@ -29,8 +29,8 @@
+ n = -16382;
+ }
+ }
+- scale.e = 1.0;
+- scale.bits.exp = 0x3fff + n;
+- return x * scale.e;
++ u.f = 1.0;
++ u.i.se = 0x3fff + n;
++ return x * u.f;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/signgam.c musl-git/src/math/signgam.c
+--- musl-0.9.13/src/math/signgam.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/signgam.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,4 +1,5 @@
+-#include "libm.h"
++#include <math.h>
++#include "libc.h"
+
+ int __signgam = 0;
+
+diff -Nur musl-0.9.13/src/math/sincosl.c musl-git/src/math/sincosl.c
+--- musl-0.9.13/src/math/sincosl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/sincosl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -9,25 +9,19 @@
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ void sincosl(long double x, long double *sin, long double *cos)
+ {
+- union IEEEl2bits u;
++ union ldshape u = {x};
+ unsigned n;
+ long double y[2], s, c;
+
+- u.e = x;
+- u.bits.sign = 0;
+-
+- /* x = nan or inf */
+- if (u.bits.exp == 0x7fff) {
++ u.i.se &= 0x7fff;
++ if (u.i.se == 0x7fff) {
+ *sin = *cos = x - x;
+ return;
+ }
+-
+- /* |x| < (double)pi/4 */
+- if (u.e < M_PI_4) {
+- /* |x| < 0x1p-64 */
+- if (u.bits.exp < 0x3fff - 64) {
++ if (u.f < M_PI_4) {
++ if (u.i.se < 0x3fff - LDBL_MANT_DIG) {
+ /* raise underflow if subnormal */
+- if (u.bits.exp == 0) FORCE_EVAL(x*0x1p-120f);
++ if (u.i.se == 0) FORCE_EVAL(x*0x1p-120f);
+ *sin = x;
+ /* raise inexact if x!=0 */
+ *cos = 1.0 + x;
+@@ -37,7 +31,6 @@
+ *cos = __cosl(x, 0);
+ return;
+ }
+-
+ n = __rem_pio2l(x, y);
+ s = __sinl(y[0], y[1], 1);
+ c = __cosl(y[0], y[1]);
+diff -Nur musl-0.9.13/src/math/sinhl.c musl-git/src/math/sinhl.c
+--- musl-0.9.13/src/math/sinhl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/sinhl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -8,10 +8,7 @@
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+ long double sinhl(long double x)
+ {
+- union {
+- long double f;
+- struct{uint64_t m; uint16_t se; uint16_t pad;} i;
+- } u = {.f = x};
++ union ldshape u = {x};
+ unsigned ex = u.i.se & 0x7fff;
+ long double h, t, absx;
+
+diff -Nur musl-0.9.13/src/math/sinl.c musl-git/src/math/sinl.c
+--- musl-0.9.13/src/math/sinl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/sinl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,31 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_sinl.c */
+-/*-
+- * Copyright (c) 2007 Steven G. Kargl
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice unmodified, this list of conditions, and the following
+- * disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -36,46 +8,34 @@
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ long double sinl(long double x)
+ {
+- union IEEEl2bits z;
++ union ldshape u = {x};
+ unsigned n;
+- long double y[2];
+- long double hi, lo;
+-
+- z.e = x;
+- z.bits.sign = 0;
++ long double y[2], hi, lo;
+
+- /* If x = NaN or Inf, then sin(x) = NaN. */
+- if (z.bits.exp == 0x7fff)
+- return (x - x) / (x - x);
+-
+- /* |x| < (double)pi/4 */
+- if (z.e < M_PI_4) {
+- /* |x| < 0x1p-64 */
+- if (z.bits.exp < 0x3fff - 64) {
++ u.i.se &= 0x7fff;
++ if (u.i.se == 0x7fff)
++ return x - x;
++ if (u.f < M_PI_4) {
++ if (u.i.se < 0x3fff - LDBL_MANT_DIG/2) {
+ /* raise inexact if x!=0 and underflow if subnormal */
+- FORCE_EVAL(z.bits.exp == 0 ? x/0x1p120f : x+0x1p120f);
++ FORCE_EVAL(u.i.se == 0 ? x*0x1p-120f : x+0x1p120f);
+ return x;
+ }
+ return __sinl(x, 0.0, 0);
+ }
+-
+ n = __rem_pio2l(x, y);
+ hi = y[0];
+ lo = y[1];
+ switch (n & 3) {
+ case 0:
+- hi = __sinl(hi, lo, 1);
+- break;
++ return __sinl(hi, lo, 1);
+ case 1:
+- hi = __cosl(hi, lo);
+- break;
++ return __cosl(hi, lo);
+ case 2:
+- hi = -__sinl(hi, lo, 1);
+- break;
++ return -__sinl(hi, lo, 1);
+ case 3:
+- hi = -__cosl(hi, lo);
+- break;
++ default:
++ return -__cosl(hi, lo);
+ }
+- return hi;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/sqrtl.c musl-git/src/math/sqrtl.c
+--- musl-0.9.13/src/math/sqrtl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/sqrtl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -2,8 +2,6 @@
+
+ long double sqrtl(long double x)
+ {
+- /* FIXME: implement sqrtl in C. At least this works for now on
+- * ARM (which uses ld64), the only arch without sqrtl asm
+- * that's supported so far. */
++ /* FIXME: implement in C, this is for LDBL_MANT_DIG == 64 only */
+ return sqrt(x);
+ }
+diff -Nur musl-0.9.13/src/math/tanhl.c musl-git/src/math/tanhl.c
+--- musl-0.9.13/src/math/tanhl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/tanhl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -8,10 +8,7 @@
+ #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
+ long double tanhl(long double x)
+ {
+- union {
+- long double f;
+- struct{uint64_t m; uint16_t se; uint16_t pad;} i;
+- } u = {.f = x};
++ union ldshape u = {x};
+ unsigned ex = u.i.se & 0x7fff;
+ unsigned sign = u.i.se & 0x8000;
+ uint32_t w;
+diff -Nur musl-0.9.13/src/math/tanl.c musl-git/src/math/tanl.c
+--- musl-0.9.13/src/math/tanl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/tanl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,35 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_tanl.c */
+-/*-
+- * Copyright (c) 2007 Steven G. Kargl
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- * 1. Redistributions of source code must retain the above copyright
+- * notice unmodified, this list of conditions, and the following
+- * disclaimer.
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in the
+- * documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-/*
+- * Limited testing on pseudorandom numbers drawn within [0:4e8] shows
+- * an accuracy of <= 1.5 ULP where 247024 values of x out of 40 million
+- * possibles resulted in tan(x) that exceeded 0.5 ULP (ie., 0.6%).
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -40,28 +8,21 @@
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+ long double tanl(long double x)
+ {
+- union IEEEl2bits z;
++ union ldshape u = {x};
+ long double y[2];
+ unsigned n;
+
+- z.e = x;
+- z.bits.sign = 0;
+-
+- /* If x = NaN or Inf, then tan(x) = NaN. */
+- if (z.bits.exp == 0x7fff)
+- return (x - x) / (x - x);
+-
+- /* |x| < (double)pi/4 */
+- if (z.e < M_PI_4) {
+- /* |x| < 0x1p-64 */
+- if (z.bits.exp < 0x3fff - 64) {
++ u.i.se &= 0x7fff;
++ if (u.i.se == 0x7fff)
++ return x - x;
++ if (u.f < M_PI_4) {
++ if (u.i.se < 0x3fff - LDBL_MANT_DIG/2) {
+ /* raise inexact if x!=0 and underflow if subnormal */
+- FORCE_EVAL(z.bits.exp == 0 ? x/0x1p120f : x+0x1p120f);
++ FORCE_EVAL(u.i.se == 0 ? x*0x1p-120f : x+0x1p120f);
+ return x;
+ }
+ return __tanl(x, 0, 0);
+ }
+-
+ n = __rem_pio2l(x, y);
+ return __tanl(y[0], y[1], n&1);
+ }
+diff -Nur musl-0.9.13/src/math/trunc.c musl-git/src/math/trunc.c
+--- musl-0.9.13/src/math/trunc.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/trunc.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,63 +1,19 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_trunc.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * trunc(x)
+- * Return x rounded toward 0 to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to trunc(x).
+- */
+-
+ #include "libm.h"
+
+-static const double huge = 1.0e300;
+-
+ double trunc(double x)
+ {
+- int32_t i0,i1,j0;
+- uint32_t i;
++ union {double f; uint64_t i;} u = {x};
++ int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12;
++ uint64_t m;
+
+- EXTRACT_WORDS(i0, i1, x);
+- j0 = ((i0>>20)&0x7ff) - 0x3ff;
+- if (j0 < 20) {
+- if (j0 < 0) { /* |x|<1, return 0*sign(x) */
+- /* raise inexact if x != 0 */
+- if (huge+x > 0.0) {
+- i0 &= 0x80000000U;
+- i1 = 0;
+- }
+- } else {
+- i = 0x000fffff>>j0;
+- if (((i0&i)|i1) == 0)
+- return x; /* x is integral */
+- /* raise inexact */
+- if (huge+x > 0.0) {
+- i0 &= ~i;
+- i1 = 0;
+- }
+- }
+- } else if (j0 > 51) {
+- if (j0 == 0x400)
+- return x + x; /* inf or NaN */
+- return x; /* x is integral */
+- } else {
+- i = (uint32_t)0xffffffff>>(j0-20);
+- if ((i1&i) == 0)
+- return x; /* x is integral */
+- /* raise inexact */
+- if (huge+x > 0.0)
+- i1 &= ~i;
+- }
+- INSERT_WORDS(x, i0, i1);
+- return x;
++ if (e >= 52 + 12)
++ return x;
++ if (e < 12)
++ e = 1;
++ m = -1ULL >> e;
++ if ((u.i & m) == 0)
++ return x;
++ FORCE_EVAL(x + 0x1p120f);
++ u.i &= ~m;
++ return u.f;
+ }
+diff -Nur musl-0.9.13/src/math/truncf.c musl-git/src/math/truncf.c
+--- musl-0.9.13/src/math/truncf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/truncf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,52 +1,19 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_truncf.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * truncf(x)
+- * Return x rounded toward 0 to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to truncf(x).
+- */
+-
+ #include "libm.h"
+
+-static const float huge = 1.0e30f;
+-
+ float truncf(float x)
+ {
+- int32_t i0,j0;
+- uint32_t i;
++ union {float f; uint32_t i;} u = {x};
++ int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9;
++ uint32_t m;
+
+- GET_FLOAT_WORD(i0, x);
+- j0 = ((i0>>23)&0xff) - 0x7f;
+- if (j0 < 23) {
+- if (j0 < 0) { /* |x|<1, return 0*sign(x) */
+- /* raise inexact if x != 0 */
+- if (huge+x > 0.0f)
+- i0 &= 0x80000000;
+- } else {
+- i = 0x007fffff>>j0;
+- if ((i0&i) == 0)
+- return x; /* x is integral */
+- /* raise inexact */
+- if (huge+x > 0.0f)
+- i0 &= ~i;
+- }
+- } else {
+- if (j0 == 0x80)
+- return x + x; /* inf or NaN */
+- return x; /* x is integral */
+- }
+- SET_FLOAT_WORD(x, i0);
+- return x;
++ if (e >= 23 + 9)
++ return x;
++ if (e < 9)
++ e = 1;
++ m = -1U >> e;
++ if ((u.i & m) == 0)
++ return x;
++ FORCE_EVAL(x + 0x1p120f);
++ u.i &= ~m;
++ return u.f;
+ }
+diff -Nur musl-0.9.13/src/math/truncl.c musl-git/src/math/truncl.c
+--- musl-0.9.13/src/math/truncl.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/truncl.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,23 +1,3 @@
+-/* origin: FreeBSD /usr/src/lib/msun/src/s_truncl.c */
+-/*
+- * ====================================================
+- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+- *
+- * Developed at SunPro, a Sun Microsystems, Inc. business.
+- * Permission to use, copy, modify, and distribute this
+- * software is freely granted, provided that this notice
+- * is preserved.
+- * ====================================================
+- */
+-/*
+- * truncl(x)
+- * Return x rounded toward 0 to integral value
+- * Method:
+- * Bit twiddling.
+- * Exception:
+- * Inexact flag raised if x not equal to truncl(x).
+- */
+-
+ #include "libm.h"
+
+ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+@@ -26,43 +6,31 @@
+ return trunc(x);
+ }
+ #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
+-#ifdef LDBL_IMPLICIT_NBIT
+-#define MANH_SIZE (LDBL_MANH_SIZE + 1)
+-#else
+-#define MANH_SIZE LDBL_MANH_SIZE
++#if LDBL_MANT_DIG == 64
++#define TOINT 0x1p63
++#elif LDBL_MANT_DIG == 113
++#define TOINT 0x1p112
+ #endif
+-
+-static const long double huge = 1.0e300;
+-static const float zero[] = { 0.0, -0.0 };
+-
+ long double truncl(long double x)
+ {
+- union IEEEl2bits u = { .e = x };
+- int e = u.bits.exp - LDBL_MAX_EXP + 1;
++ union ldshape u = {x};
++ int e = u.i.se & 0x7fff;
++ int s = u.i.se >> 15;
++ long double y;
+
+- if (e < MANH_SIZE - 1) {
+- if (e < 0) {
+- /* raise inexact if x != 0 */
+- if (huge + x > 0.0)
+- u.e = zero[u.bits.sign];
+- } else {
+- uint64_t m = ((1llu << MANH_SIZE) - 1) >> (e + 1);
+- if (((u.bits.manh & m) | u.bits.manl) == 0)
+- return x; /* x is integral */
+- /* raise inexact */
+- if (huge + x > 0.0) {
+- u.bits.manh &= ~m;
+- u.bits.manl = 0;
+- }
+- }
+- } else if (e < LDBL_MANT_DIG - 1) {
+- uint64_t m = (uint64_t)-1 >> (64 - LDBL_MANT_DIG + e + 1);
+- if ((u.bits.manl & m) == 0)
+- return x; /* x is integral */
+- /* raise inexact */
+- if (huge + x > 0.0)
+- u.bits.manl &= ~m;
++ if (e >= 0x3fff+LDBL_MANT_DIG-1)
++ return x;
++ if (e <= 0x3fff-1) {
++ FORCE_EVAL(x + 0x1p120f);
++ return x*0;
+ }
+- return u.e;
++ /* y = int(|x|) - |x|, where int(|x|) is an integer neighbor of |x| */
++ if (s)
++ x = -x;
++ y = x + TOINT - TOINT - x;
++ if (y > 0)
++ y -= 1;
++ x += y;
++ return s ? -x : x;
+ }
+ #endif
+diff -Nur musl-0.9.13/src/math/x86_64/ceill.s musl-git/src/math/x86_64/ceill.s
+--- musl-0.9.13/src/math/x86_64/ceill.s 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/x86_64/ceill.s 2013-09-16 20:31:39.000000000 +0200
+@@ -1 +1 @@
+-# see floor.s
++# see floorl.s
+diff -Nur musl-0.9.13/src/math/x86_64/exp2l.s musl-git/src/math/x86_64/exp2l.s
+--- musl-0.9.13/src/math/x86_64/exp2l.s 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/x86_64/exp2l.s 2013-09-16 20:31:39.000000000 +0200
+@@ -4,8 +4,18 @@
+ fldt 8(%rsp)
+ fldl2e
+ fmulp
++ movl $0xc2820000,-4(%rsp)
++ flds -4(%rsp)
++ fucomp %st(1)
++ fnstsw %ax
++ sahf
+ fld1
+- fld %st(1)
++ jb 1f
++ # x*log2e <= -65, return -1 without underflow
++ fstp %st(1)
++ fchs
++ ret
++1: fld %st(1)
+ fabs
+ fucom %st(1)
+ fnstsw %ax
+@@ -26,44 +36,32 @@
+ .type exp2l,@function
+ exp2l:
+ fldt 8(%rsp)
+-1: mov $0x467ff000,%eax
+- mov %eax,-16(%rsp)
+- mov $0x80000000,%eax
+- mov %eax,-20(%rsp)
+- xor %eax,%eax
+- mov %eax,-24(%rsp)
+- flds -16(%rsp) # 16380
++1: fld %st(0)
++ sub $16,%rsp
++ fstpt (%rsp)
++ mov 8(%rsp),%ax
++ and $0x7fff,%ax
++ cmp $0x3fff+13,%ax
++ jb 4f # |x| < 8192
++ cmp $0x3fff+15,%ax
++ jae 3f # |x| >= 32768
++ fsts (%rsp)
++ cmpl $0xc67ff800,(%rsp)
++ jb 2f # x > -16382
++ movl $0x5f000000,(%rsp)
++ flds (%rsp) # 0x1p63
+ fld %st(1)
+- fabs
+- fucom %st(1)
++ fsub %st(1)
++ faddp
++ fucomp %st(1)
+ fnstsw
+- fstp %st(0)
+- fstp %st(0)
+ sahf
+- ja 3f # |x| > 16380
+- jp 2f # x is nan (avoid invalid except in fistp)
+- fld %st(0)
+- fistpl -16(%rsp)
+- fildl -16(%rsp)
+- fxch %st(1)
+- fsub %st(1)
+- mov $0x3fff,%eax
+- add %eax,-16(%rsp)
+- f2xm1
+- fld1
+- faddp # 2^(x-rint(x))
+- fldt -24(%rsp) # 2^rint(x)
+- fmulp
+-2: fstp %st(1)
+- ret
+-
+-3: fld %st(0)
+- fstpt -24(%rsp)
+- fld1
+- mov -15(%rsp),%ax
+- and $0x7fff,%ax
+- cmp $0x7fff,%ax
+- je 1f # x = +-inf
++ je 2f # x - 0x1p63 + 0x1p63 == x
++ movl $1,(%rsp)
++ flds (%rsp) # 0x1p-149
++ fdiv %st(1)
++ fstps (%rsp) # raise underflow
++2: fld1
+ fld %st(1)
+ frndint
+ fxch %st(2)
+@@ -72,4 +70,21 @@
+ faddp # 2^(x-rint(x))
+ 1: fscale
+ fstp %st(1)
++ add $16,%rsp
++ ret
++3: xor %eax,%eax
++4: cmp $0x3fff-64,%ax
++ fld1
++ jb 1b # |x| < 0x1p-64
++ fstpt (%rsp)
++ fistl 8(%rsp)
++ fildl 8(%rsp)
++ fsubrp %st(1)
++ addl $0x3fff,8(%rsp)
++ f2xm1
++ fld1
++ faddp # 2^(x-rint(x))
++ fldt (%rsp) # 2^rint(x)
++ fmulp
++ add $16,%rsp
+ ret
+diff -Nur musl-0.9.13/src/math/x86_64/lrintl.s musl-git/src/math/x86_64/lrintl.s
+--- musl-0.9.13/src/math/x86_64/lrintl.s 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/x86_64/lrintl.s 2013-09-16 20:31:39.000000000 +0200
+@@ -2,6 +2,6 @@
+ .type lrintl,@function
+ lrintl:
+ fldt 8(%rsp)
+- fistpl 8(%rsp)
+- mov 8(%rsp),%eax
++ fistpll 8(%rsp)
++ mov 8(%rsp),%rax
+ ret
+diff -Nur musl-0.9.13/src/math/x86_64/truncl.s musl-git/src/math/x86_64/truncl.s
+--- musl-0.9.13/src/math/x86_64/truncl.s 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/math/x86_64/truncl.s 2013-09-16 20:31:39.000000000 +0200
+@@ -1 +1 @@
+-# see floor.s
++# see floorl.s
+diff -Nur musl-0.9.13/src/misc/realpath.c musl-git/src/misc/realpath.c
+--- musl-0.9.13/src/misc/realpath.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/misc/realpath.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,10 +1,11 @@
+ #include <stdlib.h>
+-#include <stdio.h>
+ #include <limits.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <unistd.h>
++#include <string.h>
++#include "syscall.h"
+
+ void __procfdname(char *, unsigned);
+
+@@ -14,38 +15,31 @@
+ ssize_t r;
+ struct stat st1, st2;
+ char buf[15+3*sizeof(int)];
+- int alloc = 0;
++ char tmp[PATH_MAX];
+
+ if (!filename) {
+ errno = EINVAL;
+ return 0;
+ }
+
+- fd = open(filename, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
++ fd = syscall(SYS_open, filename, O_PATH|O_NONBLOCK|O_CLOEXEC|O_LARGEFILE);
+ if (fd < 0) return 0;
+ __procfdname(buf, fd);
+
+- if (!resolved) {
+- alloc = 1;
+- resolved = malloc(PATH_MAX);
+- if (!resolved) return 0;
+- }
+-
+- r = readlink(buf, resolved, PATH_MAX-1);
++ r = readlink(buf, tmp, sizeof tmp - 1);
+ if (r < 0) goto err;
+- resolved[r] = 0;
++ tmp[r] = 0;
+
+ fstat(fd, &st1);
+- r = stat(resolved, &st2);
++ r = stat(tmp, &st2);
+ if (r<0 || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) {
+ if (!r) errno = ELOOP;
+ goto err;
+ }
+
+- close(fd);
+- return resolved;
++ __syscall(SYS_close, fd);
++ return resolved ? strcpy(resolved, tmp) : strdup(tmp);
+ err:
+- if (alloc) free(resolved);
+- close(fd);
++ __syscall(SYS_close, fd);
+ return 0;
+ }
+diff -Nur musl-0.9.13/src/mman/mprotect.c musl-git/src/mman/mprotect.c
+--- musl-0.9.13/src/mman/mprotect.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/mman/mprotect.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,5 +1,5 @@
+ #include <sys/mman.h>
+-#include <limits.h>
++#include "libc.h"
+ #include "syscall.h"
+
+ int mprotect(void *addr, size_t len, int prot)
+diff -Nur musl-0.9.13/src/signal/sigemptyset.c musl-git/src/signal/sigemptyset.c
+--- musl-0.9.13/src/signal/sigemptyset.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/signal/sigemptyset.c 2013-09-16 20:31:39.000000000 +0200
+@@ -4,6 +4,10 @@
+ int sigemptyset(sigset_t *set)
+ {
+ set->__bits[0] = 0;
+- if (sizeof(long)==4) set->__bits[1] = 0;
++ if (sizeof(long)==4 || _NSIG > 65) set->__bits[1] = 0;
++ if (sizeof(long)==4 && _NSIG > 65) {
++ set->__bits[2] = 0;
++ set->__bits[3] = 0;
++ }
+ return 0;
+ }
+diff -Nur musl-0.9.13/src/signal/sigfillset.c musl-git/src/signal/sigfillset.c
+--- musl-0.9.13/src/signal/sigfillset.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/signal/sigfillset.c 2013-09-16 20:31:39.000000000 +0200
+@@ -7,8 +7,13 @@
+ #if ULONG_MAX == 0xffffffff
+ set->__bits[0] = 0x7ffffffful;
+ set->__bits[1] = 0xfffffffcul;
++ if (_NSIG > 65) {
++ set->__bits[2] = 0xfffffffful;
++ set->__bits[3] = 0xfffffffful;
++ }
+ #else
+ set->__bits[0] = 0xfffffffc7ffffffful;
++ if (_NSIG > 65) set->__bits[1] = 0xfffffffffffffffful;
+ #endif
+ return 0;
+ }
+diff -Nur musl-0.9.13/src/signal/sigqueue.c musl-git/src/signal/sigqueue.c
+--- musl-0.9.13/src/signal/sigqueue.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/signal/sigqueue.c 2013-09-16 20:31:39.000000000 +0200
+@@ -3,6 +3,7 @@
+ #include <unistd.h>
+ #include <stdint.h>
+ #include "syscall.h"
++#include "pthread_impl.h"
+
+ int sigqueue(pid_t pid, int sig, const union sigval value)
+ {
+@@ -14,9 +15,9 @@
+ si.si_code = SI_QUEUE;
+ si.si_value = value;
+ si.si_uid = getuid();
+- pthread_sigmask(SIG_BLOCK, (void *)(uint64_t[1]){-1}, &set);
++ __block_app_sigs(&set);
+ si.si_pid = getpid();
+ r = syscall(SYS_rt_sigqueueinfo, pid, sig, &si);
+- pthread_sigmask(SIG_SETMASK, &set, 0);
++ __restore_sigs(&set);
+ return r;
+ }
+diff -Nur musl-0.9.13/src/stdio/popen.c musl-git/src/stdio/popen.c
+--- musl-0.9.13/src/stdio/popen.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/stdio/popen.c 2013-09-16 20:31:39.000000000 +0200
+@@ -39,7 +39,7 @@
+ * remove the close-on-exec flag in the child without also creating
+ * a file descriptor leak race condition in the parent. */
+ if (p[1-op] == 1-op) {
+- int tmp = fcntl(F_DUPFD_CLOEXEC, 1-op, 0);
++ int tmp = fcntl(1-op, F_DUPFD_CLOEXEC, 0);
+ if (tmp < 0) {
+ e = errno;
+ goto fail;
+diff -Nur musl-0.9.13/src/stdio/vfscanf.c musl-git/src/stdio/vfscanf.c
+--- musl-0.9.13/src/stdio/vfscanf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/stdio/vfscanf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -118,6 +118,8 @@
+ }
+
+ if (*p=='m') {
++ wcs = 0;
++ s = 0;
+ alloc = !!dest;
+ p++;
+ } else {
+diff -Nur musl-0.9.13/src/stdio/vfwscanf.c musl-git/src/stdio/vfwscanf.c
+--- musl-0.9.13/src/stdio/vfwscanf.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/stdio/vfwscanf.c 2013-09-16 20:31:39.000000000 +0200
+@@ -143,6 +143,8 @@
+ }
+
+ if (*p=='m') {
++ wcs = 0;
++ s = 0;
+ alloc = !!dest;
+ p++;
+ } else {
+diff -Nur musl-0.9.13/src/temp/__randname.c musl-git/src/temp/__randname.c
+--- musl-0.9.13/src/temp/__randname.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/temp/__randname.c 2013-09-16 20:31:39.000000000 +0200
+@@ -5,7 +5,7 @@
+ int __clock_gettime(clockid_t, struct timespec *);
+
+ /* This assumes that a check for the
+- template size has alrady been made */
++ template size has already been made */
+ char *__randname(char *template)
+ {
+ int i;
+diff -Nur musl-0.9.13/src/thread/mips/clone.s musl-git/src/thread/mips/clone.s
+--- musl-0.9.13/src/thread/mips/clone.s 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/thread/mips/clone.s 2013-09-16 20:31:39.000000000 +0200
+@@ -3,6 +3,7 @@
+ .type __clone,@function
+ __clone:
+ # Save function pointer and argument pointer on new thread stack
++ and $5, $5, -8
+ subu $5, $5, 16
+ sw $4, 0($5)
+ sw $7, 4($5)
+@@ -11,15 +12,18 @@
+ lw $6, 16($sp)
+ lw $7, 20($sp)
+ lw $9, 24($sp)
++ subu $sp, $sp, 16
+ sw $9, 16($sp)
+ li $2, 4120
+ syscall
+ beq $7, $0, 1f
+ nop
++ addu $sp, $sp, 16
+ jr $ra
+ subu $2, $0, $2
+ 1: beq $2, $0, 1f
+ nop
++ addu $sp, $sp, 16
+ jr $ra
+ nop
+ 1: lw $25, 0($sp)
+diff -Nur musl-0.9.13/src/thread/pthread_create.c musl-git/src/thread/pthread_create.c
+--- musl-0.9.13/src/thread/pthread_create.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/thread/pthread_create.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,5 +1,7 @@
++#define _GNU_SOURCE
+ #include "pthread_impl.h"
+ #include "stdio_impl.h"
++#include "libc.h"
+ #include <sys/mman.h>
+
+ static void dummy_0()
+@@ -127,7 +129,9 @@
+ size_t size, guard;
+ struct pthread *self = pthread_self(), *new;
+ unsigned char *map = 0, *stack = 0, *tsd = 0, *stack_limit;
+- unsigned flags = 0x7d8f00;
++ unsigned flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND
++ | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS
++ | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | CLONE_DETACHED;
+ int do_sched = 0;
+ pthread_attr_t attr = {0};
+
+@@ -197,7 +201,7 @@
+ new->tsd = (void *)tsd;
+ if (attr._a_detach) {
+ new->detached = 1;
+- flags -= 0x200000;
++ flags -= CLONE_CHILD_CLEARTID;
+ }
+ if (attr._a_sched) {
+ do_sched = new->startlock[0] = 1;
+diff -Nur musl-0.9.13/src/thread/pthread_getattr_np.c musl-git/src/thread/pthread_getattr_np.c
+--- musl-0.9.13/src/thread/pthread_getattr_np.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/thread/pthread_getattr_np.c 2013-09-16 20:31:39.000000000 +0200
+@@ -1,5 +1,6 @@
+ #define _GNU_SOURCE
+ #include "pthread_impl.h"
++#include "libc.h"
+ #include <sys/mman.h>
+
+ int pthread_getattr_np(pthread_t t, pthread_attr_t *a)
+diff -Nur musl-0.9.13/src/thread/synccall.c musl-git/src/thread/synccall.c
+--- musl-0.9.13/src/thread/synccall.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/thread/synccall.c 2013-09-16 20:31:39.000000000 +0200
+@@ -43,7 +43,7 @@
+ pthread_t self;
+ struct sigaction sa;
+ struct chain *next;
+- uint64_t oldmask;
++ sigset_t oldmask;
+
+ if (!libc.threads_minus_1) {
+ func(ctx);
+@@ -52,12 +52,12 @@
+
+ __inhibit_ptc();
+
+- __syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGALL_SET,
+- &oldmask, _NSIG/8);
++ __block_all_sigs(&oldmask);
+
+ sem_init(&chaindone, 0, 0);
+ sem_init(&chainlock, 0, 1);
+ chainlen = 0;
++ head = 0;
+ callback = func;
+ context = ctx;
+
+@@ -70,6 +70,10 @@
+ sigqueue(self->pid, SIGSYNCCALL, (union sigval){0});
+ while (sem_wait(&chaindone));
+
++ sa.sa_flags = 0;
++ sa.sa_handler = SIG_IGN;
++ __libc_sigaction(SIGSYNCCALL, &sa, 0);
++
+ for (cur=head; cur; cur=cur->next) {
+ sem_post(&cur->sem);
+ while (sem_wait(&cur->sem2));
+@@ -81,12 +85,7 @@
+ sem_post(&cur->sem);
+ }
+
+- sa.sa_flags = 0;
+- sa.sa_handler = SIG_IGN;
+- __libc_sigaction(SIGSYNCCALL, &sa, 0);
+-
+- __syscall(SYS_rt_sigprocmask, SIG_SETMASK,
+- &oldmask, 0, _NSIG/8);
++ __restore_sigs(&oldmask);
+
+ __release_ptc();
+ }
+diff -Nur musl-0.9.13/src/unistd/faccessat.c musl-git/src/unistd/faccessat.c
+--- musl-0.9.13/src/unistd/faccessat.c 2013-08-30 23:30:53.000000000 +0200
++++ musl-git/src/unistd/faccessat.c 2013-09-16 20:31:39.000000000 +0200
+@@ -19,7 +19,7 @@
+ __syscall(SYS_exit, 1);
+ ret = __syscall(SYS_faccessat, c->fd, c->filename, c->amode, 0);
+ __syscall(SYS_write, c->p, &ret, sizeof ret);
+- __syscall(SYS_exit, 0);
++ return 0;
+ }
+
+ int faccessat(int fd, const char *filename, int amode, int flag)