code:
From 67faeb7d58e0d25a50d36788ed49ed383b92e090 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Mon, 26 Mar 2018 11:08:17 +0300
Subject: [PATCH] add ARMv7 support

---
 src/arch/arm.h                           |  75 +++++-
 src/os/linux/arm/Makefile.am             |   9 +-
 src/os/linux/arm/Makefile.in             | 166 ++++++++----
 src/os/linux/arm/callNative.S            |  12 +-
 src/os/linux/arm/callNativeEABI.S        |   8 +-
 src/os/linux/arm/callNativeEABIHard.S    | 315 +++++++++++++++++++++++
 src/os/linux/arm/callNativeEABIHardARM.S | 266 +++++++++++++++++++
 src/os/linux/arm/dll_md.c                |  61 ++++-
 8 files changed, 843 insertions(+), 69 deletions(-)
 create mode 100644 src/os/linux/arm/callNativeEABIHard.S
 create mode 100644 src/os/linux/arm/callNativeEABIHardARM.S

diff --git a/src/arch/arm.h b/src/arch/arm.h
index ccf68c4..d2c0318 100644
--- a/src/arch/arm.h
+++ b/src/arch/arm.h
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007
- * Robert Lougher <rob@lougher.org.uk>.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
+ * 2014 Robert Lougher <rob@jamvm.org.uk>.
  *
  * This file is part of JamVM.
  *
@@ -21,10 +21,16 @@

 #define OS_ARCH "arm"

-/* Override default min and max heap sizes.  ARM machines are
-   usually embedded, and the standard defaults are too large. */
-#define DEFAULT_MAX_HEAP 16*MB
+/* Override minimum min heap size.  The initial heap size is a ratio
+   of the physical memory, but it must be at least the minimum min
+   size.  The normal setting is too large for ARM machines as they
+   are usually embedded. */
+#define MIN_MIN_HEAP 1*MB
+
+/* Likewise, override the default min/max heap sizes used when the
+   size of physical memory is not available */
 #define DEFAULT_MIN_HEAP 1*MB
+#define DEFAULT_MAX_HEAP 64*MB

 #ifdef DIRECT
 #define HANDLER_TABLE_T static const void
@@ -51,6 +57,36 @@
 /* Needed for i386 -- empty here */
 #define FPU_HACK

+#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__)
+#define COMPARE_AND_SWAP_32(addr, old_val, new_val)       \
+({                                                        \
+    int result, read_val;                                 \
+    __asm__ __volatile__ ("                               \
+        1:      mov %0, #0;                               \
+                ldrex %1, [%2];                           \
+                cmp %3, %1;                               \
+                bne 2f;                                   \
+                strex %0, %4, [%2];                       \
+                cmp %0, #1;                               \
+                beq 1b;                                   \
+                mov %0, #1;                               \
+        2:"                                               \
+    : "=&r" (result), "=&r" (read_val)                    \
+    : "r" (addr), "r" (old_val), "r" (new_val)            \
+    : "cc", "memory");                                    \
+    result;                                               \
+})
+
+#define COMPARE_AND_SWAP(addr, old_val, new_val)          \
+        COMPARE_AND_SWAP_32(addr, old_val, new_val)
+
+#define LOCKWORD_READ(addr) *addr
+#define LOCKWORD_WRITE(addr, value) *addr = value
+#define LOCKWORD_COMPARE_AND_SWAP(addr, old_val, new_val) \
+        COMPARE_AND_SWAP(addr, old_val, new_val)
+
+#else
+
 #define LOCKWORD_COMPARE_AND_SWAP(addr, old_val, new_val) \
 ({                                                        \
     int result, read_val;                                 \
@@ -94,7 +130,7 @@ do {                                                      \
     : "r" (addr), "r" (new_val)                           \
     : "cc", "memory");                                    \
 } while(0)
-
+#endif

 #ifdef __ARM_EABI__
 #define FLUSH_CACHE(addr, length)                         \
@@ -124,8 +160,33 @@ do {                                                      \
 }
 #endif

+#define GEN_REL_JMP(target_addr, patch_addr, patch_size)  \
+({                                                        \
+    int patched = FALSE;                                  \
+                                                          \
+    if(patch_size >= 4) {                                 \
+        /* Guard against the pointer difference being     \
+           larger than the signed range */                \
+        long long offset = (uintptr_t)(target_addr) -     \
+                           (uintptr_t)(patch_addr) - 8;   \
+                                                          \
+        if(offset >= -1<<25 && offset < 1<<25) {          \
+            *(int*)(patch_addr) = offset>>2 & 0x00ffffff  \
+                                            | 0xea000000; \
+            patched = TRUE;                               \
+        }                                                 \
+    }                                                     \
+    patched;                                              \
+})
+
+#ifdef __ARM_ARCH_7A__
+#define MBARRIER() __asm__ __volatile__ ("dmb" ::: "memory")
+#define UNLOCK_MBARRIER() __asm__ __volatile__ ("dmb" ::: "memory")
+#define JMM_LOCK_MBARRIER() __asm__ __volatile__ ("dmb" ::: "memory")
+#define JMM_UNLOCK_MBARRIER() __asm__ __volatile__ ("dmb" ::: "memory")
+#else
 #define MBARRIER() __asm__ __volatile__ ("" ::: "memory")
 #define UNLOCK_MBARRIER() __asm__ __volatile__ ("" ::: "memory")
 #define JMM_LOCK_MBARRIER() __asm__ __volatile__ ("" ::: "memory")
 #define JMM_UNLOCK_MBARRIER() __asm__ __volatile__ ("" ::: "memory")
-
+#endif
diff --git a/src/os/linux/arm/Makefile.am b/src/os/linux/arm/Makefile.am
index d18ea5a..74e7786 100644
--- a/src/os/linux/arm/Makefile.am
+++ b/src/os/linux/arm/Makefile.am
@@ -1,6 +1,6 @@
 ##
-## Copyright (C) 2003, 2004, 2005, 2006, 2007
-## Robert Lougher <rob@lougher.org.uk>.
+## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012
+## Robert Lougher <rob@jamvm.org.uk>.
 ##
 ## This file is part of JamVM.
 ##
@@ -19,10 +19,11 @@
 ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 ##

-EXTRA_DIST = callNativeOABI.S callNativeEABI.S
+EXTRA_DIST = callNativeOABI.S callNativeEABI.S callNativeEABIHard.S \
+             callNativeEABIHardARM.S

 noinst_LTLIBRARIES = libnative.la
 libnative_la_SOURCES = init.c dll_md.c callNative.S

-AM_CPPFLAGS = -I$(top_builddir)/src
+AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src
 AM_CCASFLAGS = -I$(top_builddir)/src
diff --git a/src/os/linux/arm/Makefile.in b/src/os/linux/arm/Makefile.in
index 63b21ad..6d44ea9 100644
--- a/src/os/linux/arm/Makefile.in
+++ b/src/os/linux/arm/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
 # @configure_input@

 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,9 +16,27 @@
 @SET_MAKE@

 VPATH = @srcdir@
+am__make_dryrun = \
+  { \
+    am__dry=no; \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
+          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+      *) \
+        for am__flg in $$MAKEFLAGS; do \
+          case $$am__flg in \
+            *=*|--*) ;; \
+            *n*) am__dry=yes; break;; \
+          esac; \
+        done;; \
+    esac; \
+    test $$am__dry = yes; \
+  }
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -42,13 +61,15 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/src/config.h
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libnative_la_LIBADD =
 am_libnative_la_OBJECTS = init.lo dll_md.lo callNative.lo
 libnative_la_OBJECTS = $(am_libnative_la_OBJECTS)
-DEFAULT_INCLUDES = -I. -I$(top_builddir)/src@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)
 LTCPPASCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -65,6 +86,11 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	$(LDFLAGS) -o $@
 SOURCES = $(libnative_la_SOURCES)
 DIST_SOURCES = $(libnative_la_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -84,21 +110,18 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
-ECHO = @ECHO@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -106,21 +129,30 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 JAVAC = @JAVAC@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
@@ -133,9 +165,9 @@ abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
 ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
@@ -149,6 +181,7 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 builddir = @builddir@
+classlib = @classlib@
 datadir = @datadir@
 datarootdir = @datarootdir@
 docdir = @docdir@
@@ -181,15 +214,18 @@ sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 use_zip_no = @use_zip_no@
 use_zip_yes = @use_zip_yes@
 with_classpath_install_dir = @with_classpath_install_dir@
-EXTRA_DIST = callNativeOABI.S callNativeEABI.S
+EXTRA_DIST = callNativeOABI.S callNativeEABI.S callNativeEABIHard.S \
+             callNativeEABIHardARM.S
+
 noinst_LTLIBRARIES = libnative.la
 libnative_la_SOURCES = init.c dll_md.c callNative.S
-AM_CPPFLAGS = -I$(top_builddir)/src
+AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src
 AM_CCASFLAGS = -I$(top_builddir)/src
 all: all-am

@@ -199,14 +235,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/os/linux/arm/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu  src/os/linux/arm/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/os/linux/arm/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/os/linux/arm/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -224,6 +260,7 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):

 clean-noinstLTLIBRARIES:
 	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@@ -233,7 +270,7 @@ clean-noinstLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-libnative.la: $(libnative_la_OBJECTS) $(libnative_la_DEPENDENCIES)
+libnative.la: $(libnative_la_OBJECTS) $(libnative_la_DEPENDENCIES) $(EXTRA_libnative_la_DEPENDENCIES)
 	$(LINK)  $(libnative_la_OBJECTS) $(libnative_la_LIBADD) $(LIBS)

 mostlyclean-compile:
@@ -248,42 +285,42 @@ distclean-compile:

 .S.o:
 @am__fastdepCCAS_TRUE@	$(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCCAS_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCCAS_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCCAS_FALSE@	$(CPPASCOMPILE) -c -o $@ $<

 .S.obj:
 @am__fastdepCCAS_TRUE@	$(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCCAS_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCCAS_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCCAS_FALSE@	$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`

 .S.lo:
 @am__fastdepCCAS_TRUE@	$(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCCAS_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCCAS_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCCAS_FALSE@	$(LTCPPASCOMPILE) -c -o $@ $<

 .c.o:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c $<

 .c.obj:
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`

 .c.lo:
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -299,45 +336,49 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS

 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique

 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"

 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -358,13 +399,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -382,16 +427,22 @@ install-am: all-am

 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:

 clean-generic:

 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -413,6 +464,8 @@ dvi-am:

 html: html-am

+html-am:
+
 info: info-am

 info-am:
@@ -421,18 +474,28 @@ install-data-am:

 install-dvi: install-dvi-am

+install-dvi-am:
+
 install-exec-am:

 install-html: install-html-am

+install-html-am:
+
 install-info: install-info-am

+install-info-am:
+
 install-man:

 install-pdf: install-pdf-am

+install-pdf-am:
+
 install-ps: install-ps-am

+install-ps-am:
+
 installcheck-am:

 maintainer-clean: maintainer-clean-am
@@ -470,6 +533,7 @@ uninstall-am:
 	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
 	pdf pdf-am ps ps-am tags uninstall uninstall-am

+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/src/os/linux/arm/callNative.S b/src/os/linux/arm/callNative.S
index 39ab6d3..245afd1 100644
--- a/src/os/linux/arm/callNative.S
+++ b/src/os/linux/arm/callNative.S
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007
- * Robert Lougher <rob@lougher.org.uk>.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011, 2012
+ * Robert Lougher <rob@jamvm.org.uk>.
  *
  * This file is part of JamVM.
  *
@@ -23,7 +23,15 @@

 #ifndef USE_FFI
 #ifdef __ARM_EABI__
+#ifdef __ARM_PCS_VFP
+#ifdef __ARM_ARCH_7A__
+#include "callNativeEABIHard.S"
+#else
+#include "callNativeEABIHardARM.S"
+#endif
+#else
 #include "callNativeEABI.S"
+#endif
 #else
 #include "callNativeOABI.S"
 #endif
diff --git a/src/os/linux/arm/callNativeEABI.S b/src/os/linux/arm/callNativeEABI.S
index 5effa57..3a7539e 100644
--- a/src/os/linux/arm/callNativeEABI.S
+++ b/src/os/linux/arm/callNativeEABI.S
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007
- * Robert Lougher <rob@lougher.org.uk>.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011
+ * Robert Lougher <rob@jamvm.org.uk>.
  *
  * This file is part of JamVM.
  *
@@ -95,8 +95,12 @@ done:
         ldmfd   sp!, {r2, r3}

         /* Call the function */
+#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
         mov     lr, pc
         bx      ip
+#else
+        blx     ip
+#endif

         subs    r4, r4, #8              /* Pop argument area */
                                         /* (minus 8 for r2/r3) */
diff --git a/src/os/linux/arm/callNativeEABIHard.S b/src/os/linux/arm/callNativeEABIHard.S
new file mode 100644
index 0000000..5d5785b
--- /dev/null
+++ b/src/os/linux/arm/callNativeEABIHard.S
@@ -0,0 +1,315 @@
+/*
+ * Copyright (C) 2011, 2012 Robert Lougher <rob@jamvm.org.uk>.
+ *
+ * This file is part of JamVM.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+        .text
+        .syntax unified
+        .arch armv7-a
+        .thumb
+        .align  2
+        .global callJNIMethod
+        .type   callJNIMethod,function
+
+/*
+ * Arguments passed in:
+ *
+ * r0 JNIEnv
+ * r1 class or NULL
+ * r2 sig
+ * r3 extra arg
+ * sp + 0 ostack
+ * sp + 4 function pntr
+ * sp + 8 args count
+ */
+
+/* Register usage :
+ *
+ * r11 function pntr
+ * lr ostack pntr
+ * ip args pntr
+ * r8 sig pntr
+ * r10 extra stack
+ * r6 fp backfill
+ * r4 fp reg
+ * r7 int reg
+ * r5 scratch
+ * r3, r2 outgoing int args
+ * r1 outgoing class or this pntr
+ * r0 outgoing JNIEnv (as passed in)
+ *
+ * s0 - s16 (d0 - d7) outgoing float args
+ */
+
+callJNIMethod:
+        stmfd   sp!, {r4, r5, r6, r7, r8, r10, r11, lr}
+        ldr     lr, [sp, #32]           /* get ostack pntr */
+        ldr     r11, [sp, #36]          /* get function pntr */
+
+        cmp     r1, #0                  /* is method non-static? */
+        it      eq
+        ldreq   r1, [lr], #4            /* yes, load r1 with "this" */
+
+        mov     r10, r3
+        subs    sp, sp, r3              /* allocate room for stacked */
+        add     r8, r2, #1              /* init sig pntr -- skipping '(' */
+
+        mov     ip, sp                  /* init loop pntr */
+
+        mov     r7, #2
+        mov     r4, #16
+        mov     r6, #0
+
+scan_sig:
+        ldrb    r5, [r8], #1
+
+        cmp     r5, #41                 /* ')' */
+        beq     done
+
+        cmp     r5, #70                 /* 'F' */
+        beq     float
+
+        cmp     r5, #68                 /* 'D' */
+        beq     double
+
+        cmp     r5, #74                 /* 'J' */
+        beq     long
+
+skip_brackets:
+        cmp     r5, #91                 /* '[' */
+        itt     eq
+        ldrbeq  r5, [r8], #1
+        beq     skip_brackets
+
+        cmp     r5, #76                 /* 'L' */
+        bne     int
+
+skip_ref:
+        ldrb    r5, [r8], #1
+        cmp     r5, #59                 /* ';' */
+        bne     skip_ref
+
+int:
+        cbz     r7, stack_int
+
+        subs    r7, r7, #1
+        ite     ne
+        ldrne   r2, [lr], #4
+        ldreq   r3, [lr], #4
+
+        b       scan_sig
+
+float:
+        cbz     r6, no_backfill
+
+        sub     r5, r6, #1
+        mov     r6, #0
+        b       load_float
+
+no_backfill:
+        cbz     r4, stack_int
+
+        sub     r4, r4, #1
+        mov     r5, r4
+
+load_float:
+        add     lr, lr, #4
+        tbb     [pc, r5]
+
+float_table:
+        .byte (s15-float_table)/2
+        .byte (s14-float_table)/2
+        .byte (s13-float_table)/2
+        .byte (s12-float_table)/2
+        .byte (s11-float_table)/2
+        .byte (s10-float_table)/2
+        .byte (s9-float_table)/2
+        .byte (s8-float_table)/2
+        .byte (s7-float_table)/2
+        .byte (s6-float_table)/2
+        .byte (s5-float_table)/2
+        .byte (s4-float_table)/2
+        .byte (s3-float_table)/2
+        .byte (s2-float_table)/2
+        .byte (s1-float_table)/2
+        .byte (s0-float_table)/2
+
+stack_int:
+        ldr     r5, [lr], #4
+        str     r5, [ip], #4
+        b       scan_sig
+
+s0:
+        vldr    s0, [lr, #-4]
+        b       scan_sig
+s1:
+        vldr    s1, [lr, #-4]
+        b       scan_sig
+s2:
+        vldr    s2, [lr, #-4]
+        b       scan_sig
+s3:
+        vldr    s3, [lr, #-4]
+        b       scan_sig
+s4:
+        vldr    s4, [lr, #-4]
+        b       scan_sig
+s5:
+        vldr    s5, [lr, #-4]
+        b       scan_sig
+s6:
+        vldr    s6, [lr, #-4]
+        b       scan_sig
+s7:
+        vldr    s7, [lr, #-4]
+        b       scan_sig
+s8:
+        vldr    s8, [lr, #-4]
+        b       scan_sig
+s9:
+        vldr    s9, [lr, #-4]
+        b       scan_sig
+s10:
+        vldr    s10, [lr, #-4]
+        b       scan_sig
+s11:
+        vldr    s11, [lr, #-4]
+        b       scan_sig
+s12:
+        vldr    s12, [lr, #-4]
+        b       scan_sig
+s13:
+        vldr    s13, [lr, #-4]
+        b       scan_sig
+s14:
+        vldr    s14, [lr, #-4]
+        b       scan_sig
+s15:
+        vldr    s15, [lr, #-4]
+        b       scan_sig
+
+long:
+        cmp     r7, #2
+        mov     r7, #0
+        bne     stack_long
+
+        ldmia   lr!, {r2, r3}
+        b       scan_sig
+
+double:
+        lsrs    r5, r4, #1
+        it      cs
+        movcs   r6, r4
+
+        lsls    r4, r5, #1
+        beq     stack_double
+
+        sub     r4, r4, #2
+        add     lr, lr, #8
+        tbb     [pc, r5]
+
+double_table:
+        .byte 0
+        .byte (d7-double_table)/2
+        .byte (d6-double_table)/2
+        .byte (d5-double_table)/2
+        .byte (d4-double_table)/2
+        .byte (d3-double_table)/2
+        .byte (d2-double_table)/2
+        .byte (d1-double_table)/2
+        .byte (d0-double_table)/2
+        .align 2
+d0:
+        vldr    d0, [lr, #-8]
+        b       scan_sig
+d1:
+        vldr    d1, [lr, #-8]
+        b       scan_sig
+d2:
+        vldr    d2, [lr, #-8]
+        b       scan_sig
+d3:
+        vldr    d3, [lr, #-8]
+        b       scan_sig
+d4:
+        vldr    d4, [lr, #-8]
+        b       scan_sig
+d5:
+        vldr    d5, [lr, #-8]
+        b       scan_sig
+d6:
+        vldr    d6, [lr, #-8]
+        b       scan_sig
+d7:
+        vldr    d7, [lr, #-8]
+        b       scan_sig
+
+stack_double:
+        mov     r6, #0
+
+stack_long:
+        /* Ensure address is 8 byte aligned */
+        add     ip, ip, #7
+        bic     ip, ip, #7
+
+        ldr     r5, [lr], #4
+        str     r5, [ip], #4
+        ldr     r5, [lr], #4
+        str     r5, [ip], #4
+        b       scan_sig
+
+done:
+        /* Call the function */
+        blx     r11
+
+        add     sp, sp, r10             /* Pop argument area */
+
+        ldr     r4, [sp, #32]           /* Reload ostack for */
+                                        /* address of return value */
+
+        ldrb    r5, [r8]                /* Return type */
+
+        cmp     r5, #86                 /* 'V' */
+        beq     return
+
+        cmp     r5, #68                 /* 'D' */
+        beq     return_double
+
+        cmp     r5, #70                 /* 'F' */
+        beq     return_float
+
+        str     r0, [r4], #4            /* Low word */
+
+        cmp     r5, #74                 /* 'J' */
+        it      eq
+        streq   r1, [r4], #4            /* High word */
+
+return:
+        mov     r0, r4                  /* return ostack */
+        ldmfd   sp!, {r4, r5, r6, r7, r8, r10, r11, lr}
+        bx      lr
+
+return_float:
+        vstr    s0, [r4]
+        add     r4, r4, #4
+        b       return
+
+return_double:
+        vstr    d0, [r4]
+        add     r4, r4, #8
+        b       return
diff --git a/src/os/linux/arm/callNativeEABIHardARM.S b/src/os/linux/arm/callNativeEABIHardARM.S
new file mode 100644
index 0000000..3a31acd
--- /dev/null
+++ b/src/os/linux/arm/callNativeEABIHardARM.S
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2011, 2012 Robert Lougher <rob@jamvm.org.uk>.
+ *
+ * This file is part of JamVM.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+        .text
+        .align  2
+        .global callJNIMethod
+        .type   callJNIMethod,function
+
+/*
+ * Arguments passed in:
+ *
+ * r0 JNIEnv
+ * r1 class or NULL
+ * r2 sig
+ * r3 extra arg
+ * sp + 0 ostack
+ * sp + 4 function pntr
+ * sp + 8 args count
+ */
+
+/* Register usage :
+ *
+ * lr ostack pntr
+ * ip scratch
+ * r11 function pntr
+ * r10 fp backfill
+ * r8 fp reg
+ * r7 int reg
+ * r6 args pntr
+ * r5 sig pntr
+ * r4 extra stack
+ * r3, r2 outgoing int args
+ * r1 outgoing class or this pntr
+ * r0 outgoing JNIEnv (as passed in)
+ *
+ * s0 - s16 (d0 - d7) outgoing float args
+ */
+
+callJNIMethod:
+        stmfd   sp!, {r4, r5, r6, r7, r8, r10, r11, lr}
+        ldr     lr, [sp, #32]           /* get ostack pntr */
+        ldr     r11, [sp, #36]          /* get function pntr */
+
+        cmp     r1, #0                  /* is method non-static? */
+        ldreq   r1, [lr], #4            /* yes, load r1 with "this" */
+
+        mov     r4, r3
+        sub     sp, sp, r4              /* allocate room for stacked */
+        add     r5, r2, #1              /* init sig pntr -- skipping '(' */
+
+        mov     r6, sp                  /* init loop pntr */
+
+        mov     r7, #2
+        mov     r8, #16
+        mov     r10, #0
+
+scan_sig:
+        ldrb    ip, [r5], #1
+
+        cmp     ip, #41                 /* ')' */
+        beq     done
+
+        cmp     ip, #70                 /* 'F' */
+        beq     float
+
+        cmp     ip, #68                 /* 'D' */
+        beq     double
+
+        cmp     ip, #74                 /* 'J' */
+        beq     long
+
+skip_brackets:
+        cmp     ip, #91                 /* '[' */
+        ldreqb  ip, [r5], #1
+        beq     skip_brackets
+
+        cmp     ip, #76                 /* 'L' */
+        bne     int
+
+skip_ref:
+        ldrb    ip, [r5], #1
+        cmp     ip, #59                 /* ';' */
+        bne     skip_ref
+
+int:
+        cmp     r7, #0
+        beq     stack_int
+
+        subs    r7, r7, #1
+
+        ldrne   r2, [lr], #4
+        ldreq   r3, [lr], #4
+
+        b       scan_sig
+
+stack_int:
+        ldr     ip, [lr], #4
+        str     ip, [r6], #4
+        b       scan_sig
+
+float:
+        cmp     r10, #0
+        beq     no_backfill
+
+        sub     ip, r10, #1
+        mov     r10, #0
+        b       load_float
+
+no_backfill:
+        cmp     r8, #0
+        beq     stack_int
+
+        sub     r8, r8, #1
+        mov     ip, r8
+
+load_float:
+        add     lr, lr, #4
+        add     pc, pc, ip, lsl #3
+        nop
+
+        flds    s15, [lr, #-4]
+        b       scan_sig
+        flds    s14, [lr, #-4]
+        b       scan_sig
+        flds    s13, [lr, #-4]
+        b       scan_sig
+        flds    s12, [lr, #-4]
+        b       scan_sig
+        flds    s11, [lr, #-4]
+        b       scan_sig
+        flds    s10, [lr, #-4]
+        b       scan_sig
+        flds    s9, [lr, #-4]
+        b       scan_sig
+        flds    s8, [lr, #-4]
+        b       scan_sig
+        flds    s7, [lr, #-4]
+        b       scan_sig
+        flds    s6, [lr, #-4]
+        b       scan_sig
+        flds    s5, [lr, #-4]
+        b       scan_sig
+        flds    s4, [lr, #-4]
+        b       scan_sig
+        flds    s3, [lr, #-4]
+        b       scan_sig
+        flds    s2, [lr, #-4]
+        b       scan_sig
+        flds    s1, [lr, #-4]
+        b       scan_sig
+        flds    s0, [lr, #-4]
+        b       scan_sig
+
+long:
+        cmp     r7, #2
+        mov     r7, #0
+        bne     stack_long
+
+        ldr     r2, [lr], #4
+        ldr     r3, [lr], #4
+        b       scan_sig
+
+double:
+        lsrs    ip, r8, #1
+        movcs   r10, r8
+
+        lsls    r8, ip, #1
+        beq     stack_double
+
+        sub     r8, r8, #2
+        add     lr, lr, #8
+        add     pc, pc, ip, lsl #3
+        nop
+        nop
+        nop
+
+        fldd    d7, [lr, #-8]
+        b       scan_sig
+        fldd    d6, [lr, #-8]
+        b       scan_sig
+        fldd    d5, [lr, #-8]
+        b       scan_sig
+        fldd    d4, [lr, #-8]
+        b       scan_sig
+        fldd    d3, [lr, #-8]
+        b       scan_sig
+        fldd    d2, [lr, #-8]
+        b       scan_sig
+        fldd    d1, [lr, #-8]
+        b       scan_sig
+        fldd    d0, [lr, #-8]
+        b       scan_sig
+
+stack_double:
+        mov     r10, #0
+
+stack_long:
+        /* Ensure address is 8 byte aligned */
+        add     r6, r6, #7
+        bic     r6, r6, #7
+
+        ldr     ip, [lr], #4
+        str     ip, [r6], #4
+        ldr     ip, [lr], #4
+        str     ip, [r6], #4
+        b       scan_sig
+
+done:
+        /* Call the function */
+#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
+        mov     lr, pc
+        bx      r11
+#else
+        blx     r11
+#endif
+
+        add     sp, sp, r4              /* Pop argument area */
+        ldr     r4, [sp, #32]           /* Reload ostack for */
+                                        /* address of return value */
+        ldrb    ip, [r5]                /* Return type */
+
+        cmp     ip, #86                 /* 'V' */
+        beq     return
+
+        cmp     ip, #68                 /* 'D' */
+        beq     return_double
+
+        cmp     ip, #70                 /* 'F' */
+        beq     return_float
+
+        str     r0, [r4], #4            /* Low word */
+
+        cmp     ip, #74                 /* 'J' */
+        streq   r1, [r4], #4            /* High word */
+
+return:
+        mov     r0, r4                  /* return ostack */
+        ldmfd   sp!, {r4, r5, r6, r7, r8, r10, r11, lr}
+        bx      lr
+
+return_float:
+        add     r4, r4, #4
+        fsts    s0, [r4, #-4]
+        b       return
+
+return_double:
+        add     r4, r4, #8
+        fstd    d0, [r4, #-8]
+        b       return
diff --git a/src/os/linux/arm/dll_md.c b/src/os/linux/arm/dll_md.c
index f5df90e..39bdf7c 100644
--- a/src/os/linux/arm/dll_md.c
+++ b/src/os/linux/arm/dll_md.c
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007
- * Robert Lougher <rob@lougher.org.uk>.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011
+ * Robert Lougher <rob@jamvm.org.uk>.
  *
  * This file is part of JamVM.
  *
@@ -31,6 +31,61 @@
  * out stack requirements and then to push arguments.  To
  * save the first scan at call time, the signature is pre-
  * scanned and stack requirement stored in the extra argument. */
+
+#ifdef __ARM_PCS_VFP
+int nativeExtraArg(MethodBlock *mb) {
+    char *sig = mb->type;
+    int fp_backfill = 0;
+    int stack_args = 0;
+    int int_args = 2;
+    int fp_args = 16;
+
+    while(*++sig != ')')
+        switch(*sig) {
+            case 'J':
+                if(int_args < 2)
+                    stack_args = (stack_args + 15) & ~7;
+                int_args = 0;
+                break;
+
+            case 'D':
+                fp_backfill |= fp_args & 1;
+                fp_args &= ~1;
+
+                if(fp_args == 0) {
+                    stack_args = (stack_args + 15) & ~7;
+                    fp_backfill = 0;
+                } else
+                    fp_args -= 2;
+                break;
+
+            case 'F':
+                if(fp_backfill)
+                    fp_backfill = 0;
+                else {
+                    if(fp_args == 0)
+                        stack_args += 4;
+                    else
+                        fp_args--;
+                }
+                break;
+
+            default:
+                if(int_args == 0)
+                    stack_args += 4;
+                else
+                    int_args--;
+
+                if(*sig == '[')
+                    while(*++sig == '[');
+                if(*sig == 'L')
+                    while(*++sig != ';');
+                break;
+        }
+
+    return (stack_args + 7) & ~7;
+}
+#else
 int nativeExtraArg(MethodBlock *mb) {
     char *sig = mb->type;
     int args = 0;
@@ -57,7 +112,7 @@ int nativeExtraArg(MethodBlock *mb) {
        native method, so minimum stack requirement is 8 bytes. */
     return args < 8 ? 8 : args;
 }
-
+#endif
 #else

 /* Under OABI, arguments can be copied onto the stack "as is"
--
2.17.1


code:
From 29055a825af5405e44ffcd59a776f8952bdc7203 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Fri, 15 Dec 2017 16:03:23 +0100
Subject: [PATCH] Port to latest bouncycastle.

---
 .../bouncycastle/OpenPGPSignatureGenerator.java    | 34 ++++++++++------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
index af7beae..34c204f 100644
--- a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
+++ b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
@@ -41,6 +41,11 @@ import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
 import org.bouncycastle.openpgp.PGPSignature;
 import org.bouncycastle.openpgp.PGPSignatureGenerator;
 import org.bouncycastle.openpgp.PGPUtil;
+import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
+import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
+import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
+import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder;
+import org.bouncycastle.openpgp.operator.bc.BcKeyFingerprintCalculator;

 public class OpenPGPSignatureGenerator implements SignatureGenerator {

@@ -101,11 +106,15 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
                 pgpSec = readSecretKey(keyIn);
             }

-            PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(password.toCharArray(),
-                BouncyCastleProvider.PROVIDER_NAME);
-            PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSec.getPublicKey()
-                    .getAlgorithm(), PGPUtil.SHA1, BouncyCastleProvider.PROVIDER_NAME);
-            sGen.initSign(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
+            PBESecretKeyDecryptor decryptor =
+                    new BcPBESecretKeyDecryptorBuilder(new BcPGPDigestCalculatorProvider())
+                    .build(password.toCharArray());
+            PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(decryptor);
+            BcPGPContentSignerBuilder builder = new BcPGPContentSignerBuilder(
+                            pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1);
+
+            PGPSignatureGenerator sGen = new PGPSignatureGenerator(builder);
+            sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);

             in = new FileInputStream(src);
             out = new BCPGOutputStream(new ArmoredOutputStream(new FileOutputStream(dest)));
@@ -116,22 +125,10 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
             }

             sGen.generate().encode(out);
-        } catch (SignatureException e) {
-            IOException ioexc = new IOException();
-            ioexc.initCause(e);
-            throw ioexc;
         } catch (PGPException e) {
             IOException ioexc = new IOException();
             ioexc.initCause(e);
             throw ioexc;
-        } catch (NoSuchAlgorithmException e) {
-            IOException ioexc = new IOException();
-            ioexc.initCause(e);
-            throw ioexc;
-        } catch (NoSuchProviderException e) {
-            IOException ioexc = new IOException();
-            ioexc.initCause(e);
-            throw ioexc;
         } finally {
             if (out != null) {
                 try {
@@ -156,7 +153,8 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {

     private PGPSecretKey readSecretKey(InputStream in) throws IOException, PGPException {
         in = PGPUtil.getDecoderStream(in);
-        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in);
+        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in,
+                        new BcKeyFingerprintCalculator());

         PGPSecretKey key = null;
         for (Iterator it = pgpSec.getKeyRings(); key == null && it.hasNext();) {
--
2.15.1

license: mit


code:
From e760d181abd20ecb98654af63faec7b2a4d61189 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Mon, 25 Jun 2018 15:02:25 +0200
Subject: [PATCH] Rename removes in maps to fix java8.

* src/java/org/apache/commons/collections/MultiHashMap.java:
Rename "V MultiHashMap#remove(K, V)"
to "boolean MulitHashMap#removeMapping(K, V)".
* src/java/org/apache/commons/collections/MultiMap.java:
Rename "V MultiMap#remove(K, V)"
to "boolean MultiMap#removeMapping(K, V)".
* src/java/org/apache/commons/collections/map/MultiKeyMap.java:
Rename "V MultiKeyMap#remove(...)"
to "V MultiKeyMap#removeMultiKey(...)".
* src/java/org/apache/commons/collections/map/MultiValueMap.java:
Rename "V MultiValueMap#remove(K, V)"
to "boolean MultiValueMap#removeMapping(K, V)".
* src/test/org/apache/commons/collections/TestMultiHashMap.java:
Adjust accordingly.
* src/test/org/apache/commons/collections/map/TestMultiKeyMap.java:
Adjust accordingly.
* src/test/org/apache/commons/collections/map/TestMultiValueMap.java:
Adjust accordingly.
---
 .../commons/collections/MultiHashMap.java      |  8 ++++----
 .../apache/commons/collections/MultiMap.java   |  2 +-
 .../commons/collections/map/MultiKeyMap.java   |  8 ++++----
 .../commons/collections/map/MultiValueMap.java |  8 ++++----
 .../commons/collections/TestMultiHashMap.java  | 16 ++++++++--------
 .../collections/map/TestMultiKeyMap.java       | 16 ++++++++--------
 .../collections/map/TestMultiValueMap.java     | 18 +++++++++---------
 7 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/java/org/apache/commons/collections/MultiHashMap.java b/src/java/org/apache/commons/collections/MultiHashMap.java
index 7fec9af..482ecbd 100644
--- a/src/java/org/apache/commons/collections/MultiHashMap.java
+++ b/src/java/org/apache/commons/collections/MultiHashMap.java
@@ -331,21 +331,21 @@ public class MultiHashMap extends HashMap implements MultiMap {
      * @param item  the value to remove
      * @return the value removed (which was passed in), null if nothing removed
      */
-    public Object remove(Object key, Object item) {
+    public boolean removeMapping(Object key, Object item) {
         Collection valuesForKey = getCollection(key);
         if (valuesForKey == null) {
-            return null;
+            return false;
         }
         boolean removed = valuesForKey.remove(item);
         if (removed == false) {
-            return null;
+            return false;
         }
         // remove the list if it is now empty
         // (saves space, and allows equals to work)
         if (valuesForKey.isEmpty()){
             remove(key);
         }
-        return item;
+        return true;
     }

     /**
diff --git a/src/java/org/apache/commons/collections/MultiMap.java b/src/java/org/apache/commons/collections/MultiMap.java
index be9455b..fe54234 100644
--- a/src/java/org/apache/commons/collections/MultiMap.java
+++ b/src/java/org/apache/commons/collections/MultiMap.java
@@ -66,7 +66,7 @@ public interface MultiMap extends Map {
      * @throws ClassCastException if the key or value is of an invalid type
      * @throws NullPointerException if the key or value is null and null is invalid
      */
-    public Object remove(Object key, Object item);
+    public boolean removeMapping(Object key, Object item);

     //-----------------------------------------------------------------------
     /**
diff --git a/src/java/org/apache/commons/collections/map/MultiKeyMap.java b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
index 9e3e02d..0b99b65 100644
--- a/src/java/org/apache/commons/collections/map/MultiKeyMap.java
+++ b/src/java/org/apache/commons/collections/map/MultiKeyMap.java
@@ -197,7 +197,7 @@ public class MultiKeyMap
      * @param key2  the second key
      * @return the value mapped to the removed key, null if key not in map
      */
-    public Object remove(Object key1, Object key2) {
+    public Object removeMultiKey(Object key1, Object key2) {
         int hashCode = hash(key1, key2);
         int index = map.hashIndex(hashCode, map.data.length);
         AbstractHashedMap.HashEntry entry = map.data[index];
@@ -327,7 +327,7 @@ public class MultiKeyMap
      * @param key3  the third key
      * @return the value mapped to the removed key, null if key not in map
      */
-    public Object remove(Object key1, Object key2, Object key3) {
+    public Object removeMultiKey(Object key1, Object key2, Object key3) {
         int hashCode = hash(key1, key2, key3);
         int index = map.hashIndex(hashCode, map.data.length);
         AbstractHashedMap.HashEntry entry = map.data[index];
@@ -467,7 +467,7 @@ public class MultiKeyMap
      * @param key4  the fourth key
      * @return the value mapped to the removed key, null if key not in map
      */
-    public Object remove(Object key1, Object key2, Object key3, Object key4) {
+    public Object removeMultiKey(Object key1, Object key2, Object key3, Object key4) {
         int hashCode = hash(key1, key2, key3, key4);
         int index = map.hashIndex(hashCode, map.data.length);
         AbstractHashedMap.HashEntry entry = map.data[index];
@@ -617,7 +617,7 @@ public class MultiKeyMap
      * @param key5  the fifth key
      * @return the value mapped to the removed key, null if key not in map
      */
-    public Object remove(Object key1, Object key2, Object key3, Object key4, Object key5) {
+    public Object removeMultiKey(Object key1, Object key2, Object key3, Object key4, Object key5) {
         int hashCode = hash(key1, key2, key3, key4, key5);
         int index = map.hashIndex(hashCode, map.data.length);
         AbstractHashedMap.HashEntry entry = map.data[index];
diff --git a/src/java/org/apache/commons/collections/map/MultiValueMap.java b/src/java/org/apache/commons/collections/map/MultiValueMap.java
index f44999b..86eaeb0 100644
--- a/src/java/org/apache/commons/collections/map/MultiValueMap.java
+++ b/src/java/org/apache/commons/collections/map/MultiValueMap.java
@@ -153,19 +153,19 @@ public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
      * @param value the value to remove
      * @return the value removed (which was passed in), null if nothing removed
      */
-    public Object remove(Object key, Object value) {
+    public boolean removeMapping(Object key, Object value) {
         Collection valuesForKey = getCollection(key);
         if (valuesForKey == null) {
-            return null;
+            return false;
         }
         boolean removed = valuesForKey.remove(value);
         if (removed == false) {
-            return null;
+            return false;
         }
         if (valuesForKey.isEmpty()) {
             remove(key);
         }
-        return value;
+        return true;
     }

     /**
diff --git a/src/test/org/apache/commons/collections/TestMultiHashMap.java b/src/test/org/apache/commons/collections/TestMultiHashMap.java
index eca833a..a1de943 100644
--- a/src/test/org/apache/commons/collections/TestMultiHashMap.java
+++ b/src/test/org/apache/commons/collections/TestMultiHashMap.java
@@ -217,7 +217,7 @@ public class TestMultiHashMap extends AbstractTestMap {
         MultiHashMap one = new MultiHashMap();
         Integer value = new Integer(1);
         one.put("One", value);
-        one.remove("One", value);
+        one.removeMapping("One", value);

         MultiHashMap two = new MultiHashMap();
         assertEquals(two, one);
@@ -269,7 +269,7 @@ public class TestMultiHashMap extends AbstractTestMap {
         assertEquals(4, map.totalSize());
         map.remove("A");
         assertEquals(3, map.totalSize());
-        map.remove("B", "BC");
+        map.removeMapping("B", "BC");
         assertEquals(2, map.totalSize());
     }

@@ -292,7 +292,7 @@ public class TestMultiHashMap extends AbstractTestMap {
         map.remove("A");
         assertEquals(0, map.size("A"));
         assertEquals(3, map.size("B"));
-        map.remove("B", "BC");
+        map.removeMapping("B", "BC");
         assertEquals(0, map.size("A"));
         assertEquals(2, map.size("B"));
     }
@@ -464,11 +464,11 @@ public class TestMultiHashMap extends AbstractTestMap {
         map.put("A", "AA");
         map.put("A", "AB");
         map.put("A", "AC");
-        assertEquals(null, map.remove("C", "CA"));
-        assertEquals(null, map.remove("A", "AD"));
-        assertEquals("AC", map.remove("A", "AC"));
-        assertEquals("AB", map.remove("A", "AB"));
-        assertEquals("AA", map.remove("A", "AA"));
+        assertEquals(false, map.removeMapping("C", "CA"));
+        assertEquals(false, map.removeMapping("A", "AD"));
+        assertEquals(true, map.removeMapping("A", "AC"));
+        assertEquals(true, map.removeMapping("A", "AB"));
+        assertEquals(true, map.removeMapping("A", "AA"));
         assertEquals(new MultiHashMap(), map);
     }

diff --git a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
index b1ee3d0..b18f480 100644
--- a/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
+++ b/src/test/org/apache/commons/collections/map/TestMultiKeyMap.java
@@ -315,34 +315,34 @@ public class TestMultiKeyMap extends AbstractTestIterableMap {
             switch (key.size()) {
                 case 2:
                 assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1)));
-                assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1)));
+                assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
                 assertEquals(size - 1, multimap.size());
-                assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1)));
+                assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1)));
                 break;
                 case 3:
                 assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
-                assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2)));
+                assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
                 assertEquals(size - 1, multimap.size());
-                assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2)));
+                assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2)));
                 break;
                 case 4:
                 assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
-                assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
+                assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
                 assertEquals(size - 1, multimap.size());
-                assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
+                assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)));
                 break;
                 case 5:
                 assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
-                assertEquals(value, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
+                assertEquals(value, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
                 assertEquals(size - 1, multimap.size());
-                assertEquals(null, multimap.remove(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
+                assertEquals(null, multimap.removeMultiKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
                 assertEquals(false, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)));
                 break;
                 default:
diff --git a/src/test/org/apache/commons/collections/map/TestMultiValueMap.java b/src/test/org/apache/commons/collections/map/TestMultiValueMap.java
index b9a5ac8..9ecc269 100644
--- a/src/test/org/apache/commons/collections/map/TestMultiValueMap.java
+++ b/src/test/org/apache/commons/collections/map/TestMultiValueMap.java
@@ -161,7 +161,7 @@ public class TestMultiValueMap extends TestCase {
         MultiValueMap one = new MultiValueMap();
         Integer value = new Integer(1);
         one.put("One", value);
-        one.remove("One", value);
+        one.removeMapping("One", value);

         MultiValueMap two = new MultiValueMap();
         assertEquals(two, one);
@@ -187,7 +187,7 @@ public class TestMultiValueMap extends TestCase {
         assertEquals(4, map.totalSize());
         map.remove("A");
         assertEquals(3, map.totalSize());
-        map.remove("B", "BC");
+        map.removeMapping("B", "BC");
         assertEquals(2, map.totalSize());
     }

@@ -204,7 +204,7 @@ public class TestMultiValueMap extends TestCase {
         assertEquals(2, map.size());
         map.remove("A");
         assertEquals(2, map.size());
-        map.remove("B", "BC");
+        map.removeMapping("B", "BC");
         assertEquals(2, map.size());
     }

@@ -227,7 +227,7 @@ public class TestMultiValueMap extends TestCase {
         map.remove("A");
         assertEquals(0, map.size("A"));
         assertEquals(3, map.size("B"));
-        map.remove("B", "BC");
+        map.removeMapping("B", "BC");
         assertEquals(0, map.size("A"));
         assertEquals(2, map.size("B"));
     }
@@ -338,11 +338,11 @@ public class TestMultiValueMap extends TestCase {
         map.put("A", "AA");
         map.put("A", "AB");
         map.put("A", "AC");
-        assertEquals(null, map.remove("C", "CA"));
-        assertEquals(null, map.remove("A", "AD"));
-        assertEquals("AC", map.remove("A", "AC"));
-        assertEquals("AB", map.remove("A", "AB"));
-        assertEquals("AA", map.remove("A", "AA"));
+        assertEquals(false, map.removeMapping("C", "CA"));
+        assertEquals(false, map.removeMapping("A", "AD"));
+        assertEquals(true, map.removeMapping("A", "AC"));
+        assertEquals(true, map.removeMapping("A", "AB"));
+        assertEquals(true, map.removeMapping("A", "AA"));
         assertEquals(new MultiValueMap(), map);
     }

--
2.18.0


code:
From 5803aadd3f209eba1ffbb2cf7bf16778019dbee1 Mon Sep 17 00:00:00 2001
From: fredoboulo <fredoboulo@users.noreply.github.com>
Date: Fri, 23 Feb 2018 23:55:57 +0100
Subject: [PATCH] Fix #524 : V1 and V2 protocol downgrades handle received data
 in handshake buffer

This patch is upstream pull request, see:
https://gihub.com/zeromq/jeromq/pull/527.

It is merged on commit c2afa9c, and we can drop it on the
0.4.4 release.

---
 src/main/java/zmq/io/StreamEngine.java            | 21 ++++++++++--
 src/test/java/zmq/io/AbstractProtocolVersion.java | 41 +++++++++++++----------
 src/test/java/zmq/io/V0ProtocolTest.java          | 12 +++++++
 src/test/java/zmq/io/V1ProtocolTest.java          | 16 +++++++--
 src/test/java/zmq/io/V2ProtocolTest.java          | 16 +++++++--
 5 files changed, 81 insertions(+), 25 deletions(-)

diff --git a/src/main/java/zmq/io/StreamEngine.java b/src/main/java/zmq/io/StreamEngine.java
index b8933c92..fe2f2d8d 100644
--- a/src/main/java/zmq/io/StreamEngine.java
+++ b/src/main/java/zmq/io/StreamEngine.java
@@ -816,9 +816,7 @@ private boolean handshake()
             assert (bufferSize == headerSize);

             //  Make sure the decoder sees the data we have already received.
-            greetingRecv.flip();
-            inpos = greetingRecv;
-            insize = greetingRecv.limit();
+            decodeDataAfterHandshake(0);

             //  To allow for interoperability with peers that do not forward
             //  their subscriptions, we inject a phantom subscription message
@@ -846,6 +844,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V1.revision) {
             }
             encoder = new V1Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
             decoder = new V1Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
+
+            decodeDataAfterHandshake(V2_GREETING_SIZE);
         }
         else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
             //  ZMTP/2.0 framing.
@@ -859,6 +859,8 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
             }
             encoder = new V2Encoder(errno, Config.OUT_BATCH_SIZE.getValue());
             decoder = new V2Decoder(errno, Config.IN_BATCH_SIZE.getValue(), options.maxMsgSize, options.allocator);
+
+            decodeDataAfterHandshake(V2_GREETING_SIZE);
         }
         else {
             zmtpVersion = Protocol.V3;
@@ -904,6 +906,19 @@ else if (greetingRecv.get(revisionPos) == Protocol.V2.revision) {
         return true;
     }

+    private void decodeDataAfterHandshake(int greetingSize)
+    {
+        final int pos = greetingRecv.position();
+        if (pos > greetingSize) {
+            // data is present after handshake
+            greetingRecv.position(greetingSize).limit(pos);
+
+            //  Make sure the decoder sees this extra data.
+            inpos = greetingRecv;
+            insize = greetingRecv.remaining();
+        }
+    }
+
     private Msg identityMsg()
     {
         Msg msg = new Msg(options.identitySize);
diff --git a/src/test/java/zmq/io/AbstractProtocolVersion.java b/src/test/java/zmq/io/AbstractProtocolVersion.java
index e60db403..aa06b4a7 100644
--- a/src/test/java/zmq/io/AbstractProtocolVersion.java
+++ b/src/test/java/zmq/io/AbstractProtocolVersion.java
@@ -18,15 +18,18 @@
 import zmq.SocketBase;
 import zmq.ZError;
 import zmq.ZMQ;
+import zmq.ZMQ.Event;
 import zmq.util.Utils;

 public abstract class AbstractProtocolVersion
 {
+    protected static final int REPETITIONS = 1000;
+
     static class SocketMonitor extends Thread
     {
-        private final Ctx             ctx;
-        private final String          monitorAddr;
-        private final List<ZMQ.Event> events = new ArrayList<>();
+        private final Ctx         ctx;
+        private final String      monitorAddr;
+        private final ZMQ.Event[] events = new ZMQ.Event[1];

         public SocketMonitor(Ctx ctx, String monitorAddr)
         {
@@ -41,15 +44,15 @@ public void run()
             boolean rc = s.connect(monitorAddr);
             assertThat(rc, is(true));
             // Only some of the exceptional events could fire
-            while (true) {
-                ZMQ.Event event = ZMQ.Event.read(s);
-                if (event == null && s.errno() == ZError.ETERM) {
-                    break;
-                }
-                assertThat(event, notNullValue());
-
-                events.add(event);
+
+            ZMQ.Event event = ZMQ.Event.read(s);
+            if (event == null && s.errno() == ZError.ETERM) {
+                s.close();
+                return;
             }
+            assertThat(event, notNullValue());
+
+            events[0] = event;
             s.close();
         }
     }
@@ -69,11 +72,12 @@ public void run()
         boolean rc = ZMQ.setSocketOption(receiver, ZMQ.ZMQ_LINGER, 0);
         assertThat(rc, is(true));

-        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
-        monitor.start();
         rc = ZMQ.monitorSocket(receiver, "inproc://monitor", ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL);
         assertThat(rc, is(true));

+        SocketMonitor monitor = new SocketMonitor(ctx, "inproc://monitor");
+        monitor.start();
+
         rc = ZMQ.bind(receiver, host);
         assertThat(rc, is(true));

@@ -81,17 +85,18 @@ public void run()
         OutputStream out = sender.getOutputStream();
         for (ByteBuffer raw : raws) {
             out.write(raw.array());
-            ZMQ.msleep(100);
         }

         Msg msg = ZMQ.recv(receiver, 0);
         assertThat(msg, notNullValue());
         assertThat(new String(msg.data(), ZMQ.CHARSET), is(payload));

-        ZMQ.msleep(500);
-        assertThat(monitor.events.size(), is(1));
-        assertThat(monitor.events.get(0).event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
-        assertThat((Integer) monitor.events.get(0).arg, is(version));
+        monitor.join();
+
+        final Event event = monitor.events[0];
+        assertThat(event, notNullValue());
+        assertThat(event.event, is(ZMQ.ZMQ_EVENT_HANDSHAKE_PROTOCOL));
+        assertThat((Integer) event.arg, is(version));

         InputStream in = sender.getInputStream();
         byte[] data = new byte[255];
diff --git a/src/test/java/zmq/io/V0ProtocolTest.java b/src/test/java/zmq/io/V0ProtocolTest.java
index bd547d23..1a5b7aef 100644
--- a/src/test/java/zmq/io/V0ProtocolTest.java
+++ b/src/test/java/zmq/io/V0ProtocolTest.java
@@ -10,6 +10,18 @@

 public class V0ProtocolTest extends AbstractProtocolVersion
 {
+    @Test
+    public void testFixIssue524() throws IOException, InterruptedException
+    {
+        for (int idx = 0; idx < REPETITIONS; ++idx) {
+            if (idx % 100 == 0) {
+                System.out.print(idx + " ");
+            }
+            testProtocolVersion0short();
+        }
+        System.out.println();
+    }
+
     @Test(timeout = 2000)
     public void testProtocolVersion0short() throws IOException, InterruptedException
     {
diff --git a/src/test/java/zmq/io/V1ProtocolTest.java b/src/test/java/zmq/io/V1ProtocolTest.java
index e1045f34..764159d0 100644
--- a/src/test/java/zmq/io/V1ProtocolTest.java
+++ b/src/test/java/zmq/io/V1ProtocolTest.java
@@ -10,7 +10,19 @@

 public class V1ProtocolTest extends AbstractProtocolVersion
 {
-    @Test(timeout = 2000)
+    @Test
+    public void testFixIssue524() throws IOException, InterruptedException
+    {
+        for (int idx = 0; idx < REPETITIONS; ++idx) {
+            if (idx % 100 == 0) {
+                System.out.print(idx + " ");
+            }
+            testProtocolVersion1short();
+        }
+        System.out.println();
+    }
+
+    @Test
     public void testProtocolVersion1short() throws IOException, InterruptedException
     {
         List<ByteBuffer> raws = raws(0);
@@ -25,7 +37,7 @@ public void testProtocolVersion1short() throws IOException, InterruptedException
         assertProtocolVersion(1, raws, "abcdefg");
     }

-    @Test(timeout = 2000)
+    @Test
     public void testProtocolVersion1long() throws IOException, InterruptedException
     {
         List<ByteBuffer> raws = raws(0);
diff --git a/src/test/java/zmq/io/V2ProtocolTest.java b/src/test/java/zmq/io/V2ProtocolTest.java
index d5e64bce..7fda31bc 100644
--- a/src/test/java/zmq/io/V2ProtocolTest.java
+++ b/src/test/java/zmq/io/V2ProtocolTest.java
@@ -21,7 +21,19 @@ protected ByteBuffer identity()
                 .put((byte) 0);
     }

-    @Test(timeout = 2000)
+    @Test
+    public void testFixIssue524() throws IOException, InterruptedException
+    {
+        for (int idx = 0; idx < REPETITIONS; ++idx) {
+            if (idx % 100 == 0) {
+                System.out.print(idx + " ");
+            }
+            testProtocolVersion2short();
+        }
+        System.out.println();
+    }
+
+    @Test
     public void testProtocolVersion2short() throws IOException, InterruptedException
     {
         List<ByteBuffer> raws = raws(1);
@@ -38,7 +50,7 @@ public void testProtocolVersion2short() throws IOException, InterruptedException
         assertProtocolVersion(2, raws, "abcdefg");
     }

-    @Test(timeout = 2000)
+    @Test
     public void testProtocolVersion2long() throws IOException, InterruptedException
     {
         List<ByteBuffer> raws = raws(1);


code:
This patch fixes build issues caused by the java compiler not finding the
correct types on some statements.

From 1ac84b58b4383fa118d98c35956d722d11cf449e Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Tue, 22 Aug 2017 20:40:27 +0200
Subject: [PATCH] Fix java files.

---
 .../internal/impl/DelegatingPowerMockRunner.java   | 13 +++++++---
 .../java/org/powermock/reflect/WhiteBoxTest.java   | 30 +++++++++++-----------
 .../reflect/internal/proxy/ClassFactory.java       |  6 ++---
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java b/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java
index 301f854..caecbbd 100644
--- a/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java
+++ b/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java
@@ -98,12 +98,17 @@ implements PowerMockJUnitRunnerDelegate, Filterable {
             @Override
             public Runner call() throws Exception {
                 try {
-                    return Whitebox.invokeConstructor(
-                            testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)
-                            ? testClass.getAnnotation(PowerMockRunnerDelegate.class).value()
-                            : PowerMockRunnerDelegate.DefaultJUnitRunner.class,
+                    if(testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)) {
+                        return Whitebox.invokeConstructor(
+                            testClass.getAnnotation(PowerMockRunnerDelegate.class).value(),
                             new Class[] {Class.class},
                             new Object[] {testClass});
+                    } else {
+                        return Whitebox.invokeConstructor(
+                            PowerMockRunnerDelegate.DefaultJUnitRunner.class,
+                            new Class[] {Class.class},
+                            new Object[] {testClass});
+                    }
                 } catch (ConstructorNotFoundException rootProblem) {
                     if (testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)
                             && JUnitVersion.isGreaterThanOrEqualTo("4.5")) {
diff --git a/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java b/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java
index bf1e2e3..0d60487 100644
--- a/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java
+++ b/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java
@@ -248,7 +248,7 @@ public class WhiteBoxTest {

     @Test
     public void testMethodWithPrimitiveAndWrappedInt_primtive_wrapped() throws Exception {
-        assertEquals(17, Whitebox.invokeMethod(new ClassWithPrivateMethods(), "methodWithPrimitiveAndWrappedInt",
+        assertEquals((Integer)17, Whitebox.invokeMethod(new ClassWithPrivateMethods(), "methodWithPrimitiveAndWrappedInt",
                                                new Class[]{int.class, Integer.class}, 9, Integer.valueOf(8)));
     }

@@ -257,7 +257,7 @@ public class WhiteBoxTest {
         int expected = 123;
         Whitebox.setInternalState(ClassWithInternalState.class, "staticState", expected);
         assertEquals(expected, ClassWithInternalState.getStaticState());
-        assertEquals(expected, Whitebox.getInternalState(ClassWithInternalState.class, "staticState"));
+        assertEquals(expected, (int)Whitebox.getInternalState(ClassWithInternalState.class, "staticState"));
     }

 	@Test
@@ -334,25 +334,25 @@ public class WhiteBoxTest {
     @Test
     public void testInvokeVarArgsMethod_multipleValues() throws Exception {
         ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
-        assertEquals(6, Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3));
+        assertEquals(6, (int)Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3));
     }

     @Test
     public void testInvokeVarArgsMethod_noArguments() throws Exception {
         ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
-        assertEquals(0, Whitebox.invokeMethod(tested, "varArgsMethod"));
+        assertEquals(0, (int)Whitebox.invokeMethod(tested, "varArgsMethod"));
     }

     @Test
     public void testInvokeVarArgsMethod_oneArgument() throws Exception {
         ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
-        assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod", 2));
+        assertEquals(4, (int)Whitebox.invokeMethod(tested, "varArgsMethod", 2));
     }

     @Test
     public void testInvokeVarArgsMethod_invokeVarArgsWithOneArgument() throws Exception {
         ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
-        assertEquals(1, Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[]{int[].class}, 1));
+        assertEquals(1, (int)Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[]{int[].class}, 1));
     }

     @Test
@@ -376,7 +376,7 @@ public class WhiteBoxTest {
         ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
         };
         Whitebox.setInternalState(tested, fieldName, value);
-        assertEquals(value, Whitebox.getInternalState(tested, fieldName));
+        assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName));
     }

     @Test
@@ -387,8 +387,8 @@ public class WhiteBoxTest {
         ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
         };
         Whitebox.setInternalState(tested, fieldName, value);
-        assertEquals(value, Whitebox.getInternalState(tested, fieldName));
-        assertEquals(-1, Whitebox.getInternalState(tested, fieldName, ClassWithInternalState.class));
+        assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName));
+        assertEquals(-1, (int)Whitebox.getInternalState(tested, fieldName, ClassWithInternalState.class));
     }

     @Test(expected = IllegalArgumentException.class)
@@ -398,7 +398,7 @@ public class WhiteBoxTest {
         ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
         };
         Whitebox.setInternalState(tested, fieldName, new Object());
-        assertEquals(value, Whitebox.getInternalState(tested, fieldName));
+        assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName));
     }

     @Test(expected = IllegalArgumentException.class)
@@ -408,7 +408,7 @@ public class WhiteBoxTest {
         ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
         };
         Whitebox.setInternalState(tested, fieldName, (Object) null);
-        assertEquals(value, Whitebox.getInternalState(tested, fieldName));
+        assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName));
     }

     @Test
@@ -417,8 +417,8 @@ public class WhiteBoxTest {
         ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState();
         Whitebox.setInternalState(tested, int.class, value);
         assertEquals(value, (int) Whitebox.getInternalState(tested, int.class));
-        assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState"));
-        assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState",
+        assertEquals(value, (int)Whitebox.getInternalState(tested, "anotherInternalState"));
+        assertEquals(value, (int)Whitebox.getInternalState(tested, "anotherInternalState",
                                                       ClassWithChildThatHasInternalState.class));
     }

@@ -429,7 +429,7 @@ public class WhiteBoxTest {
         Whitebox.setInternalState(tested, int.class, value, ClassWithInternalState.class);
         assertEquals(42, (int) Whitebox.getInternalState(tested, int.class));
         assertEquals(value, (int) Whitebox.getInternalState(tested, int.class, ClassWithInternalState.class));
-        assertEquals(value, Whitebox.getInternalState(tested, "staticState", ClassWithInternalState.class));
+        assertEquals(value, (int)Whitebox.getInternalState(tested, "staticState", ClassWithInternalState.class));
     }

     @Test
@@ -619,7 +619,7 @@ public class WhiteBoxTest {
     @Test
     public void testInvokeMethodWithBothNormalAndVarArgsParameter() throws Exception {
         ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
-        assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3));
+        assertEquals(4, (int)Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3));
     }

     @Test
diff --git a/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java b/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java
index a5e5fda..14b8bbe 100644
--- a/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java
+++ b/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java
@@ -1,8 +1,8 @@
 package org.powermock.reflect.internal.proxy;

-import net.sf.cglib.asm.ClassWriter;
-import net.sf.cglib.asm.MethodVisitor;
-import net.sf.cglib.asm.Opcodes;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;

 class ClassFactory implements Opcodes {

--
2.14.1


code:
From b3b7a305f1278ec414500bf96c4c7a7f634c941b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20Thee=C3=9F?= <theess@subshell.com>
Date: Thu, 15 Sep 2016 13:08:26 +0200
Subject: [PATCH] Dictionary uses stable order. This fixes unit tests.

This is upstream pull request #15:
https://github.com/ngallagher/simplexml/pull/15
This software is unmaintained, this pull request will no get merged.
The patch is modified, to match the directory layout of the tarball.

---
 src/main/java/org/simpleframework/xml/util/Dictionary.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/simpleframework/xml/util/Dictionary.java b/src/main/java/org/simpleframework/xml/util/Dictionary.java
index 077d2514..c7327426 100644
--- a/src/org/simpleframework/xml/util/Dictionary.java
+++ b/src/org/simpleframework/xml/util/Dictionary.java
@@ -19,8 +19,8 @@
 package org.simpleframework.xml.util;

 import java.util.AbstractSet;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;

 /**
  * The Dictionary object represents a mapped set of entry
@@ -134,7 +134,7 @@ public T remove(String name) {
     *
     * @see org.simpleframework.xml.util.Entry
     */
-   private static class Table<T> extends HashMap<String, T> {
+   private static class Table<T> extends LinkedHashMap<String, T> {

       /**
        * Constructor for the Table object. This will


code:
Based on https://anonscm.debian.org/viewvc/pkg-java/trunk/libxerces2-java/debian/patches/03_bootclasspath.patch?revision=14509, adopted for guix

--- xerces-2_11_0/build.xml.orig	2010-11-26 21:42:11.000000000 +0100
+++ xerces-2_11_0/build.xml	2017-03-28 14:04:41.946606996 +0200
@@ -290,13 +290,14 @@
            destdir="${build.dest}"
            source="${javac.source}"
            target="${javac.target}"
-           classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
+           classpath="${build.dir}/classes:${jar.jaxp}:${jar.apis-ext}:${jar.resolver}"
            debug="${debug}" nowarn="true"
            debuglevel="${debuglevel}"
            deprecation="${deprecation}"
            optimize="${optimize}"
            includeAntRuntime="false"
-           includeJavaRuntime="false"
+           includeJavaRuntime="true"
+           bootclasspath="${jar.jaxp}:${jar.apis-ext}:${jar.resolver}"
            excludes="org/xml/sax/**
                 javax/xml/**
                 org/w3c/dom/*
@@ -1451,13 +1452,14 @@
                destdir="${build.dest}"
                source="${javac.source}"
                target="${javac.target}"
-               classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
+               classpath="${build.dir}/classes:${jar.jaxp}:${jar.apis-ext}:${jar.resolver}"
                debug="${debug}"
                debuglevel="${debuglevel}"
                deprecation="${deprecation}"
                optimize="${optimize}"
                includeAntRuntime="false"
-               includeJavaRuntime="false"
+               includeJavaRuntime="true"
+               bootclasspath="${jar.jaxp}:${jar.apis-ext}:${jar.resolver}"
                excludes="org/xml/sax/**
                     javax/xml/**
                     org/w3c/dom/*


code:
Don't unzip the sources which were bundled originally. Guix strips them from
the source and uses pre-build packages.

Taken from https://anonscm.debian.org/viewvc/pkg-java/trunk/libxerces2-java/debian/patches/02_build_dont_unzip.patch?revision=14507

Index: b/build.xml
===================================================================
--- a/build.xml
+++ b/build.xml
@@ -247,7 +247,7 @@
     <copy file="${src.dir}/org/apache/xerces/impl/xpath/regex/message.properties"
       tofile="${build.src}/org/apache/xerces/impl/xpath/regex/message_en.properties"/>

-    <!-- now deal with API's:  -->
+    <!-- not needed for Debian
     <unzip src="${src.apis.zip}" dest="${build.src}">
         <patternset
             includes="org/xml/sax/**
@@ -270,6 +270,7 @@
                 org/w3c/dom/xpath/**"
         />
     </unzip>
+    -->

     <!-- substitute tokens as needed -->
     <replace file="${build.dir}/src/org/apache/xerces/impl/Version.java"
@@ -1232,7 +1233,7 @@
     <replace file="${build.dir}/src/org/apache/xerces/parsers/AbstractSAXParser.java"
              token="return (fConfiguration instanceof XML11Configurable);" value="return false;"/>

-    <!-- now deal with API's:  -->
+    <!-- not needed for Debian
     <unzip src="${src.apis.zip}" dest="${build.src}">
         <patternset
             includes="org/xml/sax/**
@@ -1255,7 +1256,7 @@
                 org/w3c/dom/xpath/**"
         />
     </unzip>
-
+    -->

     <!-- substitute tokens as needed -->
     <replace file="${build.dir}/src/org/apache/xerces/impl/Version.java"


code:
This patch eliminates the need for providing "xjavac", which saves building a
package for the unmaintained "xerces-tools".

Taken from https://anonscm.debian.org/viewvc/pkg-java/trunk/libxerces2-java/debian/patches/01_xjavac_taskdef.patch?revision=14507

Index: b/build.xml
===================================================================
--- a/build.xml
+++ b/build.xml
@@ -39,7 +39,7 @@
   <property name="tools.dir" value="./tools"/>

   <!-- enable compilation under JDK 1.4 and above -->
-  <taskdef name="xjavac" classname="org.apache.xerces.util.XJavac">
+  <taskdef name="xjavac" classname="org.apache.tools.ant.taskdefs.Javac">
     <classpath>
       <pathelement location="${tools.dir}/bin/xjavac.jar"/>
     </classpath>
@@ -291,7 +291,7 @@
            source="${javac.source}"
            target="${javac.target}"
            classpath="${build.dir}/classes:${tools.dir}/${jar.apis}:${tools.dir}/${jar.resolver}:${tools.dir}/${jar.serializer}"
-           debug="${debug}"
+           debug="${debug}" nowarn="true"
            debuglevel="${debuglevel}"
            deprecation="${deprecation}"
            optimize="${optimize}"
@@ -359,7 +359,7 @@
            source="${javac.source}"
            target="${javac.target}"
            classpath="${build.dir}/classes:${tools.dir}/${jar.apis}"
-           debug="${debug}"
+           debug="${debug}" nowarn="true"
            debuglevel="${debuglevel}"
            includeAntRuntime="false"
            includeJavaRuntime="true"/>
@@ -379,7 +379,7 @@
            source="${javac.source}"
            target="${javac.target}"
            classpath="${tools.dir}/${jar.apis}:${build.dir}/classes:./tools/junit.jar"
-           debug="${debug}"
+           debug="${debug}" nowarn="true"
            debuglevel="${debuglevel}"
            includeAntRuntime="false"
            includeJavaRuntime="true"/>


code:
Do not run the test 'test_jbig2dec.py'. It doesn't seem to do anything
and reports failure. TODO: Actually fix the test instead of ignoring it.

diff --git a/Makefile.in b/Makefile.in
index 63982d4..8af1d61 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -93,7 +93,7 @@ host_triplet = @host@
 bin_PROGRAMS = jbig2dec$(EXEEXT)
 noinst_PROGRAMS = test_sha1$(EXEEXT) test_huffman$(EXEEXT) \
 	test_arith$(EXEEXT)
-TESTS = test_sha1$(EXEEXT) test_jbig2dec.py test_huffman$(EXEEXT) \
+TESTS = test_sha1$(EXEEXT) test_huffman$(EXEEXT) \
 	test_arith$(EXEEXT)
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4


code:
From 8cfc9dec37b312a2686f602bbcdd102ca07cca99 Mon Sep 17 00:00:00 2001
From: David Goldblatt <davidgoldblatt@fb.com>
Date: Fri, 29 Sep 2017 13:54:08 -0700
Subject: [PATCH] ARM: Don't extend bit LG_VADDR to compute high address bits.

In userspace ARM on Linux, zero-ing the high bits is the correct way to do this.
This doesn't fix the fact that we currently set LG_VADDR to 48 on ARM, when in
fact larger virtual address sizes are coming soon.  We'll cross that bridge when
we come to it.
---
 include/jemalloc/internal/rtree.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/jemalloc/internal/rtree.h b/include/jemalloc/internal/rtree.h
index b5d4db39..4563db23 100644
--- a/include/jemalloc/internal/rtree.h
+++ b/include/jemalloc/internal/rtree.h
@@ -178,9 +178,21 @@ rtree_leaf_elm_bits_read(tsdn_t *tsdn, rtree_t *rtree, rtree_leaf_elm_t *elm,

 JEMALLOC_ALWAYS_INLINE extent_t *
 rtree_leaf_elm_bits_extent_get(uintptr_t bits) {
+#    ifdef __aarch64__
+	/*
+	 * aarch64 doesn't sign extend the highest virtual address bit to set
+	 * the higher ones.  Instead, the high bits gets zeroed.
+	 */
+	uintptr_t high_bit_mask = ((uintptr_t)1 << LG_VADDR) - 1;
+	/* Mask off the slab bit. */
+	uintptr_t low_bit_mask = ~(uintptr_t)1;
+	uintptr_t mask = high_bit_mask & low_bit_mask;
+	return (extent_t *)(bits & mask);
+#    else
 	/* Restore sign-extended high bits, mask slab bit. */
 	return (extent_t *)((uintptr_t)((intptr_t)(bits << RTREE_NHIB) >>
 	    RTREE_NHIB) & ~((uintptr_t)0x1));
+#    endif
 }

 JEMALLOC_ALWAYS_INLINE szind_t


code:
Fix CVE-2015-8863 (Off-by-one error in the tokenadd function in
jv_parse.c in jq allows remote attackers to cause a denial of service
(crash) via a long JSON-encoded number, which triggers a heap-based
buffer overflow):

<https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-8863>

Copied from upstream code repository:

<https://github.com/stedolan/jq/commit/8eb1367ca44e772963e704a700ef72ae2e12babd>

From 8eb1367ca44e772963e704a700ef72ae2e12babd Mon Sep 17 00:00:00 2001
From: Nicolas Williams <nico@cryptonector.com>
Date: Sat, 24 Oct 2015 17:24:57 -0500
Subject: [PATCH] Heap buffer overflow in tokenadd() (fix #105)

This was an off-by one: the NUL terminator byte was not allocated on
resize.  This was triggered by JSON-encoded numbers longer than 256
bytes.
---
 jv_parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/jv_parse.c b/jv_parse.c
index 3102ed4..84245b8 100644
--- a/jv_parse.c
+++ b/jv_parse.c
@@ -383,7 +383,7 @@ static pfunc stream_token(struct jv_parser* p, char ch) {

 static void tokenadd(struct jv_parser* p, char c) {
   assert(p->tokenpos <= p->tokenlen);
-  if (p->tokenpos == p->tokenlen) {
+  if (p->tokenpos >= (p->tokenlen - 1)) {
     p->tokenlen = p->tokenlen*2 + 256;
     p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
   }
@@ -485,7 +485,7 @@ static pfunc check_literal(struct jv_parser* p) {
     TRY(value(p, v));
   } else {
     // FIXME: better parser
-    p->tokenbuf[p->tokenpos] = 0; // FIXME: invalid
+    p->tokenbuf[p->tokenpos] = 0;
     char* end = 0;
     double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
     if (end == 0 || *end != 0)


code:
Fix floating point issues on 32-bit platforms:

https://gitlab.gnome.org/GNOME/json-glib/issues/27

This is an amalgamation of the following upstream commits:
https://gitlab.gnome.org/GNOME/json-glib/commit/70e2648e02232c1a439a7418388f18fee9afb3fe
https://gitlab.gnome.org/GNOME/json-glib/commit/675e27505776a1d77fa1ffd1974284890caec1f4

diff --git a/json-glib/tests/json-test-utils.h b/json-glib/tests/json-test-utils.h
new file mode 100644
index 0000000..83a02c6
--- /dev/null
+++ b/json-glib/tests/json-test-utils.h
@@ -0,0 +1,21 @@
+#include <string.h>
+#include <math.h>
+#include <float.h>
+#include <glib.h>
+#include <json-glib/json-glib.h>
+
+#define json_fuzzy_equals(n1,n2,epsilon) \
+  (((n1) > (n2) ? ((n1) - (n2)) : ((n2) - (n1))) < (epsilon))
+
+#define json_assert_fuzzy_equals(n1,n2,epsilon) \
+  G_STMT_START { \
+    double __n1 = (n1), __n2 = (n2), __epsilon = (epsilon); \
+    if (json_fuzzy_equals (__n1, __n2, __epsilon)) ; else { \
+      g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                  #n1 " == " #n2 " (+/- " #epsilon ")", \
+                                  __n1, "==", __n2, 'f'); \
+    } \
+  } G_STMT_END
+
+#define json_assert_almost_equals(n1,n2) \
+  json_assert_fuzzy_equals (n1, n2, DBL_EPSILON)
diff --git a/json-glib/tests/array.c b/json-glib/tests/array.c
index 98afeab..426cd72 100644
--- a/json-glib/tests/array.c
+++ b/json-glib/tests/array.c
@@ -1,9 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <json-glib/json-glib.h>
+#include "json-test-utils.h"

 static void
 test_empty_array (void)
@@ -37,7 +32,7 @@ test_add_element (void)

   json_array_add_double_element (array, 3.14);
   g_assert_cmpint (json_array_get_length (array), ==, 3);
-  g_assert_cmpfloat (json_array_get_double_element (array, 2), ==, 3.14);
+  json_assert_fuzzy_equals (json_array_get_double_element (array, 2), 3.14, 0.001);

   json_array_add_boolean_element (array, TRUE);
   g_assert_cmpint (json_array_get_length (array), ==, 4);
diff --git a/json-glib/tests/node.c b/json-glib/tests/node.c
index 23bda63..80beb78 100644
--- a/json-glib/tests/node.c
+++ b/json-glib/tests/node.c
@@ -1,6 +1,4 @@
-#include <glib.h>
-#include <json-glib/json-glib.h>
-#include <string.h>
+#include "json-test-utils.h"

 static void
 test_init_int (void)
@@ -19,7 +17,7 @@ test_init_double (void)
   JsonNode *node = json_node_new (JSON_NODE_VALUE);

   json_node_set_double (node, 3.14159);
-  g_assert_cmpfloat (json_node_get_double (node), ==, 3.14159);
+  json_assert_fuzzy_equals (json_node_get_double (node), 3.14159, 0.00001);

   json_node_free (node);
 }
@@ -119,13 +117,13 @@ test_get_int (void)

   json_node_set_int (node, 0);
   g_assert_cmpint (json_node_get_int (node), ==, 0);
-  g_assert_cmpfloat (json_node_get_double (node), ==, 0.0);
+  json_assert_almost_equals (json_node_get_double (node), 0.0);
   g_assert (!json_node_get_boolean (node));
   g_assert (!json_node_is_null (node));

   json_node_set_int (node, 42);
   g_assert_cmpint (json_node_get_int (node), ==, 42);
-  g_assert_cmpfloat (json_node_get_double (node), ==, 42.0);
+  json_assert_almost_equals (json_node_get_double (node), 42.0);
   g_assert (json_node_get_boolean (node));
   g_assert (!json_node_is_null (node));

@@ -138,7 +136,7 @@ test_get_double (void)
   JsonNode *node = json_node_new (JSON_NODE_VALUE);

   json_node_set_double (node, 3.14);
-  g_assert_cmpfloat (json_node_get_double (node), ==, 3.14);
+  json_assert_fuzzy_equals (json_node_get_double (node), 3.14, 0.001);
   g_assert_cmpint (json_node_get_int (node), ==, 3);
   g_assert (json_node_get_boolean (node));

@@ -232,9 +230,9 @@ test_gvalue_autopromotion (void)
     g_print ("Expecting a gdouble, got a %s\n", g_type_name (G_VALUE_TYPE (&check)));

   g_assert_cmpint (G_VALUE_TYPE (&check), ==, G_TYPE_DOUBLE);
-  g_assert_cmpfloat ((float) g_value_get_double (&check), ==, 3.14159f);
+  json_assert_fuzzy_equals (g_value_get_double (&check), 3.14159, 0.00001);
   g_assert_cmpint (G_VALUE_TYPE (&value), !=, G_VALUE_TYPE (&check));
-  g_assert_cmpfloat ((gdouble) g_value_get_float (&value), ==, g_value_get_double (&check));
+  json_assert_almost_equals (g_value_get_float (&value), g_value_get_double (&check));

   g_value_unset (&value);
   g_value_unset (&check);
diff --git a/json-glib/tests/parser.c b/json-glib/tests/parser.c
index f71584a..8c52a1d 100644
--- a/json-glib/tests/parser.c
+++ b/json-glib/tests/parser.c
@@ -1,11 +1,5 @@
-#include "config.h"
-
+#include "json-test-utils.h"
 #include <stdlib.h>
-#include <stdio.h>
-
-#include <glib.h>
-
-#include <json-glib/json-glib.h>

 static const gchar *test_empty_string = "";
 static const gchar *test_empty_array_string = "[ ]";
@@ -38,13 +32,13 @@ verify_string_value (JsonNode *node)
 static void
 verify_double_value (JsonNode *node)
 {
-  g_assert_cmpfloat (10.2e3, ==, json_node_get_double (node));
+  json_assert_fuzzy_equals (10.2e3, json_node_get_double (node), 0.1);
 }

 static void
 verify_negative_double_value (JsonNode *node)
 {
-  g_assert_cmpfloat (-3.14, ==, json_node_get_double (node));
+  json_assert_fuzzy_equals (-3.14, json_node_get_double (node), 0.01);
 }

 static const struct {
diff --git a/json-glib/tests/reader.c b/json-glib/tests/reader.c
index 43a6aac..9bab312 100644
--- a/json-glib/tests/reader.c
+++ b/json-glib/tests/reader.c
@@ -1,9 +1,4 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <glib.h>
-
-#include <json-glib/json-glib.h>
+#include "json-test-utils.h"

 static const gchar *test_base_array_data =
 "[ 0, true, null, \"foo\", 3.14, [ false ], { \"bar\" : 42 } ]";
@@ -78,7 +73,7 @@ test_base_object (void)
   g_assert (json_reader_get_error (reader) == NULL);

   json_reader_read_member (reader, "double");
-  g_assert_cmpfloat (json_reader_get_double_value (reader), ==, 42.47);
+  json_assert_fuzzy_equals (json_reader_get_double_value (reader), 42.47, 0.01);
   json_reader_end_element (reader);

   g_object_unref (reader);


code:
Add placeholder for kinit's store file name.

diff --git a/src/kdeinitinterface.cpp b/src/kdeinitinterface.cpp
index 22fa5e5..3d40937 100644
--- a/src/kdeinitinterface.cpp
+++ b/src/kdeinitinterface.cpp
@@ -52,7 +52,7 @@ void KDEInitInterface::ensureKdeinitRunning()
     // If not found in system paths, search other paths
     if (srv.isEmpty()) {
         const QStringList searchPaths = QStringList()
-            << QCoreApplication::applicationDirPath() // then look where our application binary is located
+            << QString::fromUtf8("@SUBSTITUTEME@/bin") // using QStringLiteral would be more efficient, but breaks guix store reference detection.
             << QLibraryInfo::location(QLibraryInfo::BinariesPath); // look where exec path is (can be set in qt.conf)
         srv = QStandardPaths::findExecutable(QStringLiteral("kdeinit5"), searchPaths);
         if (srv.isEmpty()) {


code:
Change setup.cfg so that the bundled zlib and bzip2 are not used.  This cannot
currently be achieved using "--library z,bz2" as instructed in the setup.py.

diff --git a/setup.cfg b/setup.cfg
index c054092..080992e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,7 +1,7 @@
 [build_ext]
 define = SEQAN_HAS_BZIP2,SEQAN_HAS_ZLIB
 undef = NO_UNIQUE_RC
-# libraries = z,bz2
+libraries = z,bz2
 ## if using system libraries
 include-dirs = lib:third-party/zlib:third-party/bzip2:third-party/seqan/core/include:third-party/smhasher
 # include-dirs = lib


code:
Downloaded from https://anonscm.debian.org/viewvc/pkg-games/packages/trunk/kiki-the-nano-bot/debian/patches/level-selection-with-no-levels-solved.patch?revision=8291&view=co

Kiki crashes if the user tries to use the level selection menu before
finishing any level.

Peter De Wachter (pdewacht@gmail.com)
placed in the public domain

--- a/py/levelselection.py
+++ b/py/levelselection.py
@@ -25,6 +25,8 @@
     # ............................................................................................................

     last_level = highscore.getLastAvailableLevel()
+    if last_level < 0:
+        last_level = 0
     current_level = (level_index >= 0) and level_index or last_level

     world.max_level_index = last_level


code:
Downloaded from https://anonscm.debian.org/viewvc/pkg-games/packages/trunk/kiki-the-nano-bot/debian/patches/Makefile.patch?revision=15681&view=co

Makefile fixes:
 - Make CXXFLAGS, CPPFLAGS, LDFLAGS available for user-specified flags.
 - run SWIG before compiling

Peter De Wachter (pdewacht@gmail.com)
placed in the public domain

--- a/kodilib/linux/Makefile
+++ b/kodilib/linux/Makefile
@@ -21,7 +21,7 @@

 INCLUDES = $(KODI_INCLUDES) $(X11_INCLUDES) $(SDL_INCLUDES)

-CXXFLAGS = $(INCLUDES) $(SDL_CFLAGS)
+CXXOPTS = -Wall $(INCLUDES) $(SDL_CFLAGS) $(CPPFLAGS) $(CXXFLAGS)

 src =  \
 	$(KODISRCDIR)/handler/KEventHandler.cpp \
@@ -95,4 +95,4 @@
 	$(RM) -f $(obj) libkodi.a

 %.o:    %.cpp
-	$(CXX) -c $(CXXFLAGS) -o $@ $<
+	$(CXX) -c $(CXXOPTS) -o $@ $<
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -46,7 +46,7 @@

 INCLUDES = $(KIKI_INCLUDES) $(X11_INCLUDES) $(PYTHON_INCLUDES)

-CXXFLAGS = $(INCLUDES) $(SDLCFLAGS)
+CXXOPTS = -Wall $(INCLUDES) $(SDLCFLAGS) $(CPPFLAGS) $(CXXFLAGS)

 src =  \
 	$(KIKISRC)/base/KikiAction.cpp \
@@ -105,8 +105,10 @@
 obj = $(src:.cpp=.o)

 kiki: $(KIKISRC)/../SWIG/KikiPy_wrap.cpp $(obj)
-	-(cd ../SWIG; swig -c++ -python -globals kiki -o KikiPy_wrap.cpp KikiPy.i; cp kiki.py ../py)
-	$(CXX) $(obj) $(KODILIB) -o kiki $(GLLIBS) $(SDLLIBS) $(PYTHONLIBS)
+	$(CXX) $(LDFLAGS) $(obj) $(KODILIB) -o kiki $(GLLIBS) $(SDLLIBS) $(PYTHONLIBS)
+
+$(KIKISRC)/../SWIG/KikiPy_wrap.cpp: $(wildcard ../SWIG/*.i)
+	(cd ../SWIG && swig -c++ -python -globals kiki -DSWIG_PYTHON_LEGACY_BOOL -o KikiPy_wrap.cpp KikiPy.i && cp kiki.py ../py)

 obj-clean:
 	$(RM) -f $(obj)
@@ -115,5 +117,5 @@
 	$(RM) -f $(obj) kiki

 %.o:    %.cpp
-	$(CXX) -c $(CXXFLAGS) -o $@ $<
+	$(CXX) -c $(CXXOPTS) -o $@ $<