summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2013-05-26 01:02:55 +0300
committerRoman Yeryomin <roman@advem.lv>2013-05-26 01:02:55 +0300
commit342045a35b1981a89e4bc80842b10c065e1050da (patch)
tree4140720b20e8d641c11da882010d6130a75fef21 /tools
parent7338133dde8238afce34676214b494c8db96689b (diff)
parent1a116ce7818ecee5d167a9c0ebb1a0feca9120e6 (diff)
Merge trunk into realtek-unstable
Conflicts: Config.in feeds.conf.default package/base-files/files/etc/hotplug2-common.rules package/network/config/netifd/files/etc/init.d/network
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile16
-rw-r--r--tools/b43-tools/Makefile6
-rw-r--r--tools/b43-tools/patches/003-brcmsmac-lcn-ucode.patch22
-rw-r--r--tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch27
-rw-r--r--tools/bison/Makefile10
-rw-r--r--tools/bison/patches/000-relocatable.patch18
-rw-r--r--tools/bison/patches/010-intl-stub-compat.patch8
-rw-r--r--tools/bison/patches/100-fix-gets-removal.patch17
-rw-r--r--tools/ccache/Makefile6
-rw-r--r--tools/cmake/Makefile6
-rw-r--r--tools/e2fsprogs/Makefile6
-rw-r--r--tools/e2fsprogs/patches/003-openbsd-compat.patch24
-rw-r--r--tools/e2fsprogs/patches/004-freebsd-compat.patch13
-rw-r--r--tools/firmware-utils/src/csysimg.h1
-rw-r--r--tools/firmware-utils/src/mkcameofw.c84
-rw-r--r--tools/firmware-utils/src/mkcsysimg.c1
-rw-r--r--tools/firmware-utils/src/mkdapimg.c39
-rw-r--r--tools/firmware-utils/src/mkfwimage2.c2
-rw-r--r--tools/firmware-utils/src/mktplinkfw.c55
-rw-r--r--tools/flex/Makefile6
-rw-r--r--tools/gmp/Makefile8
-rw-r--r--tools/gmp/patches/000-OE-amd64.patch14
-rw-r--r--tools/gmp/patches/000-OE-configure.patch199
-rw-r--r--tools/include/endian.h5
-rw-r--r--tools/include/getline.h2
-rw-r--r--tools/ipkg-utils/patches/210-remove_field_checks.patch36
-rw-r--r--tools/mkimage/Makefile12
-rw-r--r--tools/mkimage/patches/010-freebsd-ulong-fix.patch4
-rw-r--r--tools/mkimage/patches/020-openbsd_fixes.patch18
-rw-r--r--tools/mkimage/patches/030-allow-to-use-different-magic.patch6
-rw-r--r--tools/mkimage/patches/040-include_order.patch14
-rw-r--r--tools/mkimage/patches/050-image_h_portability.patch31
-rw-r--r--tools/mkimage/patches/060-remove_kernel_includes.patch35
-rw-r--r--tools/mkimage/patches/100-dtc-binary.patch86
-rw-r--r--tools/mklibs/Makefile8
-rw-r--r--tools/mklibs/patches/001-compile.patch8
-rw-r--r--tools/mpfr/Makefile6
-rw-r--r--tools/mpfr/patches/000-upstream_cumulative.patch1945
-rw-r--r--tools/mpfr/patches/001-no_tests.patch26
-rw-r--r--tools/mpfr/patches/001-only_src.patch22
-rw-r--r--tools/mtools/Makefile3
-rw-r--r--tools/patch/Makefile18
-rw-r--r--tools/quilt/Makefile6
-rw-r--r--tools/sed/Makefile6
-rw-r--r--tools/squashfs4/patches/180-openbsd_compat.patch26
-rw-r--r--tools/upx/Makefile3
-rw-r--r--tools/yaffs2/patches/110-openbsd-compat.patch14
47 files changed, 602 insertions, 2326 deletions
diff --git a/tools/Makefile b/tools/Makefile
index 9a0e14823..1d65e50ba 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -15,7 +15,7 @@ tools-y += gmp mpfr mpc libelf
endif
tools-y += m4 libtool autoconf automake flex bison pkg-config sed mklibs
tools-y += sstrip ipkg-utils genext2fs e2fsprogs mtd-utils mkimage
-tools-y += firmware-utils patch-image quilt yaffs2 flock padjffs2
+tools-y += firmware-utils patch-image patch quilt yaffs2 flock padjffs2
tools-y += mm-macros xorg-macros xfce-macros missing-macros xz cmake scons
tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2
tools-$(CONFIG_powerpc) += upx
@@ -58,6 +58,7 @@ $(curdir)/ppl/compile := $(curdir)/gmp/install
$(curdir)/cloog/compile := $(curdir)/ppl/install
$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/install $(curdir)/xz/install
$(curdir)/mkimage/compile := $(curdir)/sed/install
+$(curdir)/mklibs/compile := $(curdir)/automake/install
$(curdir)/qemu/compile := $(curdir)/e2fsprogs/install
$(curdir)/upslug2/compile := $(curdir)/automake/install
$(curdir)/mm-macros/compile := $(curdir)/automake/install
@@ -118,6 +119,8 @@ $(STAGING_DIR_HOST)/bin/stat: $(STAGING_DIR)/.prepared
ln -s `which stat` $@; \
elif gstat --version > /dev/null 2>&1; then \
ln -s `which gstat` $@; \
+ elif gnustat --version > /dev/null 2>&1; then \
+ ln -s `which gnustat` $@; \
else \
echo "GNU stat not found"; \
false; \
@@ -127,9 +130,14 @@ $(eval $(call PrepareCommand,find,gfind find))
$(eval $(call PrepareCommand,md5sum,gmd5sum md5sum $(SCRIPT_DIR)/md5sum))
$(eval $(call PrepareCommand,cp,gcp cp))
$(eval $(call PrepareCommand,seq,gseq seq))
-$(eval $(call PrepareCommand,python,python2 python))
-
-$(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat seq python)
+$(eval $(call PrepareCommand,python,python2 python2.7 python))
+$(eval $(call PrepareCommand,awk,gawk awk))
+$(eval $(call PrepareCommand,getopt,gnugetopt /usr/local/bin/getopt getopt))
+$(eval $(call PrepareCommand,grep,ggrep grep))
+$(eval $(call PrepareCommand,tar,gtar tar))
+$(eval $(call PrepareCommand,diff,gdiff diff))
+
+$(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat seq python awk getopt grep tar diff)
$(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps)
$(curdir)//compile = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps)
diff --git a/tools/b43-tools/Makefile b/tools/b43-tools/Makefile
index d58a20e6a..e25bfc23c 100644
--- a/tools/b43-tools/Makefile
+++ b/tools/b43-tools/Makefile
@@ -8,14 +8,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=b43-tools
-PKG_VERSION:=016
+PKG_VERSION:=017
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=git://git.bues.ch/b43-tools.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
-PKG_SOURCE_VERSION:=38267954aae73659de271c67e6892c744b47f3d8
-PKG_MIRROR_MD5SUM:=50ca3c763ee21ee213addd17cf1c1b86
+PKG_SOURCE_VERSION:=691cd291afdb3dbfcf6b9624f8f4bd068af153d0
+#PKG_MIRROR_MD5SUM:=50ca3c763ee21ee213addd17cf1c1b86
HOST_BUILD_DIR=$(BUILD_DIR_HOST)/$(PKG_NAME)
include $(INCLUDE_DIR)/host-build.mk
diff --git a/tools/b43-tools/patches/003-brcmsmac-lcn-ucode.patch b/tools/b43-tools/patches/003-brcmsmac-lcn-ucode.patch
deleted file mode 100644
index 12966a558..000000000
--- a/tools/b43-tools/patches/003-brcmsmac-lcn-ucode.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/fwcutter/fwcutter.c b/fwcutter/fwcutter.c
-index 6f5788c..e9082f9 100644
---- a/fwcutter/fwcutter.c
-+++ b/fwcutter/fwcutter.c
-@@ -449,7 +449,7 @@ static int brcmsmac_name_to_idx(const char *name)
- return D11N0INITVALS16;
- } else if (strcmp("ucode16_mimo", name) == 0) {
- return D11UCODE_OVERSIGHT16_MIMO;
-- } else if (strcmp("ucode24_mimo", name) == 0) {
-+ } else if (strcmp("ucode24_lcn", name) == 0) {
- return D11UCODE_OVERSIGHT24_LCN;
- }
- return 0;
-@@ -459,7 +459,7 @@ static int brcmsmac_name_to_size_idx(const char *name)
- {
- if (strcmp("ucode16_mimo", name) == 0) {
- return D11UCODE_OVERSIGHT16_MIMOSZ;
-- } else if (strcmp("ucode24_mimo", name) == 0) {
-+ } else if (strcmp("ucode24_lcn", name) == 0) {
- return D11UCODE_OVERSIGHT24_LCNSZ;
- }
- return 0;
diff --git a/tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch b/tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch
new file mode 100644
index 000000000..fc0553d6b
--- /dev/null
+++ b/tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch
@@ -0,0 +1,27 @@
+--- a/assembler/Makefile
++++ b/assembler/Makefile
+@@ -30,7 +30,7 @@ BIN = b43-asm.bin
+ SRCS = parser.c scanner.c main.c initvals.c util.c args.c
+
+ # YACC related CFLAGS
+-CFLAGS += -DYYSTYPE="void *" -DYYERROR_VERBOSE -DYYDEBUG -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Wno-unused
++CFLAGS += -DYYSTYPE="void *" -DYYERROR_VERBOSE -DYYDEBUG=1 -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Wno-unused
+
+ .SUFFIXES:
+ .PHONY: all install clean distclean
+diff --git a/assembler/main.c b/assembler/main.c
+index afca996..a62a15e 100644
+--- a/assembler/main.c
++++ b/assembler/main.c
+@@ -1260,7 +1260,7 @@ static void initialize(void)
+ {
+ INIT_LIST_HEAD(&infile.sl);
+ INIT_LIST_HEAD(&infile.ivals);
+-#ifdef YYDEBUG
++#if YYDEBUG
+ if (IS_INSANE_DEBUG)
+ yydebug = 1;
+ else
+--
+1.7.10.4
+
diff --git a/tools/bison/Makefile b/tools/bison/Makefile
index ef705227e..d20d1c03c 100644
--- a/tools/bison/Makefile
+++ b/tools/bison/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008-2012 OpenWrt.org
+# Copyright (C) 2008-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,12 +7,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bison
-PKG_VERSION:=2.5
+PKG_VERSION:=2.7
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/$(PKG_NAME)
-PKG_MD5SUM:=9dba20116b13fc61a0846b0058fbe004
-PKG_CAT:=bzcat
+PKG_MD5SUM:=234cdfac99257cf99ac4a03c898f37b9
+PKG_CAT:=xzcat
HOST_BUILD_PARALLEL:=1
diff --git a/tools/bison/patches/000-relocatable.patch b/tools/bison/patches/000-relocatable.patch
index 50dca6d33..47c0ae8ba 100644
--- a/tools/bison/patches/000-relocatable.patch
+++ b/tools/bison/patches/000-relocatable.patch
@@ -3,18 +3,18 @@
@@ -81,6 +81,7 @@ MOSTLYCLEANFILES = yacc
yacc:
- echo '#! /bin/sh' >$@
-+ echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@
- echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
- chmod a+x $@
+ $(AM_V_GEN)echo '#! /bin/sh' >$@
++ $(AM_V_at)echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@
+ $(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
+ $(AM_V_at)chmod a+x $@
--- a/src/Makefile.in
+++ b/src/Makefile.in
-@@ -1609,6 +1609,7 @@ uninstall-am: uninstall-binPROGRAMS unin
+@@ -1919,6 +1919,7 @@ uninstall-am: uninstall-binPROGRAMS unin
yacc:
- echo '#! /bin/sh' >$@
-+ echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@
- echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
- chmod a+x $@
+ $(AM_V_GEN)echo '#! /bin/sh' >$@
++ $(AM_V_at)echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@
+ $(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
+ $(AM_V_at)chmod a+x $@
diff --git a/tools/bison/patches/010-intl-stub-compat.patch b/tools/bison/patches/010-intl-stub-compat.patch
index 2cd720b68..d2dfcadba 100644
--- a/tools/bison/patches/010-intl-stub-compat.patch
+++ b/tools/bison/patches/010-intl-stub-compat.patch
@@ -1,8 +1,8 @@
--- a/src/main.c
+++ b/src/main.c
-@@ -58,9 +58,9 @@ main (int argc, char *argv[])
+@@ -60,9 +60,9 @@ main (int argc, char *argv[])
{
- program_name = argv[0];
+ set_program_name (argv[0]);
setlocale (LC_ALL, "");
- (void) bindtextdomain (PACKAGE, LOCALEDIR);
- (void) bindtextdomain ("bison-runtime", LOCALEDIR);
@@ -11,5 +11,5 @@
+ bindtextdomain ("bison-runtime", LOCALEDIR);
+ textdomain (PACKAGE);
- uniqstrs_new ();
- muscle_init ();
+ {
+ char const *cp = getenv ("LC_CTYPE");
diff --git a/tools/bison/patches/100-fix-gets-removal.patch b/tools/bison/patches/100-fix-gets-removal.patch
index 1b9031064..169bfd673 100644
--- a/tools/bison/patches/100-fix-gets-removal.patch
+++ b/tools/bison/patches/100-fix-gets-removal.patch
@@ -1,15 +1,16 @@
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
-@@ -177,12 +177,6 @@ _GL_WARN_ON_USE (fflush, "fflush is not
- "use gnulib module fflush for portable POSIX compliance");
+@@ -704,13 +704,6 @@ _GL_WARN_ON_USE (getline, "getline is un
+ # endif
#endif
-/* It is very rare that the developer ever has full control of stdin,
-- so any use of gets warrants an unconditional warning. Assume it is
-- always declared, since it is required by C89. */
+- so any use of gets warrants an unconditional warning; besides, C11
+- removed it. */
-#undef gets
+-#if HAVE_RAW_DECL_GETS
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
--
- #if @GNULIB_FOPEN@
- # if @REPLACE_FOPEN@
- # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+-#endif
+
+
+ #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
diff --git a/tools/ccache/Makefile b/tools/ccache/Makefile
index 9020c9c47..aeac39305 100644
--- a/tools/ccache/Makefile
+++ b/tools/ccache/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/target.mk
PKG_NAME:=ccache
-PKG_VERSION:=3.1.7
+PKG_VERSION:=3.1.9
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=http://samba.org/ftp/ccache/
-PKG_MD5SUM:=80a698c22d0b06b19c88ac58e8d8b632
+PKG_MD5SUM:=522a6016bda56892653612bbdefff3e0
include $(INCLUDE_DIR)/host-build.mk
diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile
index 2fca3a8e5..4e4d71b31 100644
--- a/tools/cmake/Makefile
+++ b/tools/cmake/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=cmake
-PKG_VERSION:=2.8.9
+PKG_VERSION:=2.8.10.2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.cmake.org/files/v2.8/
-PKG_MD5SUM:=801f4c87f8b604f727df5bf1f05a59e7
+PKG_MD5SUM:=097278785da7182ec0aea8769d06860c
HOST_BUILD_PARALLEL:=1
HOST_CONFIGURE_PARALLEL:=1
diff --git a/tools/e2fsprogs/Makefile b/tools/e2fsprogs/Makefile
index 3e4347206..3b02f1a0c 100644
--- a/tools/e2fsprogs/Makefile
+++ b/tools/e2fsprogs/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2012 OpenWrt.org
+# Copyright (C) 2010-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -8,8 +8,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=e2fsprogs
-PKG_VERSION:=1.42.4
-PKG_MD5SUM:=b6e296f210d642361b7394437ff0f318
+PKG_VERSION:=1.42.7
+PKG_MD5SUM:=a1ec22ef003688dae9f76c74881b22b9
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
diff --git a/tools/e2fsprogs/patches/003-openbsd-compat.patch b/tools/e2fsprogs/patches/003-openbsd-compat.patch
new file mode 100644
index 000000000..1f7cdca0e
--- /dev/null
+++ b/tools/e2fsprogs/patches/003-openbsd-compat.patch
@@ -0,0 +1,24 @@
+diff -Nur e2fsprogs-1.42.7.orig/lib/blkid/getsize.c e2fsprogs-1.42.7/lib/blkid/getsize.c
+--- e2fsprogs-1.42.7.orig/lib/blkid/getsize.c Fri Nov 30 03:40:18 2012
++++ e2fsprogs-1.42.7/lib/blkid/getsize.c Thu Mar 7 14:21:59 2013
+@@ -26,6 +26,9 @@
+ #include <fcntl.h>
+ #ifdef HAVE_SYS_IOCTL_H
+ #include <sys/ioctl.h>
++#ifdef __OpenBSD__
++#include <sys/dkio.h>
++#endif
+ #endif
+ #ifdef HAVE_LINUX_FD_H
+ #include <linux/fd.h>
+diff -Nur e2fsprogs-1.42.7.orig/lib/quota/mkquota.c e2fsprogs-1.42.7/lib/quota/mkquota.c
+--- e2fsprogs-1.42.7.orig/lib/quota/mkquota.c Wed Jan 2 01:47:20 2013
++++ e2fsprogs-1.42.7/lib/quota/mkquota.c Thu Mar 7 14:21:59 2013
+@@ -8,6 +8,7 @@
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <errno.h>
++#include <stdint.h>
+ #include <string.h>
+ #include <fcntl.h>
+
diff --git a/tools/e2fsprogs/patches/004-freebsd-compat.patch b/tools/e2fsprogs/patches/004-freebsd-compat.patch
new file mode 100644
index 000000000..5eff49999
--- /dev/null
+++ b/tools/e2fsprogs/patches/004-freebsd-compat.patch
@@ -0,0 +1,13 @@
+diff -Nur e2fsprogs-1.42.7.orig/lib/ext2fs/tdb.c e2fsprogs-1.42.7/lib/ext2fs/tdb.c
+--- e2fsprogs-1.42.7.orig/lib/ext2fs/tdb.c 2012-07-06 15:37:27.000000000 +0200
++++ e2fsprogs-1.42.7/lib/ext2fs/tdb.c 2013-03-07 14:54:59.000000000 +0100
+@@ -56,7 +56,9 @@
+ #include <utime.h>
+ #endif
+ #include <sys/stat.h>
++#ifndef __FreeBSD__
+ #include <sys/file.h>
++#endif
+ #include <fcntl.h>
+
+ #ifdef HAVE_SYS_MMAN_H
diff --git a/tools/firmware-utils/src/csysimg.h b/tools/firmware-utils/src/csysimg.h
index 19dfbd433..65ab062f3 100644
--- a/tools/firmware-utils/src/csysimg.h
+++ b/tools/firmware-utils/src/csysimg.h
@@ -49,6 +49,7 @@
#define SIG_BR6114WG SIG_BR6104IPC
#define SIG_BR6524K "2-K-"
#define SIG_BR6524KP "2-KP" /* FIXME: valid? */
+#define SIG_BR6524N "WNRA"
#define SIG_BR6524WG "2-WG" /* FIXME: valid? */
#define SIG_BR6524WP "2-WP" /* FIXME: valid? */
#define SIG_BR6541K "4--K"
diff --git a/tools/firmware-utils/src/mkcameofw.c b/tools/firmware-utils/src/mkcameofw.c
index a152eb535..e0da4baf3 100644
--- a/tools/firmware-utils/src/mkcameofw.c
+++ b/tools/firmware-utils/src/mkcameofw.c
@@ -61,6 +61,7 @@ static struct file_info kernel_info;
static struct file_info rootfs_info;
static uint32_t kernel_size;
static uint32_t image_size;
+static int combined;
/*
* Message macros
@@ -91,6 +92,7 @@ static void usage(int status)
"\n"
"Options:\n"
" -k <file> read kernel image from the file <file>\n"
+" -c use the kernel image as a combined image\n"
" -M <model> set model to <model>\n"
" -o <file> write output to the file <file>\n"
" -r <file> read rootfs image from the file <file>\n"
@@ -196,37 +198,55 @@ static int check_options(void)
CHKSTRLEN(version, "version");
CHKSTR(ofname, "output file");
CHKSTR(kernel_info.file_name, "kernel image");
- CHKSTR(rootfs_info.file_name, "rootfs image");
ret = get_file_stat(&kernel_info);
if (ret)
return ret;
- ret = get_file_stat(&rootfs_info);
- if (ret)
- return ret;
+ if (combined) {
+ if (!kernel_size) {
+ ERR("kernel size must be specified for combined images");
+ return -1; \
+ }
- if (kernel_size) {
- /* override kernel size */
- kernel_info.write_size = kernel_size;
- }
+ if (!image_size)
+ image_size = kernel_info.file_size;
- if (image_size) {
- if (image_size < kernel_info.write_size)
- kernel_info.write_size = image_size;
+ if (kernel_info.file_size > image_size) {
+ ERR("kernel image is too big");
+ return -1;
+ }
- /* override rootfs size */
- rootfs_info.write_size = image_size - kernel_info.write_size;
- }
+ kernel_info.write_size = image_size;
+ } else {
+ CHKSTR(rootfs_info.file_name, "rootfs image");
- if (kernel_info.file_size > kernel_info.write_size) {
- ERR("kernel image is too big");
- return -1;
- }
+ ret = get_file_stat(&rootfs_info);
+ if (ret)
+ return ret;
- if (rootfs_info.file_size > rootfs_info.write_size) {
- ERR("rootfs image is too big");
- return -1;
+ if (kernel_size) {
+ /* override kernel size */
+ kernel_info.write_size = kernel_size;
+ }
+
+ if (image_size) {
+ if (image_size < kernel_info.write_size)
+ kernel_info.write_size = image_size;
+
+ /* override rootfs size */
+ rootfs_info.write_size = image_size - kernel_info.write_size;
+ }
+
+ if (kernel_info.file_size > kernel_info.write_size) {
+ ERR("kernel image is too big");
+ return -1;
+ }
+
+ if (rootfs_info.file_size > rootfs_info.write_size) {
+ ERR("rootfs image is too big");
+ return -1;
+ }
}
return 0;
@@ -301,12 +321,14 @@ static int build_fw(void)
if (ret)
goto out_free_buf;
- p += kernel_info.write_size;
+ if (!combined) {
+ p += kernel_info.write_size;
- /* read rootfs data */
- ret = read_to_buf(&rootfs_info, p);
- if (ret)
- goto out_free_buf;
+ /* read rootfs data */
+ ret = read_to_buf(&rootfs_info, p);
+ if (ret)
+ goto out_free_buf;
+ }
csum = get_csum((unsigned char *)(buf + sizeof(struct img_header)),
buflen - sizeof(struct img_header));
@@ -316,7 +338,10 @@ static int build_fw(void)
hdr->checksum = htonl(csum);
hdr->image_size = htonl(buflen - sizeof(struct img_header));
- hdr->kernel_size = htonl(kernel_info.write_size);
+ if (!combined)
+ hdr->kernel_size = htonl(kernel_info.write_size);
+ else
+ hdr->kernel_size = htonl(kernel_size);
hdr->header_len = sizeof(struct img_header);
strncpy(hdr->model, model, sizeof(hdr->model));
strncpy(hdr->signature, signature, sizeof(hdr->signature));
@@ -344,7 +369,7 @@ int main(int argc, char *argv[])
while (1) {
int c;
- c = getopt(argc, argv, "M:S:V:R:k:K:I:r:o:h");
+ c = getopt(argc, argv, "M:S:V:R:k:K:I:r:o:hc");
if (c == -1)
break;
@@ -381,6 +406,9 @@ int main(int argc, char *argv[])
case 'r':
rootfs_info.file_name = optarg;
break;
+ case 'c':
+ combined = 1;
+ break;
case 'o':
ofname = optarg;
break;
diff --git a/tools/firmware-utils/src/mkcsysimg.c b/tools/firmware-utils/src/mkcsysimg.c
index 4f2352a60..c00096f87 100644
--- a/tools/firmware-utils/src/mkcsysimg.c
+++ b/tools/firmware-utils/src/mkcsysimg.c
@@ -160,6 +160,7 @@ static struct board_info boards[] = {
BOARD_ADM("BR-6114WG", "Edimax BR-6114WG", 2, SIG_BR6114WG),
BOARD_ADM("BR-6524K", "Edimax BR-6524K", 2, SIG_BR6524K),
BOARD_ADM("BR-6524KP", "Edimax BR-6524KP", 2, SIG_BR6524KP),
+ BOARD_ADM("BR-6524N", "Edimax BR-6524N", 2, SIG_BR6524N),
BOARD_ADM("BR-6524WG", "Edimax BR-6524WG", 4, SIG_BR6524WG),
BOARD_ADM("BR-6524WP", "Edimax BR-6524WP", 4, SIG_BR6524WP),
BOARD_ADM("BR-6541K", "Edimax BR-6541K", 2, SIG_BR6541K),
diff --git a/tools/firmware-utils/src/mkdapimg.c b/tools/firmware-utils/src/mkdapimg.c
index 8b0359f74..ed662d8ec 100644
--- a/tools/firmware-utils/src/mkdapimg.c
+++ b/tools/firmware-utils/src/mkdapimg.c
@@ -27,6 +27,8 @@
#define MAX_MODEL_NAME_LEN 20
#define MAX_SIG_LEN 30
+#define MAX_REGION_LEN 4
+#define MAX_VERSION_LEN 12
struct img_hdr_struct {
uint32_t checksum;
@@ -51,7 +53,7 @@ perrexit(int code, char *msg)
void
usage()
{
- fprintf(stderr, "usage: %s [-p] [-m model] -s signature -i input -o output\n", progname);
+ fprintf(stderr, "usage: %s [-p] [-m model] [-r region] [-v version] -s signature -i input -o output\n", progname);
exit(1);
}
@@ -60,8 +62,11 @@ main(int ac, char *av[])
{
char model[MAX_MODEL_NAME_LEN+1];
char signature[MAX_SIG_LEN+1];
+ char region[MAX_REGION_LEN+1];
+ char version[MAX_VERSION_LEN+1];
int patchmode = 0;
int fixmode = 0;
+ int have_regionversion = 0;
FILE *ifile, *ofile;
int c;
@@ -71,11 +76,13 @@ main(int ac, char *av[])
progname = basename(av[0]);
memset(model, 0, sizeof(model));
memset(signature, 0, sizeof(signature));
+ memset(region, 0, sizeof(region));
+ memset(version, 0, sizeof(version));
while ( 1 ) {
int c;
- c = getopt(ac, av, "pxm:s:i:o:");
+ c = getopt(ac, av, "pxm:r:v:s:i:o:");
if (c == -1)
break;
@@ -94,6 +101,24 @@ main(int ac, char *av[])
}
strcpy(model, optarg);
break;
+ case 'r':
+ if (strlen(optarg) > MAX_REGION_LEN) {
+ fprintf(stderr, "%s: region exceeds %d chars\n",
+ progname, MAX_REGION_LEN);
+ exit(1);
+ }
+ have_regionversion = 1;
+ strcpy(region, optarg);
+ break;
+ case 'v':
+ if (strlen(optarg) > MAX_VERSION_LEN) {
+ fprintf(stderr, "%s: version exceeds %d chars\n",
+ progname, MAX_VERSION_LEN);
+ exit(1);
+ }
+ have_regionversion = 1;
+ strcpy(version, optarg);
+ break;
case 's':
if (strlen(optarg) > MAX_SIG_LEN) {
fprintf(stderr, "%s: signature exceeds %d chars\n",
@@ -150,6 +175,10 @@ main(int ac, char *av[])
imghdr.checksum = htonl(cksum);
imghdr.partition = 0 ; // don't care?
imghdr.hdr_len = sizeof(imghdr);
+ if (have_regionversion) {
+ imghdr.hdr_len += MAX_REGION_LEN;
+ imghdr.hdr_len += MAX_VERSION_LEN;
+ }
imghdr.flash_byte_cnt = htonl(bcnt);
} else {
if (ntohl(imghdr.checksum) != cksum) {
@@ -176,6 +205,12 @@ main(int ac, char *av[])
if (fwrite(&imghdr, sizeof(imghdr), 1, ofile) < 0)
perrexit(2, "fwrite header on output");
+ if (have_regionversion) {
+ if (fwrite(&region, MAX_REGION_LEN, 1, ofile) < 0)
+ perrexit(2, "fwrite header on output");
+ if (fwrite(&version, MAX_VERSION_LEN, 1, ofile) < 0)
+ perrexit(2, "fwrite header on output");
+ }
while ((c = fgetc(ifile)) != EOF) {
if (fputc(c, ofile) == EOF)
diff --git a/tools/firmware-utils/src/mkfwimage2.c b/tools/firmware-utils/src/mkfwimage2.c
index ee09abba1..993c3d44e 100644
--- a/tools/firmware-utils/src/mkfwimage2.c
+++ b/tools/firmware-utils/src/mkfwimage2.c
@@ -212,7 +212,7 @@ static int image_layout_add_partition(const char *part_desc)
}
d = &im.parts[im.part_count];
- t = sscanf(part_desc, "%15[a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s",
+ t = sscanf(part_desc, "%15[0-9a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s",
d->partition_name,
offset,
length,
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
index 2be63356d..74a55fd27 100644
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -32,17 +32,25 @@
#define HEADER_VERSION_V1 0x01000000
#define HWID_TL_MR3020_V1 0x30200001
#define HWID_TL_MR3220_V1 0x32200001
+#define HWID_TL_MR3220_V2 0x32200002
#define HWID_TL_MR3420_V1 0x34200001
+#define HWID_TL_MR3420_V2 0x34200002
#define HWID_TL_WA701N_V1 0x07010001
#define HWID_TL_WA7510N_V1 0x75100001
+#define HWID_TL_WA801ND_V1 0x08010001
+#define HWID_TL_WA830RE_V1 0x08300010
+#define HWID_TL_WA830RE_V2 0x08300002
#define HWID_TL_WA901ND_V1 0x09010001
#define HWID_TL_WA901ND_V2 0x09010002
+#define HWID_TL_WDR4900_V1 0x49000001
#define HWID_TL_WR703N_V1 0x07030101
+#define HWID_TL_WR720N_V3 0x07200103
#define HWID_TL_WR741ND_V1 0x07410001
#define HWID_TL_WR741ND_V4 0x07410004
#define HWID_TL_WR740N_V1 0x07400001
#define HWID_TL_WR740N_V3 0x07400003
#define HWID_TL_WR743ND_V1 0x07430001
+#define HWID_TL_WR743ND_V2 0x07430002
#define HWID_TL_WR841N_V1_5 0x08410002
#define HWID_TL_WR841ND_V3 0x08410003
#define HWID_TL_WR841ND_V5 0x08410005
@@ -173,6 +181,12 @@ static struct flash_layout layouts[] = {
.kernel_ep = 0x80060000,
.rootfs_ofs = 0x100000,
}, {
+ .id = "16Mppc",
+ .fw_max_len = 0xf80000,
+ .kernel_la = 0x00000000,
+ .kernel_ep = 0xc0000000,
+ .rootfs_ofs = 0x2a0000,
+ }, {
/* terminating entry */
}
};
@@ -189,11 +203,21 @@ static struct board_info boards[] = {
.hw_rev = 1,
.layout_id = "4M",
}, {
+ .id = "TL-MR3220v2",
+ .hw_id = HWID_TL_MR3220_V2,
+ .hw_rev = 1,
+ .layout_id = "4Mlzma",
+ }, {
.id = "TL-MR3420v1",
.hw_id = HWID_TL_MR3420_V1,
.hw_rev = 1,
.layout_id = "4M",
}, {
+ .id = "TL-MR3420v2",
+ .hw_id = HWID_TL_MR3420_V2,
+ .hw_rev = 1,
+ .layout_id = "4Mlzma",
+ }, {
.id = "TL-WA701Nv1",
.hw_id = HWID_TL_WA701N_V1,
.hw_rev = 1,
@@ -204,6 +228,21 @@ static struct board_info boards[] = {
.hw_rev = 1,
.layout_id = "4M",
}, {
+ .id = "TL-WA801NDv1",
+ .hw_id = HWID_TL_WA801ND_V1,
+ .hw_rev = 1,
+ .layout_id = "4M",
+ }, {
+ .id = "TL-WA830REv1",
+ .hw_id = HWID_TL_WA830RE_V1,
+ .hw_rev = 1,
+ .layout_id = "4M",
+ }, {
+ .id = "TL-WA830REv2",
+ .hw_id = HWID_TL_WA830RE_V2,
+ .hw_rev = 1,
+ .layout_id = "4M",
+ }, {
.id = "TL-WA901NDv1",
.hw_id = HWID_TL_WA901ND_V1,
.hw_rev = 1,
@@ -214,6 +253,11 @@ static struct board_info boards[] = {
.hw_rev = 1,
.layout_id = "4M",
}, {
+ .id = "TL-WDR4900v1",
+ .hw_id = HWID_TL_WDR4900_V1,
+ .hw_rev = 1,
+ .layout_id = "16Mppc",
+ }, {
.id = "TL-WR741NDv1",
.hw_id = HWID_TL_WR741ND_V1,
.hw_rev = 1,
@@ -239,6 +283,11 @@ static struct board_info boards[] = {
.hw_rev = 1,
.layout_id = "4M",
}, {
+ .id = "TL-WR743NDv2",
+ .hw_id = HWID_TL_WR743ND_V2,
+ .hw_rev = 1,
+ .layout_id = "4Mlzma",
+ }, {
.id = "TL-WR841Nv1.5",
.hw_id = HWID_TL_WR841N_V1_5,
.hw_rev = 2,
@@ -289,6 +338,11 @@ static struct board_info boards[] = {
.hw_rev = 1,
.layout_id = "4Mlzma",
}, {
+ .id = "TL-WR720Nv3",
+ .hw_id = HWID_TL_WR720N_V3,
+ .hw_rev = 1,
+ .layout_id = "4Mlzma",
+ }, {
/* terminating entry */
}
};
@@ -371,6 +425,7 @@ static void usage(int status)
" -E <ep> overwrite kernel entry point with <ep> (hexval prefixed with 0x)\n"
" -L <la> overwrite kernel load address with <la> (hexval prefixed with 0x)\n"
" -H <hwid> use hardware id specified with <hwid>\n"
+" -W <hwrev> use hardware revision specified with <hwrev>\n"
" -F <id> use flash layout specified with <id>\n"
" -k <file> read kernel image from the file <file>\n"
" -r <file> read rootfs image from the file <file>\n"
diff --git a/tools/flex/Makefile b/tools/flex/Makefile
index 8d2344842..abb275db8 100644
--- a/tools/flex/Makefile
+++ b/tools/flex/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008 OpenWrt.org
+# Copyright (C) 2008-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=flex
-PKG_VERSION:=2.5.35
+PKG_VERSION:=2.5.37
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
-PKG_MD5SUM:=10714e50cea54dc7a227e3eddcd44d57
+PKG_MD5SUM:=c75940e1fc25108f2a7b3ef42abdae06
PKG_CAT:=bzcat
HOST_BUILD_PARALLEL:=1
diff --git a/tools/gmp/Makefile b/tools/gmp/Makefile
index 292d9a5b3..5028ae062 100644
--- a/tools/gmp/Makefile
+++ b/tools/gmp/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2009-2012 OpenWrt.org
+# Copyright (C) 2009-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gmp
-PKG_VERSION:=5.0.5
+PKG_VERSION:=5.1.1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/gmp/
-PKG_MD5SUM:=8aef50959acec2a1ad41d144ffe0f3b5
+PKG_MD5SUM:=485b1296e6287fa381e6015b19767989
+
+HOST_FIXUP:=autoreconf
HOST_BUILD_PARALLEL:=1
diff --git a/tools/gmp/patches/000-OE-amd64.patch b/tools/gmp/patches/000-OE-amd64.patch
deleted file mode 100644
index 260a0d5a7..000000000
--- a/tools/gmp/patches/000-OE-amd64.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/longlong.h
-+++ b/longlong.h
-@@ -994,8 +994,10 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO (
- count is only an int. */
- #define count_trailing_zeros(count, x) \
- do { \
-+ UDItype __cbtmp; \
- ASSERT ((x) != 0); \
-- __asm__ ("bsfq %1,%q0" : "=r" (count) : "rm" ((UDItype)(x))); \
-+ __asm__ ("bsfq %1,%0" : "=r" (__cbtmp) : "rm" ((UDItype)(x))); \
-+ (count) = __cbtmp; \
- } while (0)
- #endif /* x86_64 */
-
diff --git a/tools/gmp/patches/000-OE-configure.patch b/tools/gmp/patches/000-OE-configure.patch
deleted file mode 100644
index 7a0f1d889..000000000
--- a/tools/gmp/patches/000-OE-configure.patch
+++ /dev/null
@@ -1,199 +0,0 @@
---- a/acinclude.m4
-+++ b/acinclude.m4
-@@ -30,29 +30,29 @@ dnl a_out.exe - OpenVMS DEC C called
- dnl conftest.exe - various DOS compilers
-
-
--define(IA64_PATTERN,
-+define([IA64_PATTERN],
- [[ia64*-*-* | itanium-*-* | itanium2-*-*]])
-
- dnl Need to be careful not to match m6811, m6812, m68hc11 and m68hc12, all
- dnl of which config.sub accepts. (Though none of which are likely to work
- dnl with GMP.)
- dnl
--define(M68K_PATTERN,
-+define([M68K_PATTERN],
- [[m68k-*-* | m68[0-9][0-9][0-9]-*-*]])
-
--define(POWERPC64_PATTERN,
-+define([POWERPC64_PATTERN],
- [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-* | powerpc970-*-* | power[3-9]-*-*]])
-
--define(S390_PATTERN,
-+define([S390_PATTERN],
- [[s390-*-* | z900esa-*-* | z990esa-*-* | z9esa-*-* | z10esa-*-* | z196esa-*-*]])
-
--define(S390X_PATTERN,
-+define([S390X_PATTERN],
- [[s390x-*-* | z900-*-* | z990-*-* | z9-*-* | z10-*-* | z196-*-*]])
-
--define(X86_PATTERN,
-+define([X86_PATTERN],
- [[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]])
-
--define(X86_64_PATTERN,
-+define([X86_64_PATTERN],
- [[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | bulldozer-*-* | pentium4-*-* | atom-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-*]])
-
- dnl GMP_FAT_SUFFIX(DSTVAR, DIRECTORY)
-@@ -70,7 +70,7 @@ dnl x86 -> x86
- dnl x86/k6 -> k6
- dnl x86/k6/mmx -> k6_mmx
-
--define(GMP_FAT_SUFFIX,
-+define([GMP_FAT_SUFFIX],
- [[$1=`echo $2 | sed -e '/\//s:^[^/]*/::' -e 's:[\\/]:_:g'`]])
-
-
-@@ -79,7 +79,7 @@ dnl ----------------------------------
- dnl Emit code to remove any occurrence of ITEM from $LISTVAR. ITEM can be a
- dnl shell expression like $foo if desired.
-
--define(GMP_REMOVE_FROM_LIST,
-+define([GMP_REMOVE_FROM_LIST],
- [remove_from_list_tmp=
- for remove_from_list_i in $[][$1]; do
- if test $remove_from_list_i = [$2]; then :;
-@@ -95,12 +95,12 @@ dnl GMP_STRIP_PATH(subdir)
- dnl ----------------------
- dnl Strip entries */subdir from $path and $fat_path.
-
--define(GMP_STRIP_PATH,
-+define([GMP_STRIP_PATH],
- [GMP_STRIP_PATH_VAR(path, [$1])
- GMP_STRIP_PATH_VAR(fat_path, [$1])
- ])
-
--define(GMP_STRIP_PATH_VAR,
-+define([GMP_STRIP_PATH_VAR],
- [tmp_path=
- for i in $[][$1]; do
- case $i in
-@@ -121,7 +121,7 @@ dnl
- dnl Dummy value for GMP_LIMB_BITS is enough
- dnl for all current configure-time uses of gmp.h.
-
--define(GMP_INCLUDE_GMP_H,
-+define([GMP_INCLUDE_GMP_H],
- [[#define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */
- #define GMP_NAIL_BITS $GMP_NAIL_BITS
- #define GMP_LIMB_BITS 123
-@@ -136,7 +136,7 @@ dnl Expand at autoconf time to the valu
- dnl FILE. The regexps here aren't very rugged, but are enough for gmp.
- dnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted.
-
--define(GMP_HEADER_GETVAL,
-+define([GMP_HEADER_GETVAL],
- [patsubst(patsubst(
- esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]),
- [^.*$1[ ]+],[]),
-@@ -150,7 +150,7 @@ dnl The gmp version number, extracted f
- dnl autoconf time. Two digits like 3.0 if patchlevel <= 0, or three digits
- dnl like 3.0.1 if patchlevel > 0.
-
--define(GMP_VERSION,
-+define([GMP_VERSION],
- [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl
- .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl
- .GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)])
-@@ -1512,7 +1512,9 @@ esac
- echo ["define(<CONFIG_TOP_SRCDIR>,<\`$tmp'>)"] >>$gmp_tmpconfigm4
-
- # All CPUs use asm-defs.m4
--echo ["include][(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"] >>$gmp_tmpconfigm4i
-+echo -n ["include("] >>$gmp_tmpconfigm4i
-+echo -n ["CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4'"] >>$gmp_tmpconfigm4i
-+echo [")"] >>$gmp_tmpconfigm4i
- ])
-
-
---- a/configure.in
-+++ b/configure.in
-@@ -29,12 +29,6 @@ AC_REVISION($Revision$)
- AC_PREREQ(2.59)
- AC_INIT(GNU MP, GMP_VERSION, [gmp-bugs@gmplib.org, see http://gmplib.org/manual/Reporting-Bugs.html], gmp)
- AC_CONFIG_SRCDIR(gmp-impl.h)
--m4_pattern_forbid([^[ \t]*GMP_])
--m4_pattern_allow(GMP_LDFLAGS)
--m4_pattern_allow(GMP_LIMB_BITS)
--m4_pattern_allow(GMP_MPARAM_H_SUGGEST)
--m4_pattern_allow(GMP_NAIL_BITS)
--m4_pattern_allow(GMP_NUMB_BITS)
-
- # If --target is not used then $target_alias is empty, but if say
- # "./configure athlon-pc-freebsd3.5" is used, then all three of
-@@ -311,7 +305,7 @@ AH_VERBATIM([HAVE_HOST_CPU_1],
- # After GMP specific searches and tests, the standard autoconf AC_PROG_CC is
- # called. User selections of CC etc are respected.
- #
--# Care is taken not to use macros like AC_TRY_COMPILE during the GMP
-+# Care is taken not to use macros like AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) during the GMP
- # pre-testing, since they of course depend on AC_PROG_CC, and also some of
- # them cache their results, which is not wanted.
- #
-@@ -403,7 +397,7 @@ abilist="standard"
- # FIXME: We'd like to prefer an ANSI compiler, perhaps by preferring
- # c89 over cc here. But note that on HP-UX c89 provides a castrated
- # environment, and would want to be excluded somehow. Maybe
--# AC_PROG_CC_STDC already does enough to stick cc into ANSI mode and
-+# already does enough to stick cc into ANSI mode and
- # we don't need to worry.
- #
- cclist="gcc cc"
-@@ -1666,7 +1660,7 @@ esac
- CFLAGS_or_unset=${CFLAGS-'(unset)'}
- CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'}
-
--cat >&AC_FD_CC <<EOF
-+cat >&AS_MESSAGE_LOG_FD() <<EOF
- User:
- ABI=$ABI
- CC=$CC
-@@ -2073,7 +2067,6 @@ AC_SUBST(DEFN_LONG_LONG_LIMB)
-
- # The C compiler and preprocessor, put into ANSI mode if possible.
- AC_PROG_CC
--AC_PROG_CC_STDC
- AC_PROG_CPP
- GMP_H_ANSI
-
-@@ -2096,11 +2089,11 @@ AC_SUBST(CCAS)
-
- # The C++ compiler, if desired.
- want_cxx=no
-+AC_PROG_CXX
- if test $enable_cxx != no; then
- test_CXXFLAGS=${CXXFLAGS+set}
-- AC_PROG_CXX
-
-- echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC
-+ echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AS_MESSAGE_LOG_FD()
- cxxflags_ac_prog_cxx=$CXXFLAGS
- cxxflags_list=ac_prog_cxx
-
-@@ -2206,7 +2199,7 @@ case $host in
- esac
-
-
--cat >&AC_FD_CC <<EOF
-+cat >&AS_MESSAGE_LOG_FD() <<EOF
- Decided:
- ABI=$ABI
- CC=$CC
-@@ -3465,7 +3458,7 @@ GMP_FINISH
- # FIXME: Upcoming version of autoconf/automake may not like broken lines.
- # Right now automake isn't accepting the new AC_CONFIG_FILES scheme.
-
--AC_OUTPUT(Makefile \
-+AC_CONFIG_FILES([Makefile \
- mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile \
- mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile \
- tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile \
-@@ -3474,4 +3467,5 @@ AC_OUTPUT(Makefile \
- tests/cxx/Makefile \
- doc/Makefile tune/Makefile \
- demos/Makefile demos/calc/Makefile demos/expr/Makefile \
-- gmp.h:gmp-h.in mp.h:mp-h.in)
-+ gmp.h:gmp-h.in mp.h:mp-h.in])
-+AC_OUTPUT
diff --git a/tools/include/endian.h b/tools/include/endian.h
index 0f17b41da..bba70abd8 100644
--- a/tools/include/endian.h
+++ b/tools/include/endian.h
@@ -15,6 +15,11 @@
#define bswap_16(x) bswap16(x)
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)
+#elif defined(__OpenBSD__)
+#include <sys/types.h>
+#define bswap_16(x) __swap16(x)
+#define bswap_32(x) __swap32(x)
+#define bswap_64(x) __swap64(x)
#else
#include <machine/endian.h>
#define bswap_16(x) swap16(x)
diff --git a/tools/include/getline.h b/tools/include/getline.h
index 02df6c2f7..3ac21715b 100644
--- a/tools/include/getline.h
+++ b/tools/include/getline.h
@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <string.h>
-#if !defined(__linux__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L)
+#if !defined(__linux__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L)
/*
* Emulate glibc getline() via BSD fgetln().
* Note that outsize is not changed unless memory is allocated.
diff --git a/tools/ipkg-utils/patches/210-remove_field_checks.patch b/tools/ipkg-utils/patches/210-remove_field_checks.patch
new file mode 100644
index 000000000..2f1f2eab3
--- /dev/null
+++ b/tools/ipkg-utils/patches/210-remove_field_checks.patch
@@ -0,0 +1,36 @@
+--- a/ipkg-build
++++ b/ipkg-build
+@@ -101,9 +101,6 @@ You probably want to chown these to a sy
+ arch=`required_field Architecture`
+ [ "$?" -ne 0 ] && PKG_ERROR=1
+
+- required_field Maintainer >/dev/null
+- [ "$?" -ne 0 ] && PKG_ERROR=1
+-
+ required_field Description >/dev/null
+ [ "$?" -ne 0 ] && PKG_ERROR=1
+
+@@ -114,23 +111,6 @@ You probably want to chown these to a sy
+ echo "admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web, x11" >&2
+ fi
+
+- priority=`required_field Priority`
+- [ "$?" -ne 0 ] && PKG_ERROR=1
+- if [ -z "$priority" ]; then
+- echo "The Priority field should have one of the following values:" >&2
+- echo "required, important, standard, optional, extra." >&2
+- echo "If you don't know which priority value you should be using, then use \`optional'" >&2
+- fi
+-
+- source=`required_field Source`
+- [ "$?" -ne 0 ] && PKG_ERROR=1
+- if [ -z "$source" ]; then
+- echo "The Source field contain the URL's or filenames of the source code and any patches"
+- echo "used to build this package. Either gnu-style tarballs or Debian source packages "
+- echo "are acceptable. Relative filenames may be used if they are distributed in the same"
+- echo "directory as the .ipk file."
+- fi
+-
+ disallowed_filename=`disallowed_field Filename`
+ [ "$?" -ne 0 ] && PKG_ERROR=1
+
diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile
index 149aaa6f1..458cca8fe 100644
--- a/tools/mkimage/Makefile
+++ b/tools/mkimage/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mkimage
-PKG_VERSION:=2012.04.01
+PKG_VERSION:=2013.04
PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
-PKG_MD5SUM:=192bb231082d9159fb6e16de3039b6b2
+PKG_MD5SUM:=21bf962d69938ed4ed783b792b2b074e
PKG_CAT:=bzcat
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION)
@@ -22,12 +22,12 @@ define Host/Prepare
$(Host/Prepare/Default)
rm -f \
$(HOST_BUILD_DIR)/include/errno.h \
- $(HOST_BUILD_DIR)/include/malloc.h
+ $(HOST_BUILD_DIR)/include/malloc.h \
+ $(HOST_BUILD_DIR)/tools/.depend
+ touch $(HOST_BUILD_DIR)/include/config.h
endef
define Host/Compile
- rm -f $(HOST_BUILD_DIR)/tools/.depend
- touch $(HOST_BUILD_DIR)/include/config.h
$(MAKE) -C $(HOST_BUILD_DIR) BUILD_DIR= BIN_FILES-y="mkimage" HOSTLDFLAGS="$(HOST_STATIC_LINKING)" tools
endef
diff --git a/tools/mkimage/patches/010-freebsd-ulong-fix.patch b/tools/mkimage/patches/010-freebsd-ulong-fix.patch
index 32fa07453..715755b87 100644
--- a/tools/mkimage/patches/010-freebsd-ulong-fix.patch
+++ b/tools/mkimage/patches/010-freebsd-ulong-fix.patch
@@ -1,6 +1,6 @@
--- a/include/image.h
+++ b/include/image.h
-@@ -50,6 +50,10 @@
+@@ -51,6 +51,10 @@
#endif /* USE_HOSTCC */
@@ -9,5 +9,5 @@
+#endif
+
#if defined(CONFIG_FIT)
- #include <fdt.h>
#include <libfdt.h>
+ #include <fdt_support.h>
diff --git a/tools/mkimage/patches/020-openbsd_fixes.patch b/tools/mkimage/patches/020-openbsd_fixes.patch
new file mode 100644
index 000000000..4c376caad
--- /dev/null
+++ b/tools/mkimage/patches/020-openbsd_fixes.patch
@@ -0,0 +1,18 @@
+--- a/tools/mkimage.c
++++ b/tools/mkimage.c
+@@ -464,6 +464,7 @@ NXTARG: ;
+ #if defined(_POSIX_SYNCHRONIZED_IO) && \
+ !defined(__sun__) && \
+ !defined(__FreeBSD__) && \
++ !defined(__OpenBSD__) && \
+ !defined(__APPLE__)
+ (void) fdatasync (ifd);
+ #else
+@@ -507,6 +508,7 @@ NXTARG: ;
+ #if defined(_POSIX_SYNCHRONIZED_IO) && \
+ !defined(__sun__) && \
+ !defined(__FreeBSD__) && \
++ !defined(__OpenBSD__) && \
+ !defined(__APPLE__)
+ (void) fdatasync (ifd);
+ #else
diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
index 23f39ad22..14397964b 100644
--- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch
+++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
@@ -7,8 +7,8 @@
+ .magic = IH_MAGIC,
.dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
.imagename = "",
- };
-@@ -186,6 +187,16 @@ main (int argc, char **argv)
+ .imagename2 = "",
+@@ -189,6 +190,16 @@ main (int argc, char **argv)
genimg_get_comp_id (*++argv)) < 0)
usage ();
goto NXTARG;
@@ -25,7 +25,7 @@
case 'D':
if (--argc <= 0)
usage ();
-@@ -596,12 +607,13 @@ usage ()
+@@ -613,12 +624,13 @@ usage ()
fprintf (stderr, "Usage: %s -l image\n"
" -l ==> list image header information\n",
params.cmdname);
diff --git a/tools/mkimage/patches/040-include_order.patch b/tools/mkimage/patches/040-include_order.patch
deleted file mode 100644
index 5a9d15eb7..000000000
--- a/tools/mkimage/patches/040-include_order.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/tools/Makefile
-+++ b/tools/Makefile
-@@ -159,9 +159,9 @@ NOPEDOBJS := $(addprefix $(obj),$(NOPED_
- # Use native tools and options
- # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
- #
--HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
-+HOSTCPPFLAGS = -I $(SRCTREE)/include \
- -idirafter $(OBJTREE)/include2 \
-- -idirafter $(OBJTREE)/include \
-+ -I $(OBJTREE)/include \
- -I $(SRCTREE)/lib/libfdt \
- -I $(SRCTREE)/tools \
- -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
diff --git a/tools/mkimage/patches/050-image_h_portability.patch b/tools/mkimage/patches/050-image_h_portability.patch
new file mode 100644
index 000000000..1f222370b
--- /dev/null
+++ b/tools/mkimage/patches/050-image_h_portability.patch
@@ -0,0 +1,31 @@
+--- a/include/image.h
++++ b/include/image.h
+@@ -34,7 +34,6 @@
+ #define __IMAGE_H__
+
+ #include "compiler.h"
+-#include <asm/byteorder.h>
+
+ #ifdef USE_HOSTCC
+
+@@ -191,13 +190,13 @@
+ * all data in network byte order (aka natural aka bigendian).
+ */
+ typedef struct image_header {
+- __be32 ih_magic; /* Image Header Magic Number */
+- __be32 ih_hcrc; /* Image Header CRC Checksum */
+- __be32 ih_time; /* Image Creation Timestamp */
+- __be32 ih_size; /* Image Data Size */
+- __be32 ih_load; /* Data Load Address */
+- __be32 ih_ep; /* Entry Point Address */
+- __be32 ih_dcrc; /* Image Data CRC Checksum */
++ uint32_t ih_magic; /* Image Header Magic Number */
++ uint32_t ih_hcrc; /* Image Header CRC Checksum */
++ uint32_t ih_time; /* Image Creation Timestamp */
++ uint32_t ih_size; /* Image Data Size */
++ uint32_t ih_load; /* Data Load Address */
++ uint32_t ih_ep; /* Entry Point Address */
++ uint32_t ih_dcrc; /* Image Data CRC Checksum */
+ uint8_t ih_os; /* Operating System */
+ uint8_t ih_arch; /* CPU architecture */
+ uint8_t ih_type; /* Image Type */
diff --git a/tools/mkimage/patches/060-remove_kernel_includes.patch b/tools/mkimage/patches/060-remove_kernel_includes.patch
new file mode 100644
index 000000000..b408bb10f
--- /dev/null
+++ b/tools/mkimage/patches/060-remove_kernel_includes.patch
@@ -0,0 +1,35 @@
+--- a/include/compiler.h
++++ b/include/compiler.h
+@@ -53,6 +53,11 @@
+ typedef uint16_t __u16;
+ typedef uint32_t __u32;
+ typedef unsigned int uint;
++typedef uint64_t __u64;
++#ifndef linux
++typedef int __kernel_daddr_t;
++typedef unsigned int __kernel_ino_t;
++#endif
+
+ #define uswap_16(x) \
+ ((((x) & 0xff00) >> 8) | \
+--- a/include/linux/posix_types.h
++++ b/include/linux/posix_types.h
+@@ -43,6 +43,8 @@
+ /* Type of a SYSV IPC key. */
+ typedef int __kernel_key_t;
+
++#ifdef linux
+ #include <asm/posix_types.h>
++#endif
+
+ #endif /* _LINUX_POSIX_TYPES_H */
+--- a/include/linux/types.h
++++ b/include/linux/types.h
+@@ -6,7 +6,6 @@
+ #endif
+
+ #include <linux/posix_types.h>
+-#include <asm/types.h>
+ #include <stdbool.h>
+
+ #ifndef __KERNEL_STRICT_NAMES
diff --git a/tools/mkimage/patches/100-dtc-binary.patch b/tools/mkimage/patches/100-dtc-binary.patch
new file mode 100644
index 000000000..50341198b
--- /dev/null
+++ b/tools/mkimage/patches/100-dtc-binary.patch
@@ -0,0 +1,86 @@
+--- a/doc/mkimage.1
++++ b/doc/mkimage.1
+@@ -82,6 +82,10 @@
+ .B Create FIT image:
+
+ .TP
++.BI "\-B [" "dtc bin" "]"
++Set path to the device tree compiler binary.
++
++.TP
+ .BI "\-D [" "dtc options" "]"
+ Provide special options to the device tree compiler that is used to
+ create the image.
+--- a/tools/fit_image.c
++++ b/tools/fit_image.c
+@@ -82,7 +82,8 @@
+
+ /* dtc -I dts -O dtb -p 500 datafile > tmpfile */
+ sprintf (cmd, "%s %s %s > %s",
+- MKIMAGE_DTC, params->dtc, params->datafile, tmpfile);
++ params->dtc_bin, params->dtc_options, params->datafile,
++ tmpfile);
+ debug ("Trying to execute \"%s\"\n", cmd);
+ if (system (cmd) == -1) {
+ fprintf (stderr, "%s: system(%s) failed: %s\n",
+--- a/tools/mkimage.c
++++ b/tools/mkimage.c
+@@ -38,7 +38,8 @@
+ .type = IH_TYPE_KERNEL,
+ .comp = IH_COMP_GZIP,
+ .magic = IH_MAGIC,
+- .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
++ .dtc_bin = MKIMAGE_DTC,
++ .dtc_options = MKIMAGE_DEFAULT_DTC_OPTIONS,
+ .imagename = "",
+ .imagename2 = "",
+ };
+@@ -200,10 +201,15 @@
+ params.cmdname, *argv);
+ }
+ goto NXTARG;
++ case 'B':
++ if (--argc <= 0)
++ usage ();
++ params.dtc_bin = *++argv;
++ goto NXTARG;
+ case 'D':
+ if (--argc <= 0)
+ usage ();
+- params.dtc = *++argv;
++ params.dtc_options = *++argv;
+ goto NXTARG;
+
+ case 'O':
+@@ -637,7 +643,9 @@
+ " -d ==> use image data from 'datafile'\n"
+ " -x ==> set XIP (execute in place)\n",
+ params.cmdname);
+- fprintf (stderr, " %s [-D dtc_options] -f fit-image.its fit-image\n",
++ fprintf (stderr, " %s [-B dtc_bin] [-D dtc_options] -f fit-image.its fit-image\n",
++ " -B ==> set path to the dtc binary\n",
++ " -D ==> set options that will be passed to dtc\n",
+ params.cmdname);
+ fprintf (stderr, " %s -V ==> print version information and exit\n",
+ params.cmdname);
+--- a/tools/mkimage.h
++++ b/tools/mkimage.h
+@@ -46,7 +46,7 @@
+ #define MKIMAGE_MAX_TMPFILE_LEN 256
+ #define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500"
+ #define MKIMAGE_MAX_DTC_CMDLINE_LEN 512
+-#define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */
++#define MKIMAGE_DTC "dtc"
+
+ /*
+ * This structure defines all such variables those are initialized by
+@@ -66,7 +66,8 @@
+ int type;
+ int comp;
+ unsigned int magic;
+- char *dtc;
++ char *dtc_bin;
++ char *dtc_options;
+ unsigned int addr;
+ unsigned int ep;
+ char *imagename;
diff --git a/tools/mklibs/Makefile b/tools/mklibs/Makefile
index fd3d233c4..fa0bce70d 100644
--- a/tools/mklibs/Makefile
+++ b/tools/mklibs/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2009-2012 OpenWrt.org
+# Copyright (C) 2009-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mklibs
-PKG_VERSION:=0.1.34
+PKG_VERSION:=0.1.35
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/m/mklibs/
-PKG_MD5SUM:=afe0ed527ba96b8a882b5de350603007
+PKG_MD5SUM:=3d2a4bd0bbf5ba964b0a1ecdafd1ea9a
+
+HOST_FIXUP:=autoreconf
include $(INCLUDE_DIR)/host-build.mk
diff --git a/tools/mklibs/patches/001-compile.patch b/tools/mklibs/patches/001-compile.patch
new file mode 100644
index 000000000..09b831ada
--- /dev/null
+++ b/tools/mklibs/patches/001-compile.patch
@@ -0,0 +1,8 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,4 +1,4 @@
+-AC_INIT([mklibs],m4_esyscmd(dpkg-parsechangelog | perl -ne 'print $1 if m/^Version: (.*)$/;'))
++AC_INIT([mklibs],m4_esyscmd([head -n1 debian/changelog | awk -F'[\\\\(\\\\)]' '{ print $2 }' | xargs -I{} echo -n {}]))
+ AM_INIT_AUTOMAKE([foreign no-define])
+ AC_CONFIG_HEADERS([config.h])
+ AM_MAINTAINER_MODE
diff --git a/tools/mpfr/Makefile b/tools/mpfr/Makefile
index 55c329ff8..e34830ad5 100644
--- a/tools/mpfr/Makefile
+++ b/tools/mpfr/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2009 OpenWrt.org
+# Copyright (C) 2009-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mpfr
-PKG_VERSION:=3.0.0
+PKG_VERSION:=3.1.1
PKG_SOURCE_URL:=http://www.mpfr.org/mpfr-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
-PKG_MD5SUM:=f45bac3584922c8004a10060ab1a8f9f
+PKG_MD5SUM:=e90e0075bb1b5f626c6e31aaa9c64e3b
HOST_BUILD_PARALLEL:=1
HOST_FIXUP:=autoreconf
diff --git a/tools/mpfr/patches/000-upstream_cumulative.patch b/tools/mpfr/patches/000-upstream_cumulative.patch
deleted file mode 100644
index e21571b52..000000000
--- a/tools/mpfr/patches/000-upstream_cumulative.patch
+++ /dev/null
@@ -1,1945 +0,0 @@
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-06-23 11:02:49.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-06-23 11:03:36.000000000 +0000
-@@ -0,0 +1 @@
-+mpfr_out_str
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-06-23 11:03:20.000000000 +0000
-@@ -1 +1 @@
--3.0.0
-+3.0.0-p1
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-06-23 11:03:20.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0"
-+#define MPFR_VERSION_STRING "3.0.0-p1"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
---- mpfr-3.0.0-a/mpfr.texi 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.texi 2010-06-23 11:03:12.000000000 +0000
-@@ -2050,7 +2050,7 @@
- are printed. If @var{base} is greater than 10, @samp{@@} will be used
- instead of @samp{e} as exponent delimiter.
-
--Return the number of bytes written, or if an error occurred, return 0.
-+Return the number of characters written, or if an error occurred, return 0.
- @end deftypefun
-
- @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
-diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
---- mpfr-3.0.0-a/out_str.c 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/out_str.c 2010-06-23 11:03:12.000000000 +0000
-@@ -22,6 +22,16 @@
-
- #include "mpfr-impl.h"
-
-+/* Warning! S should not contain "%". */
-+#define OUT_STR_RET(S) \
-+ do \
-+ { \
-+ int r; \
-+ r = fprintf (stream, (S)); \
-+ return r < 0 ? 0 : r; \
-+ } \
-+ while (0)
-+
- size_t
- mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
- mpfr_rnd_t rnd_mode)
-@@ -29,6 +39,7 @@
- char *s, *s0;
- size_t l;
- mpfr_exp_t e;
-+ int err;
-
- MPFR_ASSERTN (base >= 2 && base <= 62);
-
-@@ -36,37 +47,16 @@
- if (stream == NULL)
- stream = stdout;
-
-- if (MPFR_IS_NAN(op))
-- {
-- fprintf (stream, "@NaN@");
-- return 3;
-- }
--
-- if (MPFR_IS_INF(op))
-- {
-- if (MPFR_SIGN(op) > 0)
-- {
-- fprintf (stream, "@Inf@");
-- return 3;
-- }
-- else
-- {
-- fprintf (stream, "-@Inf@");
-- return 4;
-- }
-- }
--
-- if (MPFR_IS_ZERO(op))
-+ if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
- {
-- if (MPFR_SIGN(op) > 0)
-- {
-- fprintf(stream, "0");
-- return 1;
-- }
-+ if (MPFR_IS_NAN (op))
-+ OUT_STR_RET ("@NaN@");
-+ else if (MPFR_IS_INF (op))
-+ OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
- else
- {
-- fprintf(stream, "-0");
-- return 2;
-+ MPFR_ASSERTD (MPFR_IS_ZERO (op));
-+ OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
- }
- }
-
-@@ -77,21 +67,31 @@
-
- l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
- - may be incorrect, as only an upper bound? */
-- if (*s == '-')
-- fputc (*s++, stream);
-
-- /* outputs mantissa */
-- fputc (*s++, stream); e--; /* leading digit */
-- fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
-- fputs (s, stream); /* rest of mantissa */
-+ /* outputs possible sign and significand */
-+ err = (*s == '-' && fputc (*s++, stream) == EOF)
-+ || fputc (*s++, stream) == EOF /* leading digit */
-+ || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
-+ || fputs (s, stream) == EOF; /* trailing significand */
- (*__gmp_free_func) (s0, l);
-+ if (MPFR_UNLIKELY (err))
-+ return 0;
-+
-+ e--; /* due to the leading digit */
-
- /* outputs exponent */
- if (e)
- {
-+ int r;
-+
- MPFR_ASSERTN(e >= LONG_MIN);
- MPFR_ASSERTN(e <= LONG_MAX);
-- l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
-+
-+ r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
-+ if (MPFR_UNLIKELY (r < 0))
-+ return 0;
-+
-+ l += r;
- }
-
- return l;
-diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
---- mpfr-3.0.0-a/tests/tout_str.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tout_str.c 2010-06-23 11:03:12.000000000 +0000
-@@ -46,22 +46,54 @@
- special (void)
- {
- mpfr_t x;
-+ unsigned int n;
-
- mpfr_init (x);
-
- mpfr_set_nan (x);
-- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ if (n != 5)
-+ {
-+ printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
-+ "characters instead of 5.\n", n);
-+ exit (1);
-+ }
-
- mpfr_set_inf (x, 1);
-- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ if (n != 5)
-+ {
-+ printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
-+ "characters instead of 5.\n", n);
-+ exit (1);
-+ }
-
- mpfr_set_inf (x, -1);
-- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ if (n != 6)
-+ {
-+ printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
-+ "characters instead of 6.\n", n);
-+ exit (1);
-+ }
-
- mpfr_set_ui (x, 0, MPFR_RNDN);
-- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ if (n != 1)
-+ {
-+ printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
-+ "characters instead of 1.\n", n);
-+ exit (1);
-+ }
-+
- mpfr_neg (x, x, MPFR_RNDN);
-- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
-+ if (n != 2)
-+ {
-+ printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
-+ "characters instead of 2.\n", n);
-+ exit (1);
-+ }
-
- mpfr_clear (x);
- }
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-06-23 11:03:20.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0";
-+ return "3.0.0-p1";
- }
-diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
---- mpfr-3.0.0-a/Makefile.in 2010-06-10 11:00:52.000000000 +0000
-+++ mpfr-3.0.0-b/Makefile.in 2010-06-10 11:00:52.000000000 +0000
-@@ -239,6 +239,7 @@
- distuninstallcheck_listfiles = find . -type f -print
- distcleancheck_listfiles = find . -type f -print
- ACLOCAL = @ACLOCAL@
-+ALLOCA = @ALLOCA@
- AMTAR = @AMTAR@
- AR = @AR@
- AS = @AS@
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-06-23 11:03:36.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-06-25 13:23:13.000000000 +0000
-@@ -0,0 +1 @@
-+alloca
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-06-23 11:03:20.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-06-25 13:23:13.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p1
-+3.0.0-p2
-diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
---- mpfr-3.0.0-a/acinclude.m4 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/acinclude.m4 2010-06-10 11:00:14.000000000 +0000
-@@ -59,6 +59,9 @@
- dnl sys/fpu.h - MIPS specific
- AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
-
-+dnl Check how to get `alloca'
-+AC_FUNC_ALLOCA
-+
- dnl SIZE_MAX macro
- gl_SIZE_MAX
-
-diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
---- mpfr-3.0.0-a/configure 2010-06-10 11:00:51.000000000 +0000
-+++ mpfr-3.0.0-b/configure 2010-06-25 13:23:05.000000000 +0000
-@@ -783,6 +783,7 @@
- OBJDUMP
- DLLTOOL
- AS
-+ALLOCA
- MPFR_LIBM
- ANSI2KNR
- U
-@@ -5622,6 +5623,197 @@
- done
-
-
-+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
-+# for constant arguments. Useless!
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
-+$as_echo_n "checking for working alloca.h... " >&6; }
-+if test "${ac_cv_working_alloca_h+set}" = set; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+#include <alloca.h>
-+int
-+main ()
-+{
-+char *p = (char *) alloca (2 * sizeof (int));
-+ if (p) return 0;
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_link "$LINENO"; then :
-+ ac_cv_working_alloca_h=yes
-+else
-+ ac_cv_working_alloca_h=no
-+fi
-+rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
-+$as_echo "$ac_cv_working_alloca_h" >&6; }
-+if test $ac_cv_working_alloca_h = yes; then
-+
-+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
-+
-+fi
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
-+$as_echo_n "checking for alloca... " >&6; }
-+if test "${ac_cv_func_alloca_works+set}" = set; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+#ifdef __GNUC__
-+# define alloca __builtin_alloca
-+#else
-+# ifdef _MSC_VER
-+# include <malloc.h>
-+# define alloca _alloca
-+# else
-+# ifdef HAVE_ALLOCA_H
-+# include <alloca.h>
-+# else
-+# ifdef _AIX
-+ #pragma alloca
-+# else
-+# ifndef alloca /* predefined by HP cc +Olibcalls */
-+char *alloca ();
-+# endif
-+# endif
-+# endif
-+# endif
-+#endif
-+
-+int
-+main ()
-+{
-+char *p = (char *) alloca (1);
-+ if (p) return 0;
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_link "$LINENO"; then :
-+ ac_cv_func_alloca_works=yes
-+else
-+ ac_cv_func_alloca_works=no
-+fi
-+rm -f core conftest.err conftest.$ac_objext \
-+ conftest$ac_exeext conftest.$ac_ext
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
-+$as_echo "$ac_cv_func_alloca_works" >&6; }
-+
-+if test $ac_cv_func_alloca_works = yes; then
-+
-+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
-+
-+else
-+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
-+# that cause trouble. Some versions do not even contain alloca or
-+# contain a buggy version. If you still want to use their alloca,
-+# use ar to extract alloca.o from them instead of compiling alloca.c.
-+
-+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
-+
-+$as_echo "#define C_ALLOCA 1" >>confdefs.h
-+
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
-+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
-+if test "${ac_cv_os_cray+set}" = set; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+#if defined CRAY && ! defined CRAY2
-+webecray
-+#else
-+wenotbecray
-+#endif
-+
-+_ACEOF
-+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-+ $EGREP "webecray" >/dev/null 2>&1; then :
-+ ac_cv_os_cray=yes
-+else
-+ ac_cv_os_cray=no
-+fi
-+rm -f conftest*
-+
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
-+$as_echo "$ac_cv_os_cray" >&6; }
-+if test $ac_cv_os_cray = yes; then
-+ for ac_func in _getb67 GETB67 getb67; do
-+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-+eval as_val=\$$as_ac_var
-+ if test "x$as_val" = x""yes; then :
-+
-+cat >>confdefs.h <<_ACEOF
-+#define CRAY_STACKSEG_END $ac_func
-+_ACEOF
-+
-+ break
-+fi
-+
-+ done
-+fi
-+
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
-+$as_echo_n "checking stack direction for C alloca... " >&6; }
-+if test "${ac_cv_c_stack_direction+set}" = set; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+ if test "$cross_compiling" = yes; then :
-+ ac_cv_c_stack_direction=0
-+else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+$ac_includes_default
-+int
-+find_stack_direction ()
-+{
-+ static char *addr = 0;
-+ auto char dummy;
-+ if (addr == 0)
-+ {
-+ addr = &dummy;
-+ return find_stack_direction ();
-+ }
-+ else
-+ return (&dummy > addr) ? 1 : -1;
-+}
-+
-+int
-+main ()
-+{
-+ return find_stack_direction () < 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_run "$LINENO"; then :
-+ ac_cv_c_stack_direction=1
-+else
-+ ac_cv_c_stack_direction=-1
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-+ conftest.$ac_objext conftest.beam conftest.$ac_ext
-+fi
-+
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
-+$as_echo "$ac_cv_c_stack_direction" >&6; }
-+cat >>confdefs.h <<_ACEOF
-+#define STACK_DIRECTION $ac_cv_c_stack_direction
-+_ACEOF
-+
-+
-+fi
-+
-+
-
- for ac_header in stdint.h
- do :
-@@ -7564,13 +7756,13 @@
- else
- lt_cv_nm_interface="BSD nm"
- echo "int some_variable = 0;" > conftest.$ac_ext
-- (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
-+ (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
- (eval "$ac_compile" 2>conftest.err)
- cat conftest.err >&5
-- (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
-+ (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
- (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
- cat conftest.err >&5
-- (eval echo "\"\$as_me:7573: output\"" >&5)
-+ (eval echo "\"\$as_me:7765: output\"" >&5)
- cat conftest.out >&5
- if $GREP 'External.*some_variable' conftest.out > /dev/null; then
- lt_cv_nm_interface="MS dumpbin"
-@@ -8772,7 +8964,7 @@
- ;;
- *-*-irix6*)
- # Find out which ABI we are using.
-- echo '#line 8775 "configure"' > conftest.$ac_ext
-+ echo '#line 8967 "configure"' > conftest.$ac_ext
- if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
-@@ -10032,11 +10224,11 @@
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
-- (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
-+ (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
-- echo "$as_me:10039: \$? = $ac_status" >&5
-+ echo "$as_me:10231: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
-@@ -10371,11 +10563,11 @@
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
-- (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
-+ (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
-- echo "$as_me:10378: \$? = $ac_status" >&5
-+ echo "$as_me:10570: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
-@@ -10476,11 +10668,11 @@
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
-- (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
-+ (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
-- echo "$as_me:10483: \$? = $ac_status" >&5
-+ echo "$as_me:10675: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
-@@ -10531,11 +10723,11 @@
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
-- (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
-+ (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
-- echo "$as_me:10538: \$? = $ac_status" >&5
-+ echo "$as_me:10730: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
-@@ -12915,7 +13107,7 @@
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<_LT_EOF
--#line 12918 "configure"
-+#line 13110 "configure"
- #include "confdefs.h"
-
- #if HAVE_DLFCN_H
-@@ -13011,7 +13203,7 @@
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<_LT_EOF
--#line 13014 "configure"
-+#line 13206 "configure"
- #include "confdefs.h"
-
- #if HAVE_DLFCN_H
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-06-23 11:03:20.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-06-25 13:23:13.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p1"
-+#define MPFR_VERSION_STRING "3.0.0-p2"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
---- mpfr-3.0.0-a/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000
-+++ mpfr-3.0.0-b/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000
-@@ -960,6 +960,7 @@
- red=; grn=; lgn=; blu=; std=
- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
- ACLOCAL = @ACLOCAL@
-+ALLOCA = @ALLOCA@
- AMTAR = @AMTAR@
- AR = @AR@
- AS = @AS@
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-06-23 11:03:20.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-06-25 13:23:13.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p1";
-+ return "3.0.0-p2";
- }
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-07-10 00:11:19.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-07-10 00:12:50.000000000 +0000
-@@ -0,0 +1 @@
-+gamma_underflow
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-06-25 13:23:13.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-07-10 00:11:53.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p2
-+3.0.0-p3
-diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
---- mpfr-3.0.0-a/gamma.c 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/gamma.c 2010-07-10 00:11:46.000000000 +0000
-@@ -274,7 +274,7 @@
- /* we want an upper bound for x * [log(2-x)-1].
- since x < 0, we need a lower bound on log(2-x) */
- mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
-- mpfr_log (xp, xp, MPFR_RNDD);
-+ mpfr_log2 (xp, xp, MPFR_RNDD);
- mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
- mpfr_mul (xp, xp, x, MPFR_RNDU);
-
-@@ -303,8 +303,8 @@
- {
- mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
- mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
-- mpfr_log (tmp, tmp, MPFR_RNDU);
-- mpfr_add (tmp, tmp, xp, MPFR_RNDU);
-+ mpfr_log2 (tmp, tmp, MPFR_RNDU);
-+ mpfr_add (xp, tmp, xp, MPFR_RNDU);
- underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
- }
-
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-06-25 13:23:13.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-07-10 00:11:53.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p2"
-+#define MPFR_VERSION_STRING "3.0.0-p3"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
---- mpfr-3.0.0-a/tests/tgamma.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tgamma.c 2010-07-10 00:11:46.000000000 +0000
-@@ -461,6 +461,20 @@
- mpfr_clear (x);
- }
-
-+/* bug found by Stathis, only occurs on 32-bit machines */
-+static void
-+test20100709 (void)
-+{
-+ mpfr_t x;
-+ int inex;
-+
-+ mpfr_init2 (x, 100);
-+ mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
-+ inex = mpfr_gamma (x, x, MPFR_RNDN);
-+ MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
-+ mpfr_clear (x);
-+}
-+
- int
- main (int argc, char *argv[])
- {
-@@ -471,6 +485,7 @@
- test_generic (2, 100, 2);
- gamma_integer ();
- test20071231 ();
-+ test20100709 ();
-
- data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
-
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-06-25 13:23:13.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-07-10 00:11:53.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p2";
-+ return "3.0.0-p3";
- }
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-09-07 08:44:01.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-09-07 08:48:46.000000000 +0000
-@@ -0,0 +1 @@
-+mpfr_cmp/set_ui/si
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-07-10 00:11:53.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-09-07 08:46:06.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p3
-+3.0.0-p4
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-07-10 00:11:53.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-09-07 08:46:06.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p3"
-+#define MPFR_VERSION_STRING "3.0.0-p4"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-@@ -798,35 +798,45 @@
- anyway. Checking with other ICC versions is needed. Possibly detect
- whether warnings are produced or not with a configure test.
- + Remove C++ too, since it complains too much. */
-+/* Added casts to improve robustness in case of undefined behavior and
-+ compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
-+ use such extensions, but these macros will be used by 3rd-party code,
-+ where such extensions may be required.
-+ Moreover casts to unsigned long have been added to avoid warnings in
-+ programs that use MPFR and are compiled with -Wconversion; such casts
-+ are OK since if X is a constant expression, then (unsigned long) X is
-+ also a constant expression, so that the optimizations still work. */
- #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
- #if (__GNUC__ >= 2)
- #undef mpfr_cmp_ui
--/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
--#define mpfr_cmp_ui(_f,_u) \
-- (__builtin_constant_p (_u) && (_u) == 0 ? \
-- mpfr_sgn (_f) : \
-- mpfr_cmp_ui_2exp ((_f),(_u),0))
-+/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
-+ But warning! mpfr_sgn is specified as a macro in the API, thus the macro
-+ mustn't be used if side effects are possible, like here. */
-+#define mpfr_cmp_ui(_f,_u) \
-+ (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
-+ (mpfr_sgn) (_f) : \
-+ mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
- #undef mpfr_cmp_si
--#define mpfr_cmp_si(_f,_s) \
-- (__builtin_constant_p (_s) && (_s) >= 0 ? \
-- mpfr_cmp_ui ((_f), (_s)) : \
-- mpfr_cmp_si_2exp ((_f), (_s), 0))
-+#define mpfr_cmp_si(_f,_s) \
-+ (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
-+ mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \
-+ mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
- #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
- #undef mpfr_set_ui
--#define mpfr_set_ui(_f,_u,_r) \
-- (__builtin_constant_p (_u) && (_u) == 0 ? \
-- __extension__ ({ \
-- mpfr_ptr _p = (_f); \
-- _p->_mpfr_sign = 1; \
-- _p->_mpfr_exp = __MPFR_EXP_ZERO; \
-- (void) (_r); 0; }) : \
-- mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
-+#define mpfr_set_ui(_f,_u,_r) \
-+ (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
-+ __extension__ ({ \
-+ mpfr_ptr _p = (_f); \
-+ _p->_mpfr_sign = 1; \
-+ _p->_mpfr_exp = __MPFR_EXP_ZERO; \
-+ (void) (_r); 0; }) : \
-+ mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
- #endif
- #undef mpfr_set_si
--#define mpfr_set_si(_f,_s,_r) \
-- (__builtin_constant_p (_s) && (_s) >= 0 ? \
-- mpfr_set_ui ((_f), (_s), (_r)) : \
-- mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
-+#define mpfr_set_si(_f,_s,_r) \
-+ (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
-+ mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \
-+ mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
- #endif
- #endif
-
-diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
---- mpfr-3.0.0-a/tests/tcmp_ui.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tcmp_ui.c 2010-09-07 08:45:12.000000000 +0000
-@@ -88,6 +88,126 @@
- mpfr_clear (x);
- }
-
-+/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
-+ with __builtin_constant_p for GCC, check that side effects are
-+ handled correctly. */
-+static void
-+check_macros (void)
-+{
-+ mpfr_t x;
-+ int c;
-+
-+ mpfr_init2 (x, 32);
-+
-+ c = 0;
-+ mpfr_set_ui (x, 17, MPFR_RNDN);
-+ if (mpfr_cmp_ui (x, 17) != 0)
-+ {
-+ printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
-+ exit (1);
-+ }
-+ if (mpfr_cmp_ui (x, (c++, 17)) != 0)
-+ {
-+ printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
-+ exit (1);
-+ }
-+ if (c != 1)
-+ {
-+ printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
-+ "(c = %d instead of 1)\n", c);
-+ exit (1);
-+ }
-+ if (mpfr_cmp_si (x, 17) != 0)
-+ {
-+ printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
-+ exit (1);
-+ }
-+ if (mpfr_cmp_si (x, (c++, 17)) != 0)
-+ {
-+ printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
-+ exit (1);
-+ }
-+ if (c != 2)
-+ {
-+ printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
-+ "(c = %d instead of 2)\n", c);
-+ exit (1);
-+ }
-+
-+ c = 0;
-+ mpfr_set_ui (x, 0, MPFR_RNDN);
-+ if (mpfr_cmp_ui (x, 0) != 0)
-+ {
-+ printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
-+ exit (1);
-+ }
-+ if (mpfr_cmp_ui (x, (c++, 0)) != 0)
-+ {
-+ printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
-+ exit (1);
-+ }
-+ if (c != 1)
-+ {
-+ printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
-+ "(c = %d instead of 1)\n", c);
-+ exit (1);
-+ }
-+ if (mpfr_cmp_si (x, 0) != 0)
-+ {
-+ printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
-+ exit (1);
-+ }
-+ if (mpfr_cmp_si (x, (c++, 0)) != 0)
-+ {
-+ printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
-+ exit (1);
-+ }
-+ if (c != 2)
-+ {
-+ printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
-+ "(c = %d instead of 2)\n", c);
-+ exit (1);
-+ }
-+
-+ mpfr_clear (x);
-+}
-+
-+/* Bug in r7114 */
-+static void
-+test_macros (void)
-+{
-+ mpfr_t x[3];
-+ mpfr_ptr p;
-+
-+ mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
-+ mpfr_set_ui (x[0], 0, MPFR_RNDN);
-+ p = x[0];
-+ if (mpfr_cmp_ui (p++, 0) != 0)
-+ {
-+ printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
-+ exit (1);
-+ }
-+ if (p != x[1])
-+ {
-+ printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
-+ (int) (p - x[0]));
-+ exit (1);
-+ }
-+ p = x[0];
-+ if (mpfr_cmp_si (p++, 0) != 0)
-+ {
-+ printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
-+ exit (1);
-+ }
-+ if (p != x[1])
-+ {
-+ printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
-+ (int) (p - x[0]));
-+ exit (1);
-+ }
-+ mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
-+}
-+
- int
- main (void)
- {
-@@ -216,6 +336,8 @@
- mpfr_clear (x);
-
- check_nan ();
-+ check_macros ();
-+ test_macros ();
-
- tests_end_mpfr ();
- return 0;
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-07-10 00:11:53.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-09-07 08:46:06.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p3";
-+ return "3.0.0-p4";
- }
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-10-21 20:28:38.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:28:38.000000000 +0000
-@@ -0,0 +1 @@
-+tcan_round
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-09-07 08:46:06.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-10-21 20:28:38.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p4
-+3.0.0-p5
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-09-07 08:46:06.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:28:38.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p4"
-+#define MPFR_VERSION_STRING "3.0.0-p5"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c
---- mpfr-3.0.0-a/tests/tcan_round.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tcan_round.c 2010-10-21 20:28:38.000000000 +0000
-@@ -41,7 +41,7 @@
- /* avoid mpn_random which leaks memory */
- for (i = 0; i < n; i++)
- buf[i] = randlimb ();
-- p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
-+ p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
- err = p + randlimb () % GMP_NUMB_BITS;
- r1 = mpfr_round_p (buf, n, err, p);
- r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err,
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-09-07 08:46:06.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-10-21 20:28:38.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p4";
-+ return "3.0.0-p5";
- }
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-10-21 20:59:32.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:59:32.000000000 +0000
-@@ -0,0 +1 @@
-+mpfr_sub1
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-10-21 20:28:38.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-10-21 20:59:32.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p5
-+3.0.0-p6
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:28:38.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:59:32.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p5"
-+#define MPFR_VERSION_STRING "3.0.0-p6"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c
---- mpfr-3.0.0-a/sub1.c 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/sub1.c 2010-10-21 20:59:32.000000000 +0000
-@@ -37,7 +37,9 @@
- mp_size_t cancel2, an, bn, cn, cn0;
- mp_limb_t *ap, *bp, *cp;
- mp_limb_t carry, bb, cc, borrow = 0;
-- int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
-+ int inexact, shift_b, shift_c, add_exp = 0;
-+ int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c),
-+ negative if low(b) < low(c), positive if low(b)>low(c) */
- int sh, k;
- MPFR_TMP_DECL(marker);
-
-@@ -196,7 +198,8 @@
- }
-
- #ifdef DEBUG
-- printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c,
-+ printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n",
-+ mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c,
- (unsigned long) diff_exp);
- #endif
-
-@@ -307,17 +310,18 @@
- {
- if (MPFR_LIKELY(sh))
- {
-- is_exact = (carry == 0);
- /* can decide except when carry = 2^(sh-1) [middle]
- or carry = 0 [truncate, but cannot decide inexact flag] */
-- down = (carry < (MPFR_LIMB_ONE << (sh - 1)));
- if (carry > (MPFR_LIMB_ONE << (sh - 1)))
- goto add_one_ulp;
-- else if ((0 < carry) && down)
-+ else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1))))
- {
- inexact = -1; /* result if smaller than exact value */
- goto truncate;
- }
-+ /* now carry = 2^(sh-1), in which case cmp_low=2,
-+ or carry = 0, in which case cmp_low=0 */
-+ cmp_low = (carry == 0) ? 0 : 2;
- }
- }
- else /* directed rounding: set rnd_mode to RNDZ iff toward zero */
-@@ -344,12 +348,32 @@
- cn -= (long int) an + cancel2;
-
- #ifdef DEBUG
-- printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n",
-+ printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n",
- sh, (unsigned long) carry, (long) bn, (long) cn);
- #endif
-
-+ /* for rounding to nearest, we couldn't conclude up to here in the following
-+ cases:
-+ 1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp
-+ or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp
-+ 2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1):
-+ -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp
-+ we can't decide the rounding, in that case cmp_low=2:
-+ either we truncate and flag=-1, or we add one ulp and flag=1
-+ 3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to
-+ truncate but we can't decide the ternary value, here cmp_low=0:
-+ -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp
-+ we always truncate and inexact can be any of -1,0,1
-+ */
-+
-+ /* note: here cn might exceed cn0, in which case we consider a zero limb */
- for (k = 0; (bn > 0) || (cn > 0); k = 1)
- {
-+ /* if cmp_low < 0, we know low(b) - low(c) < 0
-+ if cmp_low > 0, we know low(b) - low(c) > 0
-+ (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far)
-+ if cmp_low = 0, so far low(b) - low(c) = 0 */
-+
- /* get next limbs */
- bb = (bn > 0) ? bp[--bn] : 0;
- if ((cn > 0) && (cn-- <= cn0))
-@@ -357,76 +381,115 @@
- else
- cc = 0;
-
-- /* down is set when low(b) < low(c) */
-- if (down == 0)
-- down = (bb < cc);
-+ /* cmp_low compares low(b) and low(c) */
-+ if (cmp_low == 0) /* case 1 or 3 */
-+ cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0;
-+
-+ /* Case 1 for k=0 splits into 7 subcases:
-+ 1a: bb > cc + half
-+ 1b: bb = cc + half
-+ 1c: 0 < bb - cc < half
-+ 1d: bb = cc
-+ 1e: -half < bb - cc < 0
-+ 1f: bb - cc = -half
-+ 1g: bb - cc < -half
-+
-+ Case 2 splits into 3 subcases:
-+ 2a: bb > cc
-+ 2b: bb = cc
-+ 2c: bb < cc
-+
-+ Case 3 splits into 3 subcases:
-+ 3a: bb > cc
-+ 3b: bb = cc
-+ 3c: bb < cc
-+ */
-
- /* the case rounding to nearest with sh=0 is special since one couldn't
- subtract above 1/2 ulp in the trailing limb of the result */
-- if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0)
-+ if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */
- {
- mp_limb_t half = MPFR_LIMB_HIGHBIT;
-
-- is_exact = (bb == cc);
--
- /* add one ulp if bb > cc + half
- truncate if cc - half < bb < cc + half
- sub one ulp if bb < cc - half
- */
-
-- if (down)
-+ if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0,
-+ cases 1e, 1f and 1g */
- {
- if (cc >= half)
- cc -= half;
-- else
-+ else /* since bb < cc < half, bb+half < 2*half */
- bb += half;
-+ /* now we have bb < cc + half:
-+ we have to subtract one ulp if bb < cc,
-+ and truncate if bb > cc */
- }
-- else /* bb >= cc */
-+ else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */
- {
- if (cc < half)
- cc += half;
-- else
-+ else /* since bb >= cc >= half, bb - half >= 0 */
- bb -= half;
-+ /* now we have bb > cc - half: we have to add one ulp if bb > cc,
-+ and truncate if bb < cc */
-+ if (cmp_low > 0)
-+ cmp_low = 2;
- }
- }
-
- #ifdef DEBUG
-- printf (" bb=%lu cc=%lu down=%d is_exact=%d\n",
-- (unsigned long) bb, (unsigned long) cc, down, is_exact);
-+ printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k,
-+ (unsigned long) bb, (unsigned long) cc, cmp_low);
- #endif
-- if (bb < cc)
-+ if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract
-+ one ulp */
- {
- if (rnd_mode == MPFR_RNDZ)
-- goto sub_one_ulp;
-+ goto sub_one_ulp; /* set inexact=-1 */
- else if (rnd_mode != MPFR_RNDN) /* round away */
- {
- inexact = 1;
- goto truncate;
- }
-- else /* round to nearest: special case here since for sh=k=0
-- bb = bb0 - MPFR_LIMB_HIGHBIT */
-+ else /* round to nearest */
- {
-- if (is_exact && sh == 0)
-- {
-- /* For k=0 we can't decide exactness since it may depend
-- from low order bits.
-- For k=1, the first low limbs matched: low(b)-low(c)<0. */
-- if (k)
-- {
-- inexact = 1;
-- goto truncate;
-- }
-- }
-- else if (down && sh == 0)
-- goto sub_one_ulp;
-- else
-- {
-- inexact = (is_exact) ? 1 : -1;
-+ /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0,
-+ whatever the value of sh.
-+ If sh>0, then cmp_low < 0 implies that the initial neglected
-+ sh bits were 0 (otherwise cmp_low=2 initially), thus the
-+ weight of the new bits is less than 0.5 ulp too.
-+ If k > 0 (and sh=0) this means that either the first neglected
-+ limbs bb and cc were equal (thus cmp_low was 0 for k=0),
-+ or we had bb - cc = -0.5 ulp or 0.5 ulp.
-+ The last case is not possible here since we would have
-+ cmp_low > 0 which is sticky.
-+ In the first case (where we have cmp_low = -1), we truncate,
-+ whereas in the 2nd case we have cmp_low = -2 and we subtract
-+ one ulp.
-+ */
-+ if (bb > cc || sh > 0 || cmp_low == -1)
-+ { /* -0.5 ulp < low(b)-low(c) < 0,
-+ bb > cc corresponds to cases 1e and 1f1
-+ sh > 0 corresponds to cases 3c and 3b3
-+ cmp_low = -1 corresponds to case 1d3 (also 3b3) */
-+ inexact = 1;
- goto truncate;
- }
-+ else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp,
-+ this corresponds to cases 1g and 1f3 */
-+ goto sub_one_ulp;
-+ /* the only case where we can't conclude is sh=0 and bb=cc,
-+ i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus
-+ we don't know if we must truncate or subtract one ulp.
-+ Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to
-+ now, since low(b) - low(c) > 1/2^sh */
- }
- }
-- else if (bb > cc)
-+ else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or
-+ add one ulp */
- {
- if (rnd_mode == MPFR_RNDZ)
- {
-@@ -437,34 +500,70 @@
- goto add_one_ulp;
- else /* round to nearest */
- {
-- if (is_exact)
-+ if (bb > cc)
- {
-- inexact = -1;
-- goto truncate;
-+ /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp,
-+ and similarly when cmp_low=2 */
-+ if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */
-+ goto add_one_ulp;
-+ /* sh > 0 and cmp_low > 0: this implies that the sh initial
-+ neglected bits were 0, and the remaining low(b)-low(c)>0,
-+ but its weight is less than 0.5 ulp */
-+ else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to
-+ cases 3a, 1d1 and 3b1 */
-+ {
-+ inexact = -1;
-+ goto truncate;
-+ }
- }
-- else if (down)
-+ else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c,
-+ 1b3, 2b3 and 2c */
- {
-- inexact = 1;
-+ inexact = -1;
- goto truncate;
- }
-- else
-- goto add_one_ulp;
-+ /* the only case where we can't conclude is bb=cc, i.e.,
-+ low(b) - low(c) = 0.5 ulp (up to now), thus we don't know
-+ if we must truncate or add one ulp. */
- }
- }
-+ /* after k=0, we cannot conclude in the following cases, we split them
-+ according to the values of bb and cc for k=1:
-+ 1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp]
-+ 1b1. bb > cc: add one ulp, inex = 1
-+ 1b2: bb = cc: cannot conclude
-+ 1b3: bb < cc: truncate, inex = -1
-+ 1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0]
-+ 1d1: bb > cc: truncate, inex = -1
-+ 1d2: bb = cc: cannot conclude
-+ 1d3: bb < cc: truncate, inex = +1
-+ 1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp]
-+ 1f1: bb > cc: truncate, inex = +1
-+ 1f2: bb = cc: cannot conclude
-+ 1f3: bb < cc: sub one ulp, inex = -1
-+ 2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp]
-+ 2b1. bb > cc: add one ulp, inex = 1
-+ 2b2: bb = cc: cannot conclude
-+ 2b3: bb < cc: truncate, inex = -1
-+ 3b. sh > 0 and cmp_low = 0 [around 0]
-+ 3b1. bb > cc: truncate, inex = -1
-+ 3b2: bb = cc: cannot conclude
-+ 3b3: bb < cc: truncate, inex = +1
-+ */
- }
-
-- if ((rnd_mode == MPFR_RNDN) && !is_exact)
-+ if ((rnd_mode == MPFR_RNDN) && cmp_low != 0)
- {
- /* even rounding rule */
- if ((ap[0] >> sh) & 1)
- {
-- if (down)
-+ if (cmp_low < 0)
- goto sub_one_ulp;
- else
- goto add_one_ulp;
- }
- else
-- inexact = (down) ? 1 : -1;
-+ inexact = (cmp_low > 0) ? -1 : 1;
- }
- else
- inexact = 0;
-diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c
---- mpfr-3.0.0-a/tests/tfma.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tfma.c 2010-10-21 20:59:32.000000000 +0000
-@@ -337,6 +337,94 @@
- mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
- }
-
-+static void
-+bug20101018 (void)
-+{
-+ mpfr_t x, y, z, t, u;
-+ int i;
-+
-+ mpfr_init2 (x, 64);
-+ mpfr_init2 (y, 64);
-+ mpfr_init2 (z, 64);
-+ mpfr_init2 (t, 64);
-+ mpfr_init2 (u, 64);
-+
-+ mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN);
-+ mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN);
-+ mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN);
-+ mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN);
-+ i = mpfr_fma (u, x, y, z, MPFR_RNDN);
-+ if (mpfr_cmp (u, t) != 0)
-+ {
-+ printf ("Wrong result in bug20101018 (a)\n");
-+ printf ("Expected ");
-+ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
-+ printf ("\nGot ");
-+ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
-+ printf ("\n");
-+ exit (1);
-+ }
-+ if (i <= 0)
-+ {
-+ printf ("Wrong ternary value in bug20101018 (a)\n");
-+ printf ("Expected > 0\n");
-+ printf ("Got %d\n", i);
-+ exit (1);
-+ }
-+
-+ mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN);
-+ mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN);
-+ mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN);
-+ mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN);
-+ i = mpfr_fma (u, x, y, z, MPFR_RNDN);
-+ if (mpfr_cmp (u, t) != 0)
-+ {
-+ printf ("Wrong result in bug20101018 (b)\n");
-+ printf ("Expected ");
-+ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
-+ printf ("\nGot ");
-+ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
-+ printf ("\n");
-+ exit (1);
-+ }
-+ if (i <= 0)
-+ {
-+ printf ("Wrong ternary value in bug20101018 (b)\n");
-+ printf ("Expected > 0\n");
-+ printf ("Got %d\n", i);
-+ exit (1);
-+ }
-+
-+ mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN);
-+ mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN);
-+ mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN);
-+ mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN);
-+ i = mpfr_fma (u, x, y, z, MPFR_RNDN);
-+ if (mpfr_cmp (u, t) != 0)
-+ {
-+ printf ("Wrong result in bug20101018 (c)\n");
-+ printf ("Expected ");
-+ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
-+ printf ("\nGot ");
-+ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
-+ printf ("\n");
-+ exit (1);
-+ }
-+ if (i <= 0)
-+ {
-+ printf ("Wrong ternary value in bug20101018 (c)\n");
-+ printf ("Expected > 0\n");
-+ printf ("Got %d\n", i);
-+ exit (1);
-+ }
-+
-+ mpfr_clear (x);
-+ mpfr_clear (y);
-+ mpfr_clear (z);
-+ mpfr_clear (t);
-+ mpfr_clear (u);
-+}
-+
- int
- main (int argc, char *argv[])
- {
-@@ -345,6 +433,8 @@
-
- tests_start_mpfr ();
-
-+ bug20101018 ();
-+
- mpfr_init (x);
- mpfr_init (s);
- mpfr_init (y);
-diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c
---- mpfr-3.0.0-a/tests/tsub.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tsub.c 2010-10-21 20:59:32.000000000 +0000
-@@ -201,6 +201,8 @@
- if (mpfr_cmp (z, x))
- {
- printf ("Error in mpfr_sub (2)\n");
-+ printf ("Expected "); mpfr_print_binary (x); puts ("");
-+ printf ("Got "); mpfr_print_binary (z); puts ("");
- exit (1);
- }
- mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101");
-@@ -478,6 +480,156 @@
- mpfr_clear (u);
- }
-
-+/* Bug found by Jakub Jelinek
-+ * http://bugzilla.redhat.com/643657
-+ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301
-+ * The consequence can be either an assertion failure (i = 2 in the
-+ * testcase below, in debug mode) or an incorrectly rounded value.
-+ */
-+static void
-+bug20101017 (void)
-+{
-+ mpfr_t a, b, c;
-+ int inex;
-+ int i;
-+
-+ mpfr_init2 (a, GMP_NUMB_BITS * 2);
-+ mpfr_init2 (b, GMP_NUMB_BITS);
-+ mpfr_init2 (c, GMP_NUMB_BITS);
-+
-+ /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1
-+ with N = GMP_NUMB_BITS and k = 0 or 1.
-+ c = a - b should round to the same value as a. */
-+
-+ for (i = 2; i <= 3; i++)
-+ {
-+ mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN);
-+ mpfr_add_ui (a, a, 1, MPFR_RNDN);
-+ mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN);
-+ mpfr_set_ui (b, 1, MPFR_RNDN);
-+ inex = mpfr_sub (c, a, b, MPFR_RNDN);
-+ mpfr_set (b, a, MPFR_RNDN);
-+ if (! mpfr_equal_p (c, b))
-+ {
-+ printf ("Error in bug20101017 for i = %d.\n", i);
-+ printf ("Expected ");
-+ mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN);
-+ putchar ('\n');
-+ printf ("Got ");
-+ mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN);
-+ putchar ('\n');
-+ exit (1);
-+ }
-+ if (inex >= 0)
-+ {
-+ printf ("Error in bug20101017 for i = %d: bad inex value.\n", i);
-+ printf ("Expected negative, got %d.\n", inex);
-+ exit (1);
-+ }
-+ }
-+
-+ mpfr_set_prec (a, 64);
-+ mpfr_set_prec (b, 129);
-+ mpfr_set_prec (c, 2);
-+ mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65");
-+ mpfr_set_str_binary (c, "0.10E1");
-+ inex = mpfr_sub (a, b, c, MPFR_RNDN);
-+ if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0)
-+ {
-+ printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n");
-+ printf ("Expected result 2^64 with inex < 0\n");
-+ printf ("Got "); mpfr_print_binary (a);
-+ printf (" with inex=%d\n", inex);
-+ exit (1);
-+ }
-+
-+ mpfr_clears (a, b, c, (mpfr_ptr) 0);
-+}
-+
-+/* hard test of rounding */
-+static void
-+check_rounding (void)
-+{
-+ mpfr_t a, b, c, res;
-+ mpfr_prec_t p;
-+ long k, l;
-+ int i;
-+
-+#define MAXKL (2 * GMP_NUMB_BITS)
-+ for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++)
-+ {
-+ mpfr_init2 (a, p);
-+ mpfr_init2 (res, p);
-+ mpfr_init2 (b, p + 1 + MAXKL);
-+ mpfr_init2 (c, MPFR_PREC_MIN);
-+
-+ /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */
-+ for (k = 0; k <= MAXKL; k++)
-+ for (l = 0; l <= MAXKL; l++)
-+ {
-+ mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN);
-+ mpfr_add_ui (b, b, 1, MPFR_RNDN);
-+ mpfr_mul_2ui (b, b, k, MPFR_RNDN);
-+ mpfr_add_ui (b, b, 1, MPFR_RNDN);
-+ mpfr_div_2ui (b, b, k, MPFR_RNDN);
-+ mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
-+ i = mpfr_sub (a, b, c, MPFR_RNDN);
-+ /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
-+ 2^p for l <= k, and 2^p+2 for l < k */
-+ if (l <= k)
-+ {
-+ if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
-+ {
-+ printf ("Wrong result in check_rounding\n");
-+ printf ("p=%lu k=%ld l=%ld\n", p, k, l);
-+ printf ("b="); mpfr_print_binary (b); puts ("");
-+ printf ("c="); mpfr_print_binary (c); puts ("");
-+ printf ("Expected 2^%lu\n", p);
-+ printf ("Got "); mpfr_print_binary (a); puts ("");
-+ exit (1);
-+ }
-+ if (i >= 0)
-+ {
-+ printf ("Wrong ternary value in check_rounding\n");
-+ printf ("p=%lu k=%ld l=%ld\n", p, k, l);
-+ printf ("b="); mpfr_print_binary (b); puts ("");
-+ printf ("c="); mpfr_print_binary (c); puts ("");
-+ printf ("a="); mpfr_print_binary (a); puts ("");
-+ printf ("Expected < 0, got %d\n", i);
-+ exit (1);
-+ }
-+ }
-+ else /* l < k */
-+ {
-+ mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
-+ mpfr_add_ui (res, res, 2, MPFR_RNDN);
-+ if (mpfr_cmp (a, res) != 0)
-+ {
-+ printf ("Wrong result in check_rounding\n");
-+ printf ("b="); mpfr_print_binary (b); puts ("");
-+ printf ("c="); mpfr_print_binary (c); puts ("");
-+ printf ("Expected "); mpfr_print_binary (res); puts ("");
-+ printf ("Got "); mpfr_print_binary (a); puts ("");
-+ exit (1);
-+ }
-+ if (i <= 0)
-+ {
-+ printf ("Wrong ternary value in check_rounding\n");
-+ printf ("b="); mpfr_print_binary (b); puts ("");
-+ printf ("c="); mpfr_print_binary (c); puts ("");
-+ printf ("Expected > 0, got %d\n", i);
-+ exit (1);
-+ }
-+ }
-+ }
-+
-+ mpfr_clear (a);
-+ mpfr_clear (res);
-+ mpfr_clear (b);
-+ mpfr_clear (c);
-+ }
-+}
-+
- #define TEST_FUNCTION test_sub
- #define TWO_ARGS
- #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
-@@ -491,6 +643,8 @@
-
- tests_start_mpfr ();
-
-+ bug20101017 ();
-+ check_rounding ();
- check_diverse ();
- check_inexact ();
- bug_ddefour ();
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-10-21 20:28:38.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-10-21 20:59:32.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p5";
-+ return "3.0.0-p6";
- }
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-10-21 21:18:26.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-10-21 21:18:26.000000000 +0000
-@@ -0,0 +1 @@
-+mpfr_set_ld
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-10-21 20:59:32.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-10-21 21:18:26.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p6
-+3.0.0-p7
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:59:32.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-10-21 21:18:26.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p6"
-+#define MPFR_VERSION_STRING "3.0.0-p7"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
---- mpfr-3.0.0-a/set_ld.c 2010-06-10 11:00:14.000000000 +0000
-+++ mpfr-3.0.0-b/set_ld.c 2010-10-21 21:18:26.000000000 +0000
-@@ -102,21 +102,25 @@
- {
- x /= div13; /* exact */
- shift_exp += 8192;
-+ mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
- }
- if (ABS (x) >= div12)
- {
- x /= div12; /* exact */
- shift_exp += 4096;
-+ mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
- }
- if (ABS (x) >= div11)
- {
- x /= div11; /* exact */
- shift_exp += 2048;
-+ mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
- }
- if (ABS (x) >= div10)
- {
- x /= div10; /* exact */
- shift_exp += 1024;
-+ mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
- }
- /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
- therefore we have one extra exponent reduction step */
-@@ -124,9 +128,10 @@
- {
- x /= div9; /* exact */
- shift_exp += 512;
-+ mpfr_div_2si (t, t, 512, MPFR_RNDZ);
- }
- } /* Check overflow of double */
-- else
-+ else /* no overflow on double */
- {
- long double div9, div10, div11;
-
-@@ -149,29 +154,34 @@
- {
- x /= div13; /* exact */
- shift_exp -= 8192;
-+ mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
- }
- if (ABS (x) <= div12)
- {
- x /= div12; /* exact */
- shift_exp -= 4096;
-+ mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
- }
- if (ABS (x) <= div11)
- {
- x /= div11; /* exact */
- shift_exp -= 2048;
-+ mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
- }
- if (ABS (x) <= div10)
- {
- x /= div10; /* exact */
- shift_exp -= 1024;
-+ mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
- }
- if (ABS(x) <= div9)
- {
- x /= div9; /* exact */
- shift_exp -= 512;
-+ mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
- }
- }
-- else
-+ else /* no underflow */
- {
- inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
- MPFR_ASSERTD (inexact == 0);
-diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
---- mpfr-3.0.0-a/tests/tset_ld.c 2010-06-10 11:00:13.000000000 +0000
-+++ mpfr-3.0.0-b/tests/tset_ld.c 2010-10-21 21:18:26.000000000 +0000
-@@ -147,12 +147,39 @@
- test_fixed_bugs (void)
- {
- mpfr_t x;
-- long double d;
-+ long double l, m;
-
- /* bug found by Steve Kargl (2009-03-14) */
- mpfr_init2 (x, 64);
- mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
-- d = mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */
-+ mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */
-+
-+ /* bug reported by Jakub Jelinek (2010-10-17)
-+ https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
-+ mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
-+ /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
-+ l = 8.215640181713713164092636634579e-276;
-+ mpfr_set_ld (x, l, MPFR_RNDN);
-+ m = mpfr_get_ld (x, MPFR_RNDN);
-+ if (m != l)
-+ {
-+ printf ("Error in get_ld o set_ld for l=%Le\n", l);
-+ printf ("Got m=%Le instead of l\n", m);
-+ exit (1);
-+ }
-+
-+ /* another similar test which failed with extended double precision and the
-+ generic code for mpfr_set_ld */
-+ /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
-+ l = 4.560596445887084662336528403703e-292;
-+ mpfr_set_ld (x, l, MPFR_RNDN);
-+ m = mpfr_get_ld (x, MPFR_RNDN);
-+ if (m != l)
-+ {
-+ printf ("Error in get_ld o set_ld for l=%Le\n", l);
-+ printf ("Got m=%Le instead of l\n", m);
-+ exit (1);
-+ }
-
- mpfr_clear (x);
- }
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-10-21 20:59:32.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-10-21 21:18:26.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p6";
-+ return "3.0.0-p7";
- }
-diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
---- mpfr-3.0.0-a/PATCHES 2010-11-09 15:15:07.000000000 +0000
-+++ mpfr-3.0.0-b/PATCHES 2010-11-09 15:15:07.000000000 +0000
-@@ -0,0 +1 @@
-+macros
-diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
---- mpfr-3.0.0-a/VERSION 2010-10-21 21:18:26.000000000 +0000
-+++ mpfr-3.0.0-b/VERSION 2010-11-09 15:15:07.000000000 +0000
-@@ -1 +1 @@
--3.0.0-p7
-+3.0.0-p8
-diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
---- mpfr-3.0.0-a/mpfr.h 2010-10-21 21:18:26.000000000 +0000
-+++ mpfr-3.0.0-b/mpfr.h 2010-11-09 15:15:07.000000000 +0000
-@@ -27,7 +27,7 @@
- #define MPFR_VERSION_MAJOR 3
- #define MPFR_VERSION_MINOR 0
- #define MPFR_VERSION_PATCHLEVEL 0
--#define MPFR_VERSION_STRING "3.0.0-p7"
-+#define MPFR_VERSION_STRING "3.0.0-p8"
-
- /* Macros dealing with MPFR VERSION */
- #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
-@@ -67,6 +67,16 @@
- # define _MPFR_H_HAVE_INTMAX_T 1
- #endif
-
-+/* Avoid some problems with macro expansion if the user defines macros
-+ with the same name as keywords. By convention, identifiers and macro
-+ names starting with mpfr_ are reserved by MPFR. */
-+typedef void mpfr_void;
-+typedef int mpfr_int;
-+typedef unsigned int mpfr_uint;
-+typedef long mpfr_long;
-+typedef unsigned long mpfr_ulong;
-+typedef size_t mpfr_size_t;
-+
- /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
- Warning! Changing the contents of this enum should be seen as an
- interface change since the old and the new types are not compatible
-@@ -136,7 +146,7 @@
- typedef mp_exp_t mpfr_exp_t;
-
- /* Definition of the standard exponent limits */
--#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1))
-+#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
- #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
-
- /* Definition of the main structure */
-@@ -725,13 +735,13 @@
- unexpected results with future compilers and aggressive optimisations.
- Why not working only with signed types, using INT_MIN and LONG_MIN? */
- #if __GMP_MP_SIZE_T_INT
--#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2))
--#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1))
--#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3))
-+#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
-+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
-+#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
- #else
--#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2))
--#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1))
--#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3))
-+#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
-+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
-+#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
- #endif
-
- /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
-@@ -760,9 +770,9 @@
- #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF)
- #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
- #define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF)
--#define mpfr_sgn(_x) \
-- ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
-- (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
-+#define mpfr_sgn(_x) \
-+ ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
-+ (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
- MPFR_SIGN (_x))
-
- /* Prevent them from using as lvalues */
-@@ -805,7 +815,19 @@
- Moreover casts to unsigned long have been added to avoid warnings in
- programs that use MPFR and are compiled with -Wconversion; such casts
- are OK since if X is a constant expression, then (unsigned long) X is
-- also a constant expression, so that the optimizations still work. */
-+ also a constant expression, so that the optimizations still work. The
-+ warnings are probably related to the following two bugs:
-+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
-+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
-+ and the casts could be removed once these bugs are fixed.
-+ Casts shouldn't be used on the generic calls (to the ..._2exp functions),
-+ where implicit conversions are performed. Indeed, having at least one
-+ implicit conversion in the macro allows the compiler to emit diagnostics
-+ when normally expected, for instance in the following call:
-+ mpfr_set_ui (x, "foo", MPFR_RNDN);
-+ If this is not possible (for future macros), one of the tricks described
-+ on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
-+ be used. */
- #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
- #if (__GNUC__ >= 2)
- #undef mpfr_cmp_ui
-@@ -813,45 +835,45 @@
- But warning! mpfr_sgn is specified as a macro in the API, thus the macro
- mustn't be used if side effects are possible, like here. */
- #define mpfr_cmp_ui(_f,_u) \
-- (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
-+ (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
- (mpfr_sgn) (_f) : \
-- mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
-+ mpfr_cmp_ui_2exp ((_f), (_u), 0))
- #undef mpfr_cmp_si
--#define mpfr_cmp_si(_f,_s) \
-- (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
-- mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \
-- mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
-+#define mpfr_cmp_si(_f,_s) \
-+ (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
-+ mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \
-+ mpfr_cmp_si_2exp ((_f), (_s), 0))
- #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
- #undef mpfr_set_ui
- #define mpfr_set_ui(_f,_u,_r) \
-- (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \
-+ (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
- __extension__ ({ \
- mpfr_ptr _p = (_f); \
- _p->_mpfr_sign = 1; \
- _p->_mpfr_exp = __MPFR_EXP_ZERO; \
-- (void) (_r); 0; }) : \
-- mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
-+ (mpfr_void) (_r); 0; }) : \
-+ mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
- #endif
- #undef mpfr_set_si
- #define mpfr_set_si(_f,_s,_r) \
-- (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \
-- mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \
-- mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
-+ (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
-+ mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \
-+ mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
- #endif
- #endif
-
- /* Macro version of mpfr_stack interface for fast access */
--#define mpfr_custom_get_size(p) ((size_t) \
-+#define mpfr_custom_get_size(p) ((mpfr_size_t) \
- (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
- #define mpfr_custom_init(m,p) do {} while (0)
--#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d))
-+#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
- #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
- #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
- #define mpfr_custom_init_set(x,k,e,p,m) do { \
- mpfr_ptr _x = (x); \
- mpfr_exp_t _e; \
- mpfr_kind_t _t; \
-- int _s, _k; \
-+ mpfr_int _s, _k; \
- _k = (k); \
- if (_k >= 0) { \
- _t = (mpfr_kind_t) _k; \
-@@ -868,11 +890,13 @@
- _x->_mpfr_exp = _e; \
- _x->_mpfr_d = (mp_limb_t*) (m); \
- } while (0)
--#define mpfr_custom_get_kind(x) \
-- ( (x)->_mpfr_exp > __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
-- : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x) \
-- : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND \
-- : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
-+#define mpfr_custom_get_kind(x) \
-+ ( (x)->_mpfr_exp > __MPFR_EXP_INF ? \
-+ (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \
-+ : (x)->_mpfr_exp == __MPFR_EXP_INF ? \
-+ (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \
-+ : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \
-+ : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
-
-
- #endif /* MPFR_USE_NO_MACRO */
-diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
---- mpfr-3.0.0-a/version.c 2010-10-21 21:18:26.000000000 +0000
-+++ mpfr-3.0.0-b/version.c 2010-11-09 15:15:07.000000000 +0000
-@@ -25,5 +25,5 @@
- const char *
- mpfr_get_version (void)
- {
-- return "3.0.0-p7";
-+ return "3.0.0-p8";
- }
diff --git a/tools/mpfr/patches/001-no_tests.patch b/tools/mpfr/patches/001-no_tests.patch
deleted file mode 100644
index 08c1a4ff4..000000000
--- a/tools/mpfr/patches/001-no_tests.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Index: mpfr-3.0.0/Makefile.am
-===================================================================
---- mpfr-3.0.0.orig/Makefile.am
-+++ mpfr-3.0.0/Makefile.am
-@@ -12,7 +12,7 @@
- AUTOMAKE_OPTIONS = gnu ansi2knr
- ACLOCAL_AMFLAGS = -I m4
-
--SUBDIRS = tests
-+SUBDIRS =
-
- nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER FAQ.html NEWS TODO \
- examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \
-Index: mpfr-3.0.0/Makefile.in
-===================================================================
---- mpfr-3.0.0.orig/Makefile.in
-+++ mpfr-3.0.0/Makefile.in
-@@ -357,7 +357,7 @@ top_builddir = @top_builddir@
- top_srcdir = @top_srcdir@
- AUTOMAKE_OPTIONS = gnu ansi2knr
- ACLOCAL_AMFLAGS = -I m4
--SUBDIRS = tests
-+SUBDIRS =
- nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER FAQ.html NEWS TODO \
- examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \
- examples/version.c
diff --git a/tools/mpfr/patches/001-only_src.patch b/tools/mpfr/patches/001-only_src.patch
new file mode 100644
index 000000000..e6579b211
--- /dev/null
+++ b/tools/mpfr/patches/001-only_src.patch
@@ -0,0 +1,22 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -12,7 +12,7 @@
+ AUTOMAKE_OPTIONS = gnu
+ ACLOCAL_AMFLAGS = -I m4
+
+-SUBDIRS = doc src tests tune
++SUBDIRS = src
+
+ nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER NEWS TODO \
+ examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -294,7 +294,7 @@ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ AUTOMAKE_OPTIONS = gnu
+ ACLOCAL_AMFLAGS = -I m4
+-SUBDIRS = doc src tests tune
++SUBDIRS = src
+ nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER NEWS TODO \
+ examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \
+ examples/version.c
diff --git a/tools/mtools/Makefile b/tools/mtools/Makefile
index 8d227c147..12993458c 100644
--- a/tools/mtools/Makefile
+++ b/tools/mtools/Makefile
@@ -16,6 +16,9 @@ PKG_CAT:=zcat
include $(INCLUDE_DIR)/host-build.mk
+HOST_CONFIGURE_VARS += \
+ ac_cv_header_iconv_h=no
+
HOST_LDFLAGS += $(HOST_STATIC_LINKING)
define Host/Compile
diff --git a/tools/patch/Makefile b/tools/patch/Makefile
new file mode 100644
index 000000000..def829909
--- /dev/null
+++ b/tools/patch/Makefile
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=patch
+PKG_VERSION:=2.7.1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=ftp://ftp.gnu.org/gnu/patch
+PKG_MD5SUM:=e9ae5393426d3ad783a300a338c09b72
+
+include $(INCLUDE_DIR)/host-build.mk
+
+$(eval $(call HostBuild))
diff --git a/tools/quilt/Makefile b/tools/quilt/Makefile
index 510d8f6fd..541e656af 100644
--- a/tools/quilt/Makefile
+++ b/tools/quilt/Makefile
@@ -15,12 +15,8 @@ PKG_MD5SUM:=f77adda60039ffa753f3c584a286f12b
include $(INCLUDE_DIR)/host-build.mk
-GETOPT:=$(shell which getopt)
-
HOST_CONFIGURE_ARGS += \
- --with-patch=$(PATCH) \
- --with-find=$(FIND) \
- --with-getopt=$(GETOPT)
+ --with-find=$(FIND)
define Host/Configure
cd $(HOST_BUILD_DIR) && autoconf
diff --git a/tools/sed/Makefile b/tools/sed/Makefile
index 71e1bc9e0..27169540b 100644
--- a/tools/sed/Makefile
+++ b/tools/sed/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -7,11 +7,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sed
-PKG_VERSION:=4.2.1
+PKG_VERSION:=4.2.2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@GNU/$(PKG_NAME)
-PKG_MD5SUM:=7d310fbd76e01a01115075c1fd3f455a
+PKG_MD5SUM:=7ffe1c7cdc3233e1e0c4b502df253974
PKG_CAT:=bzcat
export SED:=
diff --git a/tools/squashfs4/patches/180-openbsd_compat.patch b/tools/squashfs4/patches/180-openbsd_compat.patch
new file mode 100644
index 000000000..6d7a857a0
--- /dev/null
+++ b/tools/squashfs4/patches/180-openbsd_compat.patch
@@ -0,0 +1,26 @@
+diff -Nur squashfs4.2.orig/squashfs-tools/mksquashfs.c squashfs4.2/squashfs-tools/mksquashfs.c
+--- squashfs4.2.orig/squashfs-tools/mksquashfs.c Tue Mar 5 16:20:49 2013
++++ squashfs4.2/squashfs-tools/mksquashfs.c Tue Mar 5 16:25:10 2013
+@@ -32,6 +32,9 @@
+ #include <stdio.h>
+ #include <stddef.h>
+ #include <sys/time.h>
++#if defined(__OpenBSD__)
++#include <sys/param.h>
++#endif
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+diff -Nur squashfs4.2.orig/squashfs-tools/unsquashfs.h squashfs4.2/squashfs-tools/unsquashfs.h
+--- squashfs4.2.orig/squashfs-tools/unsquashfs.h Tue Mar 5 16:20:49 2013
++++ squashfs4.2/squashfs-tools/unsquashfs.h Tue Mar 5 16:25:57 2013
+@@ -25,6 +25,9 @@
+ #define TRUE 1
+ #define FALSE 0
+ #include <stdio.h>
++#if defined(__OpenBSD__)
++#include <sys/param.h>
++#endif
+ #include <sys/types.h>
+ #include <unistd.h>
+ #include <stdlib.h>
diff --git a/tools/upx/Makefile b/tools/upx/Makefile
index 3e7623201..c162e557c 100644
--- a/tools/upx/Makefile
+++ b/tools/upx/Makefile
@@ -21,7 +21,8 @@ include $(INCLUDE_DIR)/host-build.mk
define Host/Compile
rm -f $(HOST_BUILD_DIR)/src/.depend
$(MAKE) UPX_LZMADIR="$(BUILD_DIR_HOST)/lzma-4.65" -C $(HOST_BUILD_DIR)/src \
- CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)"
+ CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)" \
+ CXX="$(HOSTCXX)"
endef
define Host/Install
diff --git a/tools/yaffs2/patches/110-openbsd-compat.patch b/tools/yaffs2/patches/110-openbsd-compat.patch
new file mode 100644
index 000000000..cfafc1ca7
--- /dev/null
+++ b/tools/yaffs2/patches/110-openbsd-compat.patch
@@ -0,0 +1,14 @@
+diff -Nur yaffs2_android.orig/yaffs2/yaffs_guts.h yaffs2_android/yaffs2/yaffs_guts.h
+--- yaffs2_android.orig/yaffs2/yaffs_guts.h Sun Feb 15 16:23:50 2009
++++ yaffs2_android/yaffs2/yaffs_guts.h Tue Mar 5 15:45:21 2013
+@@ -823,6 +823,10 @@
+ int yaffs_SetAttributes(yaffs_Object * obj, struct iattr *attr);
+ int yaffs_GetAttributes(yaffs_Object * obj, struct iattr *attr);
+
++#if defined(__OpenBSD__)
++#define loff_t off_t
++#endif
++
+ /* File operations */
+ int yaffs_ReadDataFromFile(yaffs_Object * obj, __u8 * buffer, loff_t offset,
+ int nBytes);