[polyml] 03/05: Drop all patches; applied upstream

James Clarke jrtc27 at moszumanska.debian.org
Tue Feb 21 17:56:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

jrtc27 pushed a commit to branch debian/experimental
in repository polyml.

commit 81941c14f7cfb74e7a22dde32b4af224fc398d77
Author: James Clarke <jrtc27 at debian.org>
Date:   Tue Feb 21 16:56:31 2017 +0000

    Drop all patches; applied upstream
---
 debian/patches/alpha.diff                          |  49 ---
 debian/patches/bss-ioarea.diff                     | 281 --------------
 debian/patches/disable-compile-time-real-eval.diff |  57 ---
 debian/patches/fix-heap-ratio-assert.diff          |  28 --
 debian/patches/fix-script-args.diff                |  35 --
 debian/patches/hppa.diff                           |  46 ---
 debian/patches/ioctl-int.diff                      |  64 ----
 debian/patches/m68k.diff                           |  44 ---
 debian/patches/maxhostnamelen.diff                 | 120 ------
 debian/patches/maxpathlen.diff                     | 421 ---------------------
 debian/patches/mips-abi.diff                       |  18 -
 debian/patches/mips64.diff                         | 153 --------
 debian/patches/noexec-stack-gnu.diff               |  51 ---
 debian/patches/noflsh-unsigned.diff                |  17 -
 debian/patches/polyc-dont-capture-build-path.diff  |  40 --
 debian/patches/polyc-it.diff                       |  19 -
 debian/patches/reset-save-vector-sleep.diff        |  77 ----
 .../rounding-mode-test-allow-exceptions.diff       |  83 ----
 ...de-test-only-allow-exceptions-for-set-mode.diff |  66 ----
 debian/patches/s390.diff                           |  55 ---
 debian/patches/series                              |  32 +-
 debian/patches/sh.diff                             |  80 ----
 debian/patches/soft-fpu.diff                       |  37 --
 debian/patches/source-date-epoch.diff              | 252 ------------
 debian/patches/sparc64.diff                        |  47 ---
 debian/patches/spelling-errors.diff                |  56 ---
 debian/patches/streamtoken-endian.diff             |  23 --
 .../thread-exited-interrupt-requested-overlap.diff |  21 -
 debian/patches/unix-const-vec-unsigned.diff        |  19 -
 ...e-polyunsigned-consistently-for-stream-ids.diff | 158 --------
 debian/patches/wait-return-valid-status.diff       |  30 --
 debian/patches/x32.diff                            |  82 ----
 32 files changed, 1 insertion(+), 2560 deletions(-)

diff --git a/debian/patches/alpha.diff b/debian/patches/alpha.diff
deleted file mode 100644
index ee824a2..0000000
--- a/debian/patches/alpha.diff
+++ /dev/null
@@ -1,49 +0,0 @@
-Description: Add support for Alpha
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/26
-Applied-Upstream: https://github.com/polyml/polyml/commit/e9028e9395549525fc22484a24fd78f5cb0beed3
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -557,6 +557,9 @@
- /* Define if the host is an ARM (64-bit) */
- #undef HOSTARCHITECTURE_AARCH64
- 
-+/* Define if the host is an Alpha (64-bit) */
-+#undef HOSTARCHITECTURE_ALPHA
-+
- /* Define if the host is an ARM (32-bit) */
- #undef HOSTARCHITECTURE_ARM
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -459,6 +459,15 @@
-             AC_DEFINE([HOSTARCHITECTURE_S390], [1], [Define if the host is an S/390 (32-bit)])
-             polyarch=interpret
-             ;;
-+      alpha*)
-+            AC_DEFINE([HOSTARCHITECTURE_ALPHA], [1], [Define if the host is an Alpha (64-bit)])
-+            polyarch=interpret
-+            # GCC defaults to non-conforming floating-point, and does not respect the rounding mode
-+            # in the floating-point control register, so we force it to conform to IEEE and use the
-+            # dynamic suffix on the floating-point instructions it produces.
-+            CFLAGS="$CFLAGS -mieee -mfp-rounding-mode=d"
-+            CXXFLAGS="$CXXFLAGS -mieee -mfp-rounding-mode=d"
-+            ;;
-       *) AC_MSG_ERROR([Poly/ML is not supported for this architecture]) ;;
- esac
- 
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -397,6 +397,10 @@
-     fhdr.e_flags = EF_MIPS_CPIC;
- #endif
-     useRela = true;
-+#elif defined(HOSTARCHITECTURE_ALPHA)
-+    fhdr.e_machine = EM_ALPHA;
-+    directReloc = R_ALPHA_REFQUAD;
-+    useRela = true;
- #else
- #error "No support for exporting on this architecture"
- #endif
diff --git a/debian/patches/bss-ioarea.diff b/debian/patches/bss-ioarea.diff
deleted file mode 100644
index 0dba99b..0000000
--- a/debian/patches/bss-ioarea.diff
+++ /dev/null
@@ -1,281 +0,0 @@
-Description: Export ioarea to bss section
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/31
-Applied-Upstream: https://github.com/polyml/polyml/commit/9f2cb26e5c91fc8cd59d1348961a4ded0ca1b1d3
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -340,9 +340,9 @@
-     PolyWord    *p;
-     ElfXX_Ehdr fhdr;
-     ElfXX_Shdr *sections = 0;
--    unsigned numSections = 6 + 2*memTableEntries;
-+    unsigned numSections = 6 + 2*memTableEntries - 1;
-     // The symbol table comes at the end.
--    unsigned sect_symtab = sect_data + 2*memTableEntries + 2;
-+    unsigned sect_symtab = sect_data + 2*memTableEntries + 2 - 1;
-     
-     unsigned i;
- 
-@@ -485,6 +485,7 @@
-     // sections[sect_stringtable].sh_offset is set later
-     // sections[sect_stringtable].sh_size is set later
- 
-+    unsigned long bssName = makeStringTableEntry(".bss", &sectionStrings);
-     unsigned long dataName = makeStringTableEntry(".data", &sectionStrings);
-     unsigned long dataRelName = makeStringTableEntry(useRela ? ".rela.data" : ".rel.data", &sectionStrings);
-     unsigned long textName = makeStringTableEntry(".text", &sectionStrings);
-@@ -493,41 +494,52 @@
-     // Main data sections.  Each one has a relocation section.
-     for (i=0; i < memTableEntries; i++)
-     {
--        unsigned s = sect_data + i*2;
--        sections[s].sh_type = SHT_PROGBITS;
-+        unsigned s = sect_data + i*2 - (i > ioMemEntry ? 1 : 0);
-         sections[s].sh_addralign = 8; // 8-byte alignment
- 
--        if (memTable[i].mtFlags & MTF_WRITEABLE)
-+        if (i == ioMemEntry)
-         {
--            // Mutable areas
--            ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE)); // Executable areas can't be writable.
--            sections[s].sh_name = dataName;
-+            ASSERT(memTable[i].mtFlags & MTF_WRITEABLE);
-+            ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE));
-+            sections[s].sh_name = bssName;
-+            sections[s].sh_type = SHT_NOBITS;
-             sections[s].sh_flags = SHF_WRITE | SHF_ALLOC;
--            sections[s+1].sh_name = dataRelName; // Name of relocation section
-         }
-         else
-         {
--            // Immutable areas are marked as executable.
--            sections[s].sh_name = textName;
--            sections[s].sh_flags = SHF_ALLOC | SHF_EXECINSTR;
--            sections[s+1].sh_name = textRelName; // Name of relocation section
-+            sections[s].sh_type = SHT_PROGBITS;
-+            if (memTable[i].mtFlags & MTF_WRITEABLE)
-+            {
-+                // Mutable areas
-+                ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE)); // Executable areas can't be writable.
-+                sections[s].sh_name = dataName;
-+                sections[s].sh_flags = SHF_WRITE | SHF_ALLOC;
-+                sections[s+1].sh_name = dataRelName; // Name of relocation section
-+            }
-+            else
-+            {
-+                // Immutable areas are marked as executable.
-+                sections[s].sh_name = textName;
-+                sections[s].sh_flags = SHF_ALLOC | SHF_EXECINSTR;
-+                sections[s+1].sh_name = textRelName; // Name of relocation section
-+            }
-+            // sections[s].sh_size is set later
-+            // sections[s].sh_offset is set later.
-+            // sections[s].sh_size is set later.
-+
-+            // Relocation section
-+            sections[s+1].sh_type = useRela ? SHT_RELA : SHT_REL; // Contains relocation with/out explicit addends (ElfXX_Rel)
-+            sections[s+1].sh_link = sect_symtab; // Index to symbol table
-+            sections[s+1].sh_info = s; // Applies to the data section
-+            sections[s+1].sh_addralign = sizeof(long); // Align to a word
-+            sections[s+1].sh_entsize = useRela ? sizeof(ElfXX_Rela) : sizeof(ElfXX_Rel);
-+            // sections[s+1].sh_offset is set later.
-+            // sections[s+1].sh_size is set later.
-         }
--        // sections[s].sh_size is set later
--        // sections[s].sh_offset is set later.
--        // sections[s].sh_size is set later.
--
--        // Relocation section
--        sections[s+1].sh_type = useRela ? SHT_RELA : SHT_REL; // Contains relocation with/out explicit addends (ElfXX_Rel)
--        sections[s+1].sh_link = sect_symtab; // Index to symbol table
--        sections[s+1].sh_info = s; // Applies to the data section
--        sections[s+1].sh_addralign = sizeof(long); // Align to a word
--        sections[s+1].sh_entsize = useRela ? sizeof(ElfXX_Rela) : sizeof(ElfXX_Rel);
--        // sections[s+1].sh_offset is set later.
--        // sections[s+1].sh_size is set later.
-     }
- 
-     // Table data - Poly tables that describe the memory layout.
--    unsigned sect_table_data = sect_data+2*memTableEntries;
-+    unsigned sect_table_data = sect_data + 2*memTableEntries - 1;
- 
-     sections[sect_table_data].sh_name = dataName;
-     sections[sect_table_data].sh_type = SHT_PROGBITS;
-@@ -561,12 +573,13 @@
-     // Create symbols for the address areas.  AreaToSym assumes these come first.
-     for (i = 0; i < memTableEntries; i++)
-     {
-+        unsigned s = sect_data + i*2 - (i > ioMemEntry ? 1 : 0);
-         if (i == ioMemEntry)
--            writeSymbol("ioarea", 0, 0, STB_LOCAL, STT_OBJECT, sect_data+i*2);
-+            writeSymbol("ioarea", 0, 0, STB_LOCAL, STT_OBJECT, s);
-         else {
-             char buff[50];
-             sprintf(buff, "area%1u", i);
--            writeSymbol(buff, 0, 0, STB_LOCAL, STT_OBJECT, sect_data+i*2);
-+            writeSymbol(buff, 0, 0, STB_LOCAL, STT_OBJECT, s);
-         }
-     }
- 
-@@ -575,6 +588,7 @@
-     {
-         if (i != ioMemEntry)
-         {
-+            unsigned s = sect_data + i*2 - (i > ioMemEntry ? 1 : 0);
-             char buff[50];
-             // Write the names of the functions as local symbols.  This isn't necessary
-             // but it makes debugging easier since the function names appear in gdb.
-@@ -591,7 +605,7 @@
-                     // Copy as much of the name as will fit and ignore any extra.
-                     // Do we need to worry about duplicates?
-                     (void)Poly_string_to_C(*name, buff, sizeof(buff));
--                    writeSymbol(buff, ((char*)p - start), 0, STB_LOCAL, STT_OBJECT, sect_data+i*2);
-+                    writeSymbol(buff, ((char*)p - start), 0, STB_LOCAL, STT_OBJECT, s);
-                 }
-                 p += length;
-             }
-@@ -610,12 +624,12 @@
- 
-     for (i = 0; i < memTableEntries; i++)
-     {
--        unsigned relocSection = sect_data+i*2+1;
--        alignFile(sections[relocSection].sh_addralign);
--        sections[relocSection].sh_offset = ftell(exportFile);
--        relocationCount = 0;
-         if (i != ioMemEntry) // Don't relocate the IO area
-         {
-+            unsigned relocSection = sect_data + i*2 + 1 - (i > ioMemEntry ? 1 : 0);
-+            alignFile(sections[relocSection].sh_addralign);
-+            sections[relocSection].sh_offset = ftell(exportFile);
-+            relocationCount = 0;
-             // Create the relocation table and turn all addresses into offsets.
-             char *start = (char*)memTable[i].mtAddr;
-             char *end = start + memTable[i].mtLength;
-@@ -631,9 +645,9 @@
-                 relocateObject(obj);
-                 p += length;
-             }
-+            sections[relocSection].sh_size =
-+                relocationCount * (useRela ? sizeof(ElfXX_Rela) : sizeof(ElfXX_Rel));
-         }
--        sections[relocSection].sh_size =
--            relocationCount * (useRela ? sizeof(ElfXX_Rela) : sizeof(ElfXX_Rel));
-     }
- 
-     // Relocations for "exports" and "memTable";
-@@ -671,11 +685,15 @@
-     // Now the binary data.
-     for (i = 0; i < memTableEntries; i++)
-     {
--        unsigned dataSection = sect_data+i*2;
--        alignFile(sections[dataSection].sh_addralign);
--        sections[dataSection].sh_offset = ftell(exportFile);
-+        unsigned dataSection = sect_data + i*2 - (i > ioMemEntry ? 1 : 0);
-         sections[dataSection].sh_size = memTable[i].mtLength;
--        fwrite(memTable[i].mtAddr, 1, memTable[i].mtLength, exportFile);
-+
-+        if (i != ioMemEntry)
-+        {
-+            alignFile(sections[dataSection].sh_addralign);
-+            sections[dataSection].sh_offset = ftell(exportFile);
-+            fwrite(memTable[i].mtAddr, 1, memTable[i].mtLength, exportFile);
-+        }
-     }
- 
-     exportDescription exports;
---- a/libpolyml/machoexport.cpp
-+++ b/libpolyml/machoexport.cpp
-@@ -334,7 +334,15 @@
-     {
-         memset(&(sections[i]), 0, sectionSize);
- 
--        if (memTable[i].mtFlags & MTF_WRITEABLE)
-+        if (i == ioMemEntry)
-+        {
-+            ASSERT(memTable[i].mtFlags & MTF_WRITEABLE);
-+            ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE));
-+            sprintf(sections[i].sectname, "__bss");
-+            sprintf(sections[i].segname, "__DATA");
-+            sections[i].flags = S_ZEROFILL;
-+        }
-+        else if (memTable[i].mtFlags & MTF_WRITEABLE)
-         {
-             // Mutable areas
-             ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE)); // Executable areas can't be writable.
-@@ -433,10 +441,10 @@
-     // Create and write out the relocations.
-     for (i = 0; i < memTableEntries; i++)
-     {
--        sections[i].reloff = ftell(exportFile);
--        relocationCount = 0;
-         if (i != ioMemEntry) // Don't relocate the IO area
-         {
-+            sections[i].reloff = ftell(exportFile);
-+            relocationCount = 0;
-             // Create the relocation table and turn all addresses into offsets.
-             char *start = (char*)memTable[i].mtAddr;
-             char *end = start + memTable[i].mtLength;
-@@ -450,8 +458,8 @@
-                 relocateObject(obj);
-                 p += length;
-             }
-+            sections[i].nreloc = relocationCount;
-         }
--        sections[i].nreloc = relocationCount;
-     }
- 
-     // Additional relocations for the descriptors.
-@@ -512,9 +520,16 @@
-     // Now the binary data.
-     for (i = 0; i < memTableEntries; i++)
-     {
--        alignFile(4);
--        sections[i].offset = ftell(exportFile);
--        fwrite(memTable[i].mtAddr, 1, memTable[i].mtLength, exportFile);
-+        if (i == ioMemEntry)
-+        {
-+            sections[i].offset = 0;
-+        }
-+        else
-+        {
-+            alignFile(4);
-+            sections[i].offset = ftell(exportFile);
-+            fwrite(memTable[i].mtAddr, 1, memTable[i].mtLength, exportFile);
-+        }
-     }
-     // Rewind to rewrite the headers with the actual offsets.
-     rewind(exportFile);
---- a/libpolyml/pecoffexport.cpp
-+++ b/libpolyml/pecoffexport.cpp
-@@ -208,7 +208,14 @@
-         sections[i].SizeOfRawData = (DWORD)memTable[i].mtLength;
-         sections[i].Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_ALIGN_8BYTES;
- 
--        if (memTable[i].mtFlags & MTF_WRITEABLE)
-+        if (i == ioMemEntry)
-+        {
-+            ASSERT(memTable[i].mtFlags & MTF_WRITEABLE);
-+            ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE));
-+            strcpy((char*)sections[i].Name, ".bss");
-+            sections[i].Characteristics |= IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_UNINITIALIZED_DATA;
-+        }
-+        else if (memTable[i].mtFlags & MTF_WRITEABLE)
-         {
-             // Mutable data
-             ASSERT(!(memTable[i].mtFlags & MTF_EXECUTABLE)); // Executable areas can't be writable.
-@@ -313,8 +320,11 @@
-     // Now the binary data.
-     for (i = 0; i < memTableEntries; i++)
-     {
--        sections[i].PointerToRawData = ftell(exportFile);
--        fwrite(memTable[i].mtAddr, 1, memTable[i].mtLength, exportFile);
-+        if (i != ioMemEntry)
-+        {
-+            sections[i].PointerToRawData = ftell(exportFile);
-+            fwrite(memTable[i].mtAddr, 1, memTable[i].mtLength, exportFile);
-+        }
-     }
- 
-     sections[memTableEntries].PointerToRawData = ftell(exportFile);
diff --git a/debian/patches/disable-compile-time-real-eval.diff b/debian/patches/disable-compile-time-real-eval.diff
deleted file mode 100644
index a57a642..0000000
--- a/debian/patches/disable-compile-time-real-eval.diff
+++ /dev/null
@@ -1,57 +0,0 @@
-Description: Disable compile-time evaluation of real number functions.
- Real number operations depend on the current rounding mode.  That means that in
- general it is not possible to "fold" operations on real constants.
-Origin: upstream, https://github.com/polyml/polyml/commit/4fca50be382fcec8212367081791d51bea44c0bd
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/poly_specific.cpp
-+++ b/libpolyml/poly_specific.cpp
-@@ -154,7 +154,10 @@
-     case POLY_SYS_equala: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-     case POLY_SYS_ora: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-     case POLY_SYS_anda: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_Real_str: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-+
-+        // Floating point operations depend on the current rounding mode.  That means
-+        // that it's not possible to perform floating point operations at compile-time.
-+    case POLY_SYS_Real_str: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-     case POLY_SYS_Real_geq: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-     case POLY_SYS_Real_leq: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-     case POLY_SYS_Real_gtr: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-@@ -162,21 +165,21 @@
-     case POLY_SYS_Real_eq: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-     case POLY_SYS_Real_neq: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-     case POLY_SYS_Real_Dispatch: return 0;
--    case POLY_SYS_Add_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_Sub_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_Mul_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_Div_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_Abs_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_Neg_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-+    case POLY_SYS_Add_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_Sub_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_Mul_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_Div_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_Abs_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF; // Only affects sign
-+    case POLY_SYS_Neg_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF; // Only affects sign
-     case POLY_SYS_conv_real: return PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_real_to_int: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_int_to_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_sqrt_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_sin_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_cos_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_arctan_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_exp_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
--    case POLY_SYS_ln_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE|PROPWORD_NODEREF;
-+    case POLY_SYS_real_to_int: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_int_to_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_sqrt_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_sin_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_cos_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_arctan_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_exp_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-+    case POLY_SYS_ln_real: return PROPWORD_NORAISE|PROPWORD_NOUPDATE;
-     case POLY_SYS_stdin: return 0; // Not a function
-     case POLY_SYS_stdout: return 0; // Not a function
-     case POLY_SYS_process_env: return 0;
diff --git a/debian/patches/fix-heap-ratio-assert.diff b/debian/patches/fix-heap-ratio-assert.diff
deleted file mode 100644
index 8453a6c..0000000
--- a/debian/patches/fix-heap-ratio-assert.diff
+++ /dev/null
@@ -1,28 +0,0 @@
-Description: The calculated cost of the minimum heap size may be exactly the value desired.
- In that case the previous code failed an assertion check.
-Origin: upstream, https://github.com/polyml/polyml/commit/489c7cab70a23961adbd782e96e58818b9bd87bb
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/heapsizing.cpp
-+++ b/libpolyml/heapsizing.cpp
-@@ -576,8 +576,8 @@
-     if (sizeMin < minForAllocation) sizeMin = minForAllocation;
- 
-     double costMin = costFunction(sizeMin, withSharing, true);
--    if (costMin < userGCRatio)
--        // If the cost of the minimum is below the target we
-+    if (costMin <= userGCRatio)
-+        // If the cost of the minimum is below or at the target we
-         // use that and don't need to look further.
-         isBounded = true;
-     else
-@@ -599,7 +599,7 @@
-                 sizeMin = sizeNext;
-                 costMin = cost;
-             }
--            ASSERT(costMin > userGCRatio);
-+            ASSERT(costMin >= userGCRatio);
-         }
-     }
-     ASSERT(sizeMin >= minHeapSize && sizeMin <= maxHeapSize);
diff --git a/debian/patches/fix-script-args.diff b/debian/patches/fix-script-args.diff
deleted file mode 100644
index 9a38376..0000000
--- a/debian/patches/fix-script-args.diff
+++ /dev/null
@@ -1,35 +0,0 @@
-Description: Fix --script to read the next argument as the file rather than the last.
- The --script argument is intended for use in a shell script to skip the
- #! line.  It was reading the last argument as the name of the script file
- which meant it only worked if there were no arguments.
-Origin: upstream, https://github.com/polyml/polyml/commit/e4b984c24afa1f738e7ce6f6bdc437cef23d0c40
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/basis/TopLevelPolyML.sml
-+++ b/basis/TopLevelPolyML.sml
-@@ -1583,7 +1583,7 @@
-                 print "--error-exit         Exit shell on unhandled exception\n";
-                 print "--with-markup        Include extra mark-up information when printing\n";
-                 print "--ideprotocol[=v2]   Run the IDE communications protocol\n";
--                print "--script             The input is a script.  Skips the first line if it begins with #!";
-+                print "--script FILE        The input is a script.  Skips the first line if it begins with #!.";
-                 print "\nRun time system arguments:\n";
-                 print (rtsHelp())
-                )
-@@ -1594,10 +1594,13 @@
-             else if switchOption "--script"
-             then
-             let
--                (* The last argument is the file name.  Open it but skip 
-+                (* The next argument is the file name.  Open it but skip 
-                    the first line if it's #!.   The rest of this code is
-                    largely copied from PolyML.use.  *)
--                val fileName = List.last argList (* We know there's at least one *)
-+                fun getFileName("--script" :: fileName :: _) = fileName
-+                |   getFileName [] = (print "Missing file name after --script\n"; OS.Process.exit OS.Process.failure)
-+                |   getFileName(_ :: tail) = getFileName tail
-+                val fileName = getFileName argList
-                 open TextIO
-                 val inStream = getInstream(TextIO.openIn fileName)
-                 open StreamIO
diff --git a/debian/patches/hppa.diff b/debian/patches/hppa.diff
deleted file mode 100644
index 016b2af..0000000
--- a/debian/patches/hppa.diff
+++ /dev/null
@@ -1,46 +0,0 @@
-Description: Add support for HP PA-RISC
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/48
-Applied-Upstream: https://github.com/polyml/polyml/commit/0fdeea5ce02dc64f46f885e9be32b308bc981a7f
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -566,6 +566,9 @@
- /* Define if the host is an ARM (32-bit) */
- #undef HOSTARCHITECTURE_ARM
- 
-+/* Define if the host is an HP PA-RISC (32-bit) */
-+#undef HOSTARCHITECTURE_HPPA
-+
- /* Define if the host is an Itanium */
- #undef HOSTARCHITECTURE_IA64
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -459,6 +459,10 @@
-             AC_DEFINE([HOSTARCHITECTURE_AARCH64], [1], [Define if the host is an ARM (64-bit)])
-             polyarch=interpret
-             ;;
-+      hppa*)
-+            AC_DEFINE([HOSTARCHITECTURE_HPPA], [1], [Define if the host is an HP PA-RISC (32-bit)])
-+            polyarch=interpret
-+            ;;
-       ia64*)
-             AC_DEFINE([HOSTARCHITECTURE_IA64], [1], [Define if the host is an Itanium])
-             polyarch=interpret
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -430,6 +430,12 @@
-     directReloc = R_ARM_ABS32;
-     useRela = false;
-     fhdr.e_flags = EF_ARM_EABI_VER4;
-+#elif defined(HOSTARCHITECTURE_HPPA)
-+    fhdr.e_ident[EI_OSABI] = ELFOSABI_HPUX;
-+    fhdr.e_machine = EM_PARISC;
-+    directReloc = R_PARISC_DIR32;
-+    fhdr.e_flags = EFA_PARISC_1_0;
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_IA64)
-     fhdr.e_machine = EM_IA_64;
-     directReloc = R_IA64_DIR64LSB;
diff --git a/debian/patches/ioctl-int.diff b/debian/patches/ioctl-int.diff
deleted file mode 100644
index 5d3764c..0000000
--- a/debian/patches/ioctl-int.diff
+++ /dev/null
@@ -1,64 +0,0 @@
-Description: Use int instead of unsigned long for ioctl calls
- On 64-bit big-endian machines, int is 32-bit but unsigned long is
- 64-bit. ioctl is supposed to take a pointer to an int; on little-endian
- machines it does not matter if you give it a pointer to a longer type,
- but on big-endian machines ioctl ends up seeing the leading 4 bytes of
- zeroes when passing it a pointer to an unsigned long set to 1, and ends
- up effectively multiplying the output by 2^32 when given an out pointer
- to an unsigned long.
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/17
-Applied-Upstream: https://github.com/polyml/polyml/commit/c2f37c3c0b63d89e216af863571a14573f9586b7
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/network.cpp
-+++ b/libpolyml/network.cpp
-@@ -553,7 +553,6 @@
-             int af = get_C_int(taskData, DEREFHANDLE(args)->Get(0));
-             int type = get_C_int(taskData, DEREFHANDLE(args)->Get(1));
-             int proto = get_C_int(taskData, DEREFHANDLE(args)->Get(2));
--            unsigned long onOff = 1;
-             SOCKET skt = socket(af, type, proto);
-             if (skt == INVALID_SOCKET)
-             {
-@@ -574,8 +573,10 @@
-             }
-             /* Set the socket to non-blocking mode. */
- #if (defined(_WIN32) && ! defined(__CYGWIN__))
-+            unsigned long onOff = 1;
-             if (ioctlsocket(skt, FIONBIO, &onOff) != 0)
- #else
-+            int onOff = 1;
-             if (ioctl(skt, FIONBIO, &onOff) < 0)
- #endif
-             {
-@@ -759,12 +760,13 @@
-     case 44: /* Find number of bytes available. */
-         {
-             PIOSTRUCT strm = get_stream(args->WordP());
--            unsigned long readable;
-             if (strm == NULL) raise_syscall(taskData, "Stream is closed", EBADF);
- #if (defined(_WIN32) && ! defined(__CYGWIN__))
-+            unsigned long readable;
-             if (ioctlsocket(strm->device.sock, FIONREAD, &readable) != 0)
-                 raise_syscall(taskData, "ioctlsocket failed", GETERROR);
- #else
-+            int readable;
-             if (ioctl(strm->device.sock, FIONREAD, &readable) < 0)
-                 raise_syscall(taskData, "ioctl failed", GETERROR);
- #endif
-@@ -774,12 +776,13 @@
-     case 45: /* Find out if we are at the mark. */
-         {
-             PIOSTRUCT strm = get_stream(args->WordP());
--            unsigned long atMark;
-             if (strm == NULL) raise_syscall(taskData, "Stream is closed", EBADF);
- #if (defined(_WIN32) && ! defined(__CYGWIN__))
-+            unsigned long atMark;
-             if (ioctlsocket(strm->device.sock, SIOCATMARK, &atMark) != 0)
-                 raise_syscall(taskData, "ioctlsocket failed", GETERROR);
- #else
-+            int atMark;
-             if (ioctl(strm->device.sock, SIOCATMARK, &atMark) < 0)
-                 raise_syscall(taskData, "ioctl failed", GETERROR);
- #endif
diff --git a/debian/patches/m68k.diff b/debian/patches/m68k.diff
deleted file mode 100644
index 5ab2d28..0000000
--- a/debian/patches/m68k.diff
+++ /dev/null
@@ -1,44 +0,0 @@
-Description: Add support for Motorola 68000
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/27
-Applied-Upstream: https://github.com/polyml/polyml/commit/50bb971b5fd9c392c1b5494e0e87cd85a8fd9186
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -566,6 +566,9 @@
- /* Define if the host is an Itanium */
- #undef HOSTARCHITECTURE_IA64
- 
-+/* Define if the host is a Motorola 68000 */
-+#undef HOSTARCHITECTURE_M68K
-+
- /* Define if the host is a MIPS (32-bit) */
- #undef HOSTARCHITECTURE_MIPS
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -447,6 +447,10 @@
-             AC_DEFINE([HOSTARCHITECTURE_IA64], [1], [Define if the host is an Itanium])
-             polyarch=interpret
-             ;;
-+      m68k*)
-+            AC_DEFINE([HOSTARCHITECTURE_M68K], [1], [Define if the host is a Motorola 68000])
-+            polyarch=interpret
-+            ;;
-       mips*)
-             AC_DEFINE([HOSTARCHITECTURE_MIPS], [1], [Define if the host is a MIPS (32-bit)])
-             polyarch=interpret
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -390,6 +390,10 @@
-     fhdr.e_machine = EM_AARCH64;
-     directReloc = R_AARCH64_ABS64;
-     useRela = true;
-+#elif defined(HOSTARCHITECTURE_M68K)
-+    fhdr.e_machine = EM_68K;
-+    directReloc = R_68K_32;
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_MIPS)
-     fhdr.e_machine = EM_MIPS;
-     directReloc = R_MIPS_32;
diff --git a/debian/patches/maxhostnamelen.diff b/debian/patches/maxhostnamelen.diff
deleted file mode 100644
index ec3073a..0000000
--- a/debian/patches/maxhostnamelen.diff
+++ /dev/null
@@ -1,120 +0,0 @@
-Description: Remove all use of MAXHOSTNAMELEN
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/42
-Applied-Upstream: https://github.com/polyml/polyml/commit/18e322b65177fd7013999ab95c716320aabcb1fc
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/network.cpp
-+++ b/libpolyml/network.cpp
-@@ -29,6 +29,10 @@
- #include <stdio.h>
- #endif
- 
-+#ifdef HAVE_STDLIB_H
-+#include <stdlib.h>
-+#endif
-+
- #ifdef HAVE_ERRNO_H
- #include <errno.h>
- #endif
-@@ -123,10 +127,6 @@
- #include "machine_dep.h"
- #include "errors.h"
- 
--#ifndef MAXHOSTNAMELEN
--#define MAXHOSTNAMELEN 256
--#endif
--
- #define STREAMID(x) (DEREFSTREAMHANDLE(x)->streamNo)
- #define SAVE(x) taskData->saveVec.push(x)
- #define ALLOC(n) alloc_and_save(taskData, n)
-@@ -412,19 +412,29 @@
-     {
-     case 0:
-         { /* Get the current host name. */
--            char hostName[MAXHOSTNAMELEN];
--            if (gethostname(hostName, MAXHOSTNAMELEN) != 0)
-+            size_t size = 4096;
-+            TempCString hostName((char *)malloc(size));
-+            if (hostName == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+            int err;
-+            while ((err = gethostname(hostName, size)) != 0 && GETERROR == ENAMETOOLONG)
-+            {
-+                if (size > SIZE_MAX / 2) raise_fail(taskData, "gethostname needs too large a buffer");
-+                size *= 2;
-+                char *new_buf = (char *)realloc(hostName, size);
-+                if (new_buf == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+                hostName = new_buf;
-+            }
-+
-+            if (err != 0)
-                 raise_syscall(taskData, "gethostname failed", GETERROR);
-+
-             return (SAVE(C_string_to_Poly(taskData, hostName)));
-         }
- 
-     case 1:
-         {
-             /* Look up a host name. */
--            char hostName[MAXHOSTNAMELEN];
--            POLYUNSIGNED length = Poly_string_to_C(DEREFWORD(args), hostName, MAXHOSTNAMELEN);
--            if (length > MAXHOSTNAMELEN)
--                raise_syscall(taskData, "Host name too long", ENAMETOOLONG);
-+            TempCString hostName(Poly_string_to_C_alloc(DEREFWORD(args)));
-             struct hostent *host = gethostbyname(hostName);
-             if (host == NULL)
-                 raise_syscall(taskData, "gethostbyname failed", GETERROR);
-@@ -447,10 +457,7 @@
-     case 3:
-         {
-             /* Look up protocol entry. */
--            char protoName[MAXHOSTNAMELEN];
--            POLYUNSIGNED length = Poly_string_to_C(DEREFWORD(args), protoName, MAXHOSTNAMELEN);
--            if (length > MAXHOSTNAMELEN)
--                raise_syscall(taskData, "Protocol name too long", ENAMETOOLONG);
-+            TempCString protoName(Poly_string_to_C_alloc(DEREFWORD(args)));
-             struct protoent *proto = getprotobyname(protoName);
-             if (proto == NULL)
-                 raise_syscall(taskData, "getprotobyname failed", GETERROR);
-@@ -471,10 +478,7 @@
-     case 5:
-         {
-             /* Get service given service name only. */
--            char servName[MAXHOSTNAMELEN];
--            POLYUNSIGNED length = Poly_string_to_C(DEREFWORD(args), servName, MAXHOSTNAMELEN);
--            if (length > MAXHOSTNAMELEN)
--                raise_syscall(taskData, "Service name too long", ENAMETOOLONG);
-+            TempCString servName(Poly_string_to_C_alloc(DEREFWORD(args)));
-             struct servent *serv = getservbyname (servName, NULL);
-             if (serv == NULL)
-                 raise_syscall(taskData, "getservbyname failed", GETERROR);
-@@ -484,13 +488,8 @@
-     case 6:
-         {
-             /* Get service given service name and protocol name. */
--            char servName[MAXHOSTNAMELEN], protoName[MAXHOSTNAMELEN];
--            POLYUNSIGNED length = Poly_string_to_C(args->WordP()->Get(0), servName, MAXHOSTNAMELEN);
--            if (length > MAXHOSTNAMELEN)
--                raise_syscall(taskData, "Service name too long", ENAMETOOLONG);
--            length = Poly_string_to_C(args->WordP()->Get(1), protoName, MAXHOSTNAMELEN);
--            if (length > MAXHOSTNAMELEN)
--                raise_syscall(taskData, "Protocol name too long", ENAMETOOLONG);
-+            TempCString servName(Poly_string_to_C_alloc(args->WordP()->Get(0)));
-+            TempCString protoName(Poly_string_to_C_alloc(args->WordP()->Get(1)));
-             struct servent *serv = getservbyname (servName, protoName);
-             if (serv == NULL)
-                 raise_syscall(taskData, "getservbyname failed", GETERROR);
-@@ -511,12 +510,9 @@
-     case 8:
-         {
-             /* Get service given port number and protocol name. */
--            char protoName[MAXHOSTNAMELEN];
-             struct servent *serv;
-             long port = htons(get_C_ushort(taskData, DEREFHANDLE(args)->Get(0)));
--            POLYUNSIGNED length = Poly_string_to_C(args->WordP()->Get(1), protoName, MAXHOSTNAMELEN);
--            if (length > MAXHOSTNAMELEN)
--                raise_syscall(taskData, "Protocol name too long", ENAMETOOLONG);
-+            TempCString protoName(Poly_string_to_C_alloc(args->WordP()->Get(1)));
-             serv = getservbyport (port, protoName);
-             if (serv == NULL)
-                 raise_syscall(taskData, "getservbyport failed", GETERROR);
diff --git a/debian/patches/maxpathlen.diff b/debian/patches/maxpathlen.diff
deleted file mode 100644
index 93cb9ab..0000000
--- a/debian/patches/maxpathlen.diff
+++ /dev/null
@@ -1,421 +0,0 @@
-Description: Remove all use of MAXPATHLEN and its variants
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/33
-Applied-Upstream: https://github.com/polyml/polyml/commit/1fcce28158b37906ff130f6dd6d240efda934a82
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/basicio.cpp
-+++ b/libpolyml/basicio.cpp
-@@ -111,10 +111,6 @@
- #define _tcsdup strdup
- #endif
- 
--#if(!defined(MAXPATHLEN) && defined(MAX_PATH))
--#define MAXPATHLEN MAX_PATH
--#endif
--
- #ifndef O_BINARY
- #define O_BINARY    0 /* Not relevant. */
- #endif
-@@ -1651,13 +1647,21 @@
-                 raise_syscall(taskData, "GetCurrentDirectory failed", -(int)GetLastError());
-             return SAVE(C_string_to_Poly(taskData, buff));
- #else
--            // This is a bit messy in Unix.  getcwd will return an error result if there's
--            // not enough space be we have to iterate to find the size.
--            // Use the fixed size for the moment.
--            TCHAR string_buffer[MAXPATHLEN+1];
--            if (getcwd(string_buffer, MAXPATHLEN+1) == NULL)
-+            size_t size = 4096;
-+            TempString string_buffer((TCHAR *)malloc(size * sizeof(TCHAR)));
-+            if (string_buffer == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+            TCHAR *cwd;
-+            while ((cwd = getcwd(string_buffer, size)) == NULL && errno == ERANGE) {
-+                if (size > SIZE_MAX / 2) raise_fail(taskData, "getcwd needs too large a buffer");
-+                size *= 2;
-+                TCHAR *new_buf = (TCHAR *)realloc(string_buffer, size * sizeof(TCHAR));
-+                if (new_buf == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+                string_buffer = new_buf;
-+            }
-+
-+            if (cwd == NULL)
-                raise_syscall(taskData, "getcwd failed", errno);
--            return SAVE(C_string_to_Poly(taskData, string_buffer));
-+            return SAVE(C_string_to_Poly(taskData, cwd));
- #endif
-         }
- 
-@@ -1728,8 +1732,19 @@
-             int nLen;
-             TempString linkName(args->Word());
-             if (linkName == 0) raise_syscall(taskData, "Insufficient memory", ENOMEM);
--            char resBuf[MAXPATHLEN];
--            nLen = readlink(linkName, resBuf, sizeof(resBuf));
-+
-+            size_t size = 4096;
-+            TempString resBuf((TCHAR *)malloc(size * sizeof(TCHAR)));
-+            if (resBuf == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+            // nLen is signed, so cast size to ssize_t to perform signed
-+            // comparison, avoiding an infinite loop when nLen is -1.
-+            while ((nLen = readlink(linkName, resBuf, size)) >= (ssize_t) size) {
-+                size *= 2;
-+                if (size > SSIZE_MAX) raise_fail(taskData, "readlink needs too large a buffer");
-+                TCHAR *newBuf = (TCHAR *)realloc(resBuf, size * sizeof(TCHAR));
-+                if (newBuf == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+                resBuf = newBuf;
-+            }
-             if (nLen < 0) raise_syscall(taskData, "readlink failed", errno);
-             return(SAVE(C_string_to_Poly(taskData, resBuf, nLen)));
- #endif
-@@ -1780,13 +1795,18 @@
-                 raise_syscall(taskData, "GetTempPath failed", -(int)(GetLastError()));
-             lstrcat(buff, _T("MLTEMPXXXXXX"));
- #else
--            TCHAR buff[MAXPATHLEN];
-+            const char *template_subdir =  "/MLTEMPXXXXXX";
- #ifdef P_tmpdir
-+            TempString buff((TCHAR *)malloc(strlen(P_tmpdir) + strlen(template_subdir) + 1));
-+            if (buff == 0) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-             strcpy(buff, P_tmpdir);
- #else
--            strcpy(buff, "/tmp");
-+            const char *tmpdir = "/tmp";
-+            TempString buff((TCHAR *)malloc(strlen(tmpdir) + strlen(template_subdir) + 1));
-+            if (buff == 0) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+            strcpy(buff, tmpdir);
- #endif
--            strcat(buff, "/MLTEMPXXXXXX");
-+            strcat(buff, template_subdir);
- #endif
- 
- #if (defined(HAVE_MKSTEMP) && ! defined(UNICODE))
---- a/libpolyml/exporter.cpp
-+++ b/libpolyml/exporter.cpp
-@@ -82,10 +82,6 @@
- #include "machoexport.h"
- #endif
- 
--#if(!defined(MAXPATHLEN) && defined(MAX_PATH))
--#define MAXPATHLEN MAX_PATH
--#endif
--
- /*
- To export the function and everything reachable from it we need to copy
- all the objects into a new area.  We leave tombstones in the original
-@@ -416,14 +412,14 @@
- 
- static void exporter(TaskData *taskData, Handle args, const TCHAR *extension, Exporter *exports)
- {
--    TCHAR fileNameBuff[MAXPATHLEN+MAX_EXTENSION];
--    POLYUNSIGNED length =
--        Poly_string_to_C(DEREFHANDLE(args)->Get(0), fileNameBuff, MAXPATHLEN);
--    if (length > MAXPATHLEN)
--        raise_syscall(taskData, "File name too long", ENAMETOOLONG);
-+    size_t extLen = _tcslen(extension);
-+    TempString fileNameBuff(Poly_string_to_C_alloc(DEREFHANDLE(args)->Get(0), extLen * sizeof(TCHAR)));
-+    if (fileNameBuff == NULL)
-+        raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+    size_t length = _tcslen(fileNameBuff);
- 
-     // Does it already have the extension?  If not add it on.
--    if (length < _tcslen(extension) || _tcscmp(fileNameBuff + length - _tcslen(extension), extension) != 0)
-+    if (length < extLen || _tcscmp(fileNameBuff + length - extLen, extension) != 0)
-         _tcscat(fileNameBuff, extension);
- #if (defined(_WIN32) && defined(UNICODE))
-     exports->exportFile = _wfopen(fileNameBuff, L"wb");
---- a/libpolyml/polystring.cpp
-+++ b/libpolyml/polystring.cpp
-@@ -97,7 +97,7 @@
-     return chars;
- } /* Poly_string_to_C */
- 
--char *Poly_string_to_C_alloc(PolyWord ps)
-+char *Poly_string_to_C_alloc(PolyWord ps, size_t buffExtra)
- /* Similar to Poly_string_to_C except that the string is allocated using
-    malloc and must be freed by the caller. */
- {
-@@ -105,7 +105,7 @@
- 
-     if (IS_INT(ps))
-     {
--        res = (char*)malloc(2);
-+        res = (char*)malloc(2 + buffExtra);
-         if (res == 0) return 0;
-         res[0] = (char)(UNTAGGED(ps));
-         res[1] = '\0';
-@@ -114,7 +114,7 @@
-     {
-         PolyStringObject * str = (PolyStringObject *)ps.AsObjPtr();
-         POLYUNSIGNED chars = str->length;
--        res = (char*)malloc(chars+1);
-+        res = (char*)malloc(chars + buffExtra + 1);
-         if (res == 0) return 0;
-         if (chars != 0) strncpy(res, str->chars, chars);
-         res[chars] = '\0';
---- a/libpolyml/polystring.h
-+++ b/libpolyml/polystring.h
-@@ -46,7 +46,7 @@
- /* PolyStringObject functions */
- extern PolyWord C_string_to_Poly(TaskData *mdTaskData, const char *buffer, size_t buffLen = -1);
- extern POLYUNSIGNED Poly_string_to_C(PolyWord ps, char *buff, POLYUNSIGNED bufflen);
--extern char *Poly_string_to_C_alloc(PolyWord ps);
-+extern char *Poly_string_to_C_alloc(PolyWord ps, size_t buffExtra = 0);
- 
- extern Handle convert_string_list(TaskData *mdTaskData, int count, char **strings);
- 
---- a/libpolyml/savestate.cpp
-+++ b/libpolyml/savestate.cpp
-@@ -101,10 +101,6 @@
- #include "osmem.h"
- #include "gc.h" // For FullGC.
- 
--#if(!defined(MAXPATHLEN) && defined(MAX_PATH))
--#define MAXPATHLEN MAX_PATH
--#endif
--
- #ifdef _MSC_VER
- // Don't tell me about ISO C++ changes.
- #pragma warning(disable:4996)
-@@ -653,11 +649,7 @@
- 
- Handle SaveState(TaskData *taskData, Handle args)
- {
--    TCHAR fileNameBuff[MAXPATHLEN];
--    POLYUNSIGNED length =
--        Poly_string_to_C(DEREFHANDLE(args)->Get(0), fileNameBuff, MAXPATHLEN);
--    if (length > MAXPATHLEN)
--        raise_syscall(taskData, "File name too long", ENAMETOOLONG);
-+    TempString fileNameBuff(Poly_string_to_C_alloc(DEREFHANDLE(args)->Get(0)));
-     // The value of depth is zero for top-level save so we need to add one for hierarchy.
-     unsigned newHierarchy = get_C_unsigned(taskData, DEREFHANDLE(args)->Get(1)) + 1;
- 
-@@ -694,7 +686,7 @@
-     // The fileName here is the last file loaded.  As well as using it
-     // to load the name can also be printed out at the end to identify the
-     // particular file in the hierarchy that failed.
--    TCHAR fileName[MAXPATHLEN];
-+    AutoFree<TCHAR*> fileName;
-     int errNumber;
- };
- 
-@@ -710,23 +702,22 @@
-             return;
-         }
-         ML_Cons_Cell *p = DEREFLISTHANDLE(fileNameList);
--        POLYUNSIGNED length = Poly_string_to_C(p->h, fileName, MAXPATHLEN);
--        if (length > MAXPATHLEN)
-+        fileName = Poly_string_to_C_alloc(p->h);
-+        if (fileName == NULL)
-         {
--            errorResult = "File name too long";
--            errNumber = ENAMETOOLONG;
-+            errorResult = "Insufficient memory";
-+            errNumber = ENOMEM;
-             return;
-         }
-         (void)LoadFile(true, 0, p->t);
-     }
-     else
-     {
--        POLYUNSIGNED length =
--            Poly_string_to_C(DEREFHANDLE(fileNameList), fileName, MAXPATHLEN);
--        if (length > MAXPATHLEN)
-+        fileName = Poly_string_to_C_alloc(DEREFHANDLE(fileNameList));
-+        if (fileName == NULL)
-         {
--            errorResult = "File name too long";
--            errNumber = ENAMETOOLONG;
-+            errorResult = "Insufficient memory";
-+            errNumber = ENOMEM;
-             return;
-         }
-         (void)LoadFile(true, 0, TAGGED(0));
-@@ -867,11 +858,11 @@
-                 return false;
-             }
-             ML_Cons_Cell *p = (ML_Cons_Cell *)tail.AsObjPtr();
--            POLYUNSIGNED length = Poly_string_to_C(p->h, fileName, MAXPATHLEN);
--            if (length > MAXPATHLEN)
-+            fileName = Poly_string_to_C_alloc(p->h);
-+            if (fileName == NULL)
-             {
--                errorResult = "File name too long";
--                errNumber = ENAMETOOLONG;
-+                errorResult = "Insufficient memory";
-+                errNumber = ENOMEM;
-                 return false;
-             }
-             if (! LoadFile(false, header.parentTimeStamp, p->t))
-@@ -880,7 +871,17 @@
-         else
-         {
-             size_t toRead = header.stringTableSize-header.parentNameEntry;
--            if (MAXPATHLEN < toRead) toRead = MAXPATHLEN;
-+            size_t elems = ((toRead + sizeof(TCHAR) - 1) / sizeof(TCHAR));
-+            // Always allow space for null terminator
-+            size_t roundedBytes = (elems + 1) * sizeof(TCHAR);
-+            TCHAR *newFileName = (TCHAR *)realloc(fileName, roundedBytes);
-+            if (newFileName == NULL)
-+            {
-+                errorResult = "Insufficient memory";
-+                errNumber = ENOMEM;
-+                return false;
-+            }
-+            fileName = newFileName;
- 
-             if (header.parentNameEntry >= header.stringTableSize /* Bad entry */ ||
-                 fseek(loadFile, header.stringTable + header.parentNameEntry, SEEK_SET) != 0 ||
-@@ -889,7 +890,7 @@
-                 errorResult = "Unable to read parent file name";
-                 return false;
-             }
--            fileName[toRead] = 0; // Should already be null-terminated, but just in case.
-+            fileName[elems] = 0; // Should already be null-terminated, but just in case.
- 
-             if (! LoadFile(false, header.parentTimeStamp, TAGGED(0)))
-                 return false;
-@@ -1097,11 +1098,11 @@
-             raise_fail(taskData, loader.errorResult);
-         else
-         {
--            char buff[MAXPATHLEN+100];
-+            AutoFree<char*> buff((char *)malloc(strlen(loader.errorResult) + 2 + _tcslen(loader.fileName) * sizeof(TCHAR) + 1));
- #if (defined(_WIN32) && defined(UNICODE))
--            sprintf(buff, "%s: %S", loader.errorResult, loader.fileName);
-+            sprintf(buff, "%s: %S", loader.errorResult, (TCHAR *)loader.fileName);
- #else
--            sprintf(buff, "%s: %s", loader.errorResult, loader.fileName);
-+            sprintf(buff, "%s: %s", loader.errorResult, (TCHAR *)loader.fileName);
- #endif
-             raise_syscall(taskData, buff, loader.errNumber);
-         }
-@@ -1139,26 +1140,23 @@
- Handle RenameParent(TaskData *taskData, Handle args)
- // Change the name of the immediate parent stored in a child
- {
--    TCHAR fileNameBuff[MAXPATHLEN], parentNameBuff[MAXPATHLEN];
-     // The name of the file to modify.
--    POLYUNSIGNED fileLength =
--        Poly_string_to_C(DEREFHANDLE(args)->Get(0), fileNameBuff, MAXPATHLEN);
--    if (fileLength > MAXPATHLEN)
--        raise_syscall(taskData, "File name too long", ENAMETOOLONG);
-+    AutoFree<TCHAR*> fileNameBuff(Poly_string_to_C_alloc(DEREFHANDLE(args)->Get(0)));
-+    if (fileNameBuff == NULL)
-+        raise_syscall(taskData, "Insufficient memory", ENOMEM);
-     // The new parent name to insert.
--    POLYUNSIGNED parentLength =
--        Poly_string_to_C(DEREFHANDLE(args)->Get(1), parentNameBuff, MAXPATHLEN);
--    if (parentLength > MAXPATHLEN)
--        raise_syscall(taskData, "Parent name too long", ENAMETOOLONG);
-+    AutoFree<TCHAR*> parentNameBuff(Poly_string_to_C_alloc(DEREFHANDLE(args)->Get(1)));
-+    if (parentNameBuff == NULL)
-+        raise_syscall(taskData, "Insufficient memory", ENOMEM);
- 
-     AutoClose loadFile(_tfopen(fileNameBuff, _T("r+b"))); // Open for reading and writing
-     if ((FILE*)loadFile == NULL)
-     {
--        char buff[MAXPATHLEN+1+23];
-+        AutoFree<char*> buff((char *)malloc(23 + _tcslen(fileNameBuff) * sizeof(TCHAR) + 1));
- #if (defined(_WIN32) && defined(UNICODE))
--        sprintf(buff, "Cannot open load file: %S", fileNameBuff);
-+        sprintf(buff, "Cannot open load file: %S", (TCHAR *)fileNameBuff);
- #else
--        sprintf(buff, "Cannot open load file: %s", fileNameBuff);
-+        sprintf(buff, "Cannot open load file: %s", (TCHAR *)fileNameBuff);
- #endif
-         raise_syscall(taskData, buff, errno);
-     }
-@@ -1203,20 +1201,18 @@
- Handle ShowParent(TaskData *taskData, Handle hFileName)
- // Return the name of the immediate parent stored in a child
- {
--    TCHAR fileNameBuff[MAXPATHLEN+1];
--    POLYUNSIGNED length =
--        Poly_string_to_C(DEREFHANDLE(hFileName), fileNameBuff, MAXPATHLEN);
--    if (length > MAXPATHLEN)
--        raise_syscall(taskData, "File name too long", ENAMETOOLONG);
-+    AutoFree<TCHAR*> fileNameBuff(Poly_string_to_C_alloc(DEREFHANDLE(hFileName)));
-+    if (fileNameBuff == NULL)
-+        raise_syscall(taskData, "Insufficient memory", ENOMEM);
- 
-     AutoClose loadFile(_tfopen(fileNameBuff, _T("rb")));
-     if ((FILE*)loadFile == NULL)
-     {
--        char buff[MAXPATHLEN+1+23];
-+        AutoFree<char*> buff((char *)malloc(23 + _tcslen(fileNameBuff) * sizeof(TCHAR) + 1));
- #if (defined(_WIN32) && defined(UNICODE))
--        sprintf(buff, "Cannot open load file: %S", fileNameBuff);
-+        sprintf(buff, "Cannot open load file: %S", (TCHAR *)fileNameBuff);
- #else
--        sprintf(buff, "Cannot open load file: %s", fileNameBuff);
-+        sprintf(buff, "Cannot open load file: %s", (TCHAR *)fileNameBuff);
- #endif
-         raise_syscall(taskData, buff, errno);
-     }
-@@ -1239,9 +1235,13 @@
-     // Does this have a parent?
-     if (header.parentNameEntry != 0)
-     {
--        TCHAR parentFileName[MAXPATHLEN+1];
-         size_t toRead = header.stringTableSize-header.parentNameEntry;
--        if (MAXPATHLEN < toRead) toRead = MAXPATHLEN;
-+        size_t elems = ((toRead + sizeof(TCHAR) - 1) / sizeof(TCHAR));
-+        // Always allow space for null terminator
-+        size_t roundedBytes = (elems + 1) * sizeof(TCHAR);
-+        AutoFree<TCHAR*> parentFileName((TCHAR *)malloc(roundedBytes));
-+        if (parentFileName == NULL)
-+            raise_syscall(taskData, "Insufficient memory", ENOMEM);
- 
-         if (header.parentNameEntry >= header.stringTableSize /* Bad entry */ ||
-             fseek(loadFile, header.stringTable + header.parentNameEntry, SEEK_SET) != 0 ||
-@@ -1249,7 +1249,7 @@
-         {
-             raise_fail(taskData, "Unable to read parent file name");
-         }
--        parentFileName[toRead] = 0; // Should already be null-terminated, but just in case.
-+        parentFileName[elems] = 0; // Should already be null-terminated, but just in case.
-         // Convert the name into a Poly string and then build a "Some" value.
-         // It's possible, although silly, to have the empty string as a parent name.
-         Handle resVal = SAVE(C_string_to_Poly(taskData, parentFileName));
-@@ -1599,7 +1599,7 @@
-             raise_fail(taskData, loader.errorResult);
-         else
-         {
--            char buff[MAXPATHLEN+100];
-+            AutoFree<char*> buff((char *)malloc(strlen(loader.errorResult) + 2 + _tcslen(loader.fileName) * sizeof(TCHAR) + 1));
- #if (defined(_WIN32) && defined(UNICODE))
-             sprintf(buff, "%s: %S", loader.errorResult, loader.fileName);
- #else
---- a/libpolyml/statistics.cpp
-+++ b/libpolyml/statistics.cpp
-@@ -669,13 +669,26 @@
-     return result;
- #elif HAVE_MMAP
-     // Find the shared memory in the user's home directory
--    int remMapFd = -1;
--    char remMapFileName[MAXPATHLEN];
--    remMapFileName[0] = 0;
-     char *homeDir = getenv("HOME");
-     if (homeDir == NULL)
-         raise_exception_string(taskData, EXC_Fail, "No statistics available");
--    sprintf(remMapFileName, "%s/.polyml/" POLY_STATS_NAME "%" POLYUFMT, homeDir, pid);
-+
-+    int remMapFd = -1;
-+    size_t remMapSize = 4096;
-+    TempCString remMapFileName((char *)malloc(remMapSize));
-+    if (remMapFileName == NULL)
-+        raise_exception_string(taskData, EXC_Fail, "No statistics available");
-+
-+    while ((snprintf(remMapFileName, remMapSize, "%s/.polyml/" POLY_STATS_NAME "%" POLYUFMT, homeDir, pid), strlen(remMapFileName) >= remMapSize - 1)) {
-+        if (remMapSize > SIZE_MAX / 2)
-+            raise_exception_string(taskData, EXC_Fail, "No statistics available");
-+        remMapSize *= 2;
-+        char *newFileName = (char *)realloc(remMapFileName, remMapSize);
-+        if (newFileName == NULL)
-+            raise_exception_string(taskData, EXC_Fail, "No statistics available");
-+        remMapFileName = newFileName;
-+    }
-+
-     remMapFd = open(remMapFileName, O_RDONLY);
-     if (remMapFd == -1)
-         raise_exception_string(taskData, EXC_Fail, "No statistics available");
diff --git a/debian/patches/mips-abi.diff b/debian/patches/mips-abi.diff
deleted file mode 100644
index 7d966d6..0000000
--- a/debian/patches/mips-abi.diff
+++ /dev/null
@@ -1,18 +0,0 @@
-Description: Mark polyexport.o as CPIC on MIPS when code is position-independent
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/18
-Applied-Upstream: https://github.com/polyml/polyml/commit/a2b9005b22f15d84096d80b9e5a927093b9c45f1
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -393,6 +393,9 @@
- #elif defined(HOSTARCHITECTURE_MIPS)
-     fhdr.e_machine = EM_MIPS;
-     directReloc = R_MIPS_32;
-+#ifdef __PIC__
-+    fhdr.e_flags = EF_MIPS_CPIC;
-+#endif
-     useRela = true;
- #else
- #error "No support for exporting on this architecture"
diff --git a/debian/patches/mips64.diff b/debian/patches/mips64.diff
deleted file mode 100644
index 89f8145..0000000
--- a/debian/patches/mips64.diff
+++ /dev/null
@@ -1,153 +0,0 @@
-Description: Add support for 64-bit MIPS
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/24
-Applied-Upstream: https://github.com/polyml/polyml/commit/df53130085ed5e9b83b69cafd5810a4415f7285b
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -572,6 +572,9 @@
- /* Define if the host is a MIPS (32-bit) */
- #undef HOSTARCHITECTURE_MIPS
- 
-+/* Define if the host is a MIPS (64-bit) */
-+#undef HOSTARCHITECTURE_MIPS64
-+
- /* Define if the host is a PowerPC (32-bit) */
- #undef HOSTARCHITECTURE_PPC
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -451,6 +451,10 @@
-             AC_DEFINE([HOSTARCHITECTURE_M68K], [1], [Define if the host is a Motorola 68000])
-             polyarch=interpret
-             ;;
-+      mips64*)
-+            AC_DEFINE([HOSTARCHITECTURE_MIPS64], [1], [Define if the host is a MIPS (64-bit)])
-+            polyarch=interpret
-+            ;;
-       mips*)
-             AC_DEFINE([HOSTARCHITECTURE_MIPS], [1], [Define if the host is a MIPS (32-bit)])
-             polyarch=interpret
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -154,7 +154,15 @@
-         ElfXX_Rela reloc;
-         // Set the offset within the section we're scanning.
-         setRelocationAddress(relocAddr, &reloc.r_offset);
-+#ifdef HOSTARCHITECTURE_MIPS64
-+        reloc.r_sym = AreaToSym(addrArea);
-+        reloc.r_ssym = 0;
-+        reloc.r_type = directReloc;
-+        reloc.r_type2 = 0;
-+        reloc.r_type3 = 0;
-+#else
-         reloc.r_info = ELFXX_R_INFO(AreaToSym(addrArea), directReloc);
-+#endif
-         reloc.r_addend = offset;
-         fwrite(&reloc, sizeof(reloc), 1, exportFile);
-         relocationCount++;
-@@ -163,7 +171,15 @@
-     else {
-         ElfXX_Rel reloc;
-         setRelocationAddress(relocAddr, &reloc.r_offset);
-+#ifdef HOSTARCHITECTURE_MIPS64
-+        reloc.r_sym = AreaToSym(addrArea);
-+        reloc.r_ssym = 0;
-+        reloc.r_type = directReloc;
-+        reloc.r_type2 = 0;
-+        reloc.r_type3 = 0;
-+#else
-         reloc.r_info = ELFXX_R_INFO(AreaToSym(addrArea), directReloc);
-+#endif
-         fwrite(&reloc, sizeof(reloc), 1, exportFile);
-         relocationCount++;
-         return PolyWord::FromUnsigned(offset);
-@@ -285,7 +301,15 @@
-     if (useRela)
-     {
-         ElfXX_Rela reloc;
-+#ifdef HOSTARCHITECTURE_MIPS64
-+        reloc.r_sym = sym;
-+        reloc.r_ssym = 0;
-+        reloc.r_type = directReloc;
-+        reloc.r_type2 = 0;
-+        reloc.r_type3 = 0;
-+#else
-         reloc.r_info = ELFXX_R_INFO(sym, directReloc);
-+#endif
-         reloc.r_offset = offset;
-         reloc.r_addend = addend;
-         fwrite(&reloc, sizeof(reloc), 1, exportFile);
-@@ -294,7 +318,15 @@
-     else
-     {
-         ElfXX_Rel reloc;
-+#ifdef HOSTARCHITECTURE_MIPS64
-+        reloc.r_sym = sym;
-+        reloc.r_ssym = 0;
-+        reloc.r_type = directReloc;
-+        reloc.r_type2 = 0;
-+        reloc.r_type3 = 0;
-+#else
-         reloc.r_info = ELFXX_R_INFO(sym, directReloc);
-+#endif
-         reloc.r_offset = offset;
-         fwrite(&reloc, sizeof(reloc), 1, exportFile);
-         relocationCount++;
-@@ -401,6 +433,14 @@
-     fhdr.e_flags = EF_MIPS_CPIC;
- #endif
-     useRela = true;
-+#elif defined(HOSTARCHITECTURE_MIPS64)
-+    fhdr.e_machine = EM_MIPS;
-+    directReloc = R_MIPS_64;
-+    fhdr.e_flags = EF_MIPS_ARCH_64;
-+#ifdef __PIC__
-+    fhdr.e_flags |= EF_MIPS_CPIC;
-+#endif
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_ALPHA)
-     fhdr.e_machine = EM_ALPHA;
-     directReloc = R_ALPHA_REFQUAD;
---- a/libpolyml/elfexport.h
-+++ b/libpolyml/elfexport.h
-@@ -60,6 +60,38 @@
- #define ELFCLASSXX              ELFCLASS32
- #endif
- 
-+#ifdef HOSTARCHITECTURE_MIPS64
-+/* MIPS N64 ABI has a different Elf64_Rel/Rela layout */
-+
-+typedef struct
-+{
-+  Elf64_Addr r_offset;      /* Address */
-+  Elf64_Word r_sym;         /* Symbol index */
-+  unsigned char r_ssym;     /* Special symbol */
-+  unsigned char r_type3;    /* Third relocation type */
-+  unsigned char r_type2;    /* Second relocation type */
-+  unsigned char r_type;     /* First relocation type */
-+} Elf64_Mips_Rel;
-+
-+typedef struct
-+{
-+  Elf64_Addr r_offset;      /* Address */
-+  Elf64_Word r_sym;         /* Symbol index */
-+  unsigned char r_ssym;     /* Special symbol */
-+  unsigned char r_type3;    /* Third relocation type */
-+  unsigned char r_type2;    /* Second relocation type */
-+  unsigned char r_type;     /* First relocation type */
-+  Elf64_Sxword r_addend;    /* Addend */
-+} Elf64_Mips_Rela;
-+
-+#undef  ElfXX_Rel
-+#define ElfXX_Rel   Elf64_Mips_Rel
-+#undef  ElfXX_Rela
-+#define ElfXX_Rela  Elf64_Mips_Rela
-+/* Elf64_Mips_Rel/Rela has no r_info, so this macro is meaningless */
-+#undef  ELFXX_R_INFO
-+#endif
-+
- class TaskData;
- 
- class ELFExport: public Exporter, public ScanAddress
diff --git a/debian/patches/noexec-stack-gnu.diff b/debian/patches/noexec-stack-gnu.diff
deleted file mode 100644
index 338daca..0000000
--- a/debian/patches/noexec-stack-gnu.diff
+++ /dev/null
@@ -1,51 +0,0 @@
-Description: Mark stack as non-executable on all GNU systems
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/34
-Applied-Upstream: https://github.com/polyml/polyml/commit/2bdd9518cf3f938f0ca4335875840dcb160f0af8
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/x86asm.asm
-+++ b/libpolyml/x86asm.asm
-@@ -791,12 +791,10 @@
- 
- ENDIF
- 
--;# Mark the stack as non-executable when compiling for Linux
--IFDEF __linux__
--IFDEF __ELF__
-+;# Mark the stack as non-executable when supported
-+IFDEF HAVE_GNU_STACK
- .section .note.GNU-stack, "", @progbits
- ENDIF
--ENDIF
- 
- ;#
- ;# CODE STARTS HERE
---- a/config.h.in
-+++ b/config.h.in
-@@ -129,6 +129,9 @@
- /* Define to 1 if you have the `gmtime_r' function. */
- #undef HAVE_GMTIME_R
- 
-+/* Define to 1 if you have .note.GNU-stack support in the assembler. */
-+#undef HAVE_GNU_STACK
-+
- /* Define to 1 if you have the <grp.h> header file. */
- #undef HAVE_GRP_H
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -401,6 +401,13 @@
- # Additional checks. AC_CANONICAL_HOST has already been called.
- #AC_CANONICAL_HOST
- 
-+# Check for .note.GNU-stack support, used for marking the stack as non-executable.
-+AC_MSG_CHECKING([whether as supports .note.GNU-stack])
-+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[__asm__(".section .note.GNU-stack,\"\", at progbits");]])],
-+    [AC_MSG_RESULT([yes])] [AC_DEFINE([HAVE_GNU_STACK], [1],
-+        [Define to 1 if you have .note.GNU-stack support in the assembler.])],
-+    [AC_MSG_RESULT([no])])
-+
- # This option enables the native code generator.  More precisely it allows
- # the byte code interpreter to be built on X86.
- 
diff --git a/debian/patches/noflsh-unsigned.diff b/debian/patches/noflsh-unsigned.diff
deleted file mode 100644
index 96f8f45..0000000
--- a/debian/patches/noflsh-unsigned.diff
+++ /dev/null
@@ -1,17 +0,0 @@
-Description: Cast NOFLSH to unsigned
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/40
-Applied-Upstream: https://github.com/polyml/polyml/commit/00f781b621a17239ab809f30c66e6aef52d324e5
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/unix_specific.cpp
-+++ b/libpolyml/unix_specific.cpp
-@@ -285,7 +285,7 @@
-     ICANON,
-     IEXTEN,
-     ISIG,
--    NOFLSH,
-+    (unsigned)NOFLSH,
-     TOSTOP, /* 115 */
- 
-     /* TTY: Speeds. */
diff --git a/debian/patches/polyc-dont-capture-build-path.diff b/debian/patches/polyc-dont-capture-build-path.diff
deleted file mode 100644
index a4d7c33..0000000
--- a/debian/patches/polyc-dont-capture-build-path.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-Description: Don't capture -fdebug-prefix-map in polyc's CFLAGS
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/73
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/configure.ac
-+++ b/configure.ac
-@@ -559,6 +559,21 @@ if test X"$gitinstalled" = "Xyes" -a -d
-     AC_SUBST(GIT_VERSION)
- fi
- 
-+# Strip -fdebug-prefix-map= from CFLAGS; it's meaningless for users of polyc,
-+# and hurts reproducibility.
-+polyc_CFLAGS=
-+for cflag in $CFLAGS; do
-+    cflag="${cflag##-fdebug-prefix-map=*}"
-+    if test -n "$cflag"; then
-+        if test -n "$polyc_CFLAGS"; then
-+            polyc_CFLAGS="$polyc_CFLAGS $cflag"
-+        else
-+            polyc_CFLAGS="$cflag"
-+        fi
-+    fi
-+done
-+AC_SUBST([polyc_CFLAGS], ["$polyc_CFLAGS"])
-+
- # Modules directory
- AC_ARG_WITH([moduledir],
-   [AS_HELP_STRING([--with-moduledir=DIR], [directory for Poly/ML modules])],
---- a/polyc.in
-+++ b/polyc.in
-@@ -5,7 +5,7 @@ BINDIR=@bindir@
- LINK=@CXX@
- LIBDIR=@libdir@
- LIBS="@LIBS@"
--CFLAGS="@CFLAGS@"
-+CFLAGS="@polyc_CFLAGS@"
- 
- DEFAULT_COMPILER="${BINDIR}/poly"
- COMPILER=${DEFAULT_COMPILER}
diff --git a/debian/patches/polyc-it.diff b/debian/patches/polyc-it.diff
deleted file mode 100644
index 7469594..0000000
--- a/debian/patches/polyc-it.diff
+++ /dev/null
@@ -1,19 +0,0 @@
-Description: Don't set "it" in polyc
- This stops polyc from setting (and potentially shadowing) the implicit it
- variable, allowing Tests/Fail/Test071.ML to pass when the test suite is
- compiled with polyc.
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/55
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/polyc.in
-+++ b/polyc.in
-@@ -36,7 +36,7 @@
- 
- compile()
- {
--    echo "use (List.nth(CommandLine.arguments(), 2)); PolyML.export(List.nth(CommandLine.arguments(), 3), main);" | ${COMPILER} -q --error-exit  "$1" "$2"
-+    echo "val () = use (List.nth(CommandLine.arguments(), 2)); val () = PolyML.export(List.nth(CommandLine.arguments(), 3), main);" | ${COMPILER} -q --error-exit  "$1" "$2"
- }
- 
- link()
diff --git a/debian/patches/reset-save-vector-sleep.diff b/debian/patches/reset-save-vector-sleep.diff
deleted file mode 100644
index c723116..0000000
--- a/debian/patches/reset-save-vector-sleep.diff
+++ /dev/null
@@ -1,77 +0,0 @@
-Description: Ensure the save vector is reset when sleeping in
- Posix.Process.sleep. This is almost the same as commit 57bc974 in
- basicio.cpp.
-Origin: backport, https://github.com/polyml/polyml/commit/a66e52345ab56fe0af3e4862bb61a7f98a3da1db
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- /dev/null
-+++ b/Tests/Fail/Test073.ML
-@@ -0,0 +1,5 @@
-+(* Testing Posix is a problem because the Posix structure is not available in Windows. *)
-+(* This caused an assertion failure when the save vector overflowed. *)
-+Posix.Process.sleep (Time.fromMilliseconds 15000);
-+rubbish; (* Generate a "failure" i.e. the correct result *)
-+
---- a/libpolyml/unix_specific.cpp
-+++ b/libpolyml/unix_specific.cpp
-@@ -383,7 +383,6 @@
- Handle OS_spec_dispatch_c(TaskData *taskData, Handle args, Handle code)
- {
-     unsigned lastSigCount = receivedSignalCount; // Have we received a signal?
--    TryAgain:
-     int c = get_C_long(taskData, DEREFWORDHANDLE(code));
-     switch (c)
-     {
-@@ -580,27 +579,30 @@
-         }
- 
-     case 21: /* Pause until signal. */
--        {
-             /* This never returns.  When a signal is handled it will
-                be interrupted. */
-+       while (true)
-+       {
-             processes->ThreadPause(taskData);
-             if (lastSigCount != receivedSignalCount)
-                 raise_syscall(taskData, "Call interrupted by signal", EINTR);
--            goto TryAgain;
--        }
-+       }
- 
-     case 22: /* Sleep until given time or until a signal.  Note: this is called
-             with an absolute time as an argument and returns a relative time as
-             result.  This RTS call is tried repeatedly until either the time has
-             expired or a signal has occurred. */
-+        while (true)
-         {
-             struct timeval tv;
-             /* We have a value in microseconds.  We need to split
-                it into seconds and microseconds. */
-+            Handle hSave = taskData->saveVec.mark();
-             Handle hTime = args;
-             Handle hMillion = Make_arbitrary_precision(taskData, 1000000);
-             unsigned long secs = get_C_ulong(taskData, DEREFWORDHANDLE(div_longc(taskData, hMillion, hTime)));
-             unsigned long usecs = get_C_ulong(taskData, DEREFWORDHANDLE(rem_longc(taskData, hMillion, hTime)));
-+            taskData->saveVec.reset(hSave);
-             /* Has the time expired? */
-             if (gettimeofday(&tv, NULL) != 0)
-                 raise_syscall(taskData, "gettimeofday failed", errno);
-@@ -613,11 +615,13 @@
-                 processes->ThreadPause(taskData);
-                 if (lastSigCount != receivedSignalCount)
-                     raise_syscall(taskData, "Call interrupted by signal", EINTR);
--                goto TryAgain;
-+                // And loop
-+            }
-+            else
-+            {
-+                processes->TestAnyEvents(taskData); // Check for interrupts anyway
-+                return Make_arbitrary_precision(taskData, 0);
-             }
--            else processes->TestAnyEvents(taskData); // Check for interrupts anyway
--
--            return Make_arbitrary_precision(taskData, 0);
-         }
-     
-     case 23: /* Set uid. */
diff --git a/debian/patches/rounding-mode-test-allow-exceptions.diff b/debian/patches/rounding-mode-test-allow-exceptions.diff
deleted file mode 100644
index 015d948..0000000
--- a/debian/patches/rounding-mode-test-allow-exceptions.diff
+++ /dev/null
@@ -1,83 +0,0 @@
-Description: Change rounding mode test to allow for the possibility of exceptions.
- IEEReal.setRoundingMode may raise an exception if it is not implemented
- or only implemented for certain rounding modes.
-Origin: upstream, https://github.com/polyml/polyml/commit/891e8122dcca36f9c2e9eea5a3eca7cf5de9f191
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/Tests/Succeed/Test121.ML
-+++ b/Tests/Succeed/Test121.ML
-@@ -2,30 +2,49 @@
-    and compiled code. *)
- fun check x = if x then () else raise Fail "Wrong";
- open IEEEReal;
--setRoundingMode(TO_POSINF);
--check(getRoundingMode() = TO_POSINF);
--val pos = 1.0/3.0;
--check(pos * 3.0 > 1.0);
--val neg = ~1.0/3.0;
--check(neg * 3.0 > ~1.0);
- 
--setRoundingMode(TO_NEGINF);
--check(getRoundingMode() = TO_NEGINF);
--val pos = 1.0/3.0;
--check(pos * 3.0 < 1.0);
--val neg = ~1.0/3.0;
--check(neg * 3.0 < ~1.0);
-+(* setRoundingMode may raise an exception if it isn't implemented or
-+   only permits certain rounding modes. *)
-+let
-+    val () = setRoundingMode(TO_POSINF);
-+    val () = check(getRoundingMode() = TO_POSINF);
-+    val pos = 1.0/3.0;
-+    val () = check(pos * 3.0 > 1.0);
-+    val neg = ~1.0/3.0;
-+    val () = check(neg * 3.0 > ~1.0)
-+in
-+    ()
-+end handle _ => ();
- 
--setRoundingMode(TO_ZERO);
--check(getRoundingMode() = TO_ZERO);
--val pos = 1.0/3.0;
--check(pos * 3.0 < 1.0);
--val neg = ~1.0/3.0;
--check(neg * 3.0 > ~1.0);
--check(Real.==(~neg, pos));
-+let
-+    val () = setRoundingMode(TO_NEGINF);
-+    val () = check(getRoundingMode() = TO_NEGINF);
-+    val pos = 1.0/3.0;
-+    val () = check(pos * 3.0 < 1.0);
-+    val neg = ~1.0/3.0;
-+    val () = check(neg * 3.0 < ~1.0);
-+in
-+    ()
-+end handle _ => ();
- 
--setRoundingMode(TO_NEAREST);
--check(getRoundingMode() = TO_NEAREST);
--val pos = 1.0/3.0;
--val neg = ~1.0/3.0;
--check(Real.==(~neg, pos));
-+let
-+    val () = setRoundingMode(TO_ZERO);
-+    val () = check(getRoundingMode() = TO_ZERO);
-+    val pos = 1.0/3.0;
-+    val () = check(pos * 3.0 < 1.0);
-+    val neg = ~1.0/3.0;
-+    val () = check(neg * 3.0 > ~1.0);
-+    val () = check(Real.==(~neg, pos));
-+in
-+    ()
-+end handle _ => ();
-+
-+let
-+    val () = setRoundingMode(TO_NEAREST);
-+    val () = check(getRoundingMode() = TO_NEAREST);
-+    val pos = 1.0/3.0;
-+    val neg = ~1.0/3.0;
-+    val () = check(Real.==(~neg, pos));
-+in
-+    ()
-+end handle _ => ();
diff --git a/debian/patches/rounding-mode-test-only-allow-exceptions-for-set-mode.diff b/debian/patches/rounding-mode-test-only-allow-exceptions-for-set-mode.diff
deleted file mode 100644
index f676fc1..0000000
--- a/debian/patches/rounding-mode-test-only-allow-exceptions-for-set-mode.diff
+++ /dev/null
@@ -1,66 +0,0 @@
-Description: Fix change to test to deal only with an exception from setRoundingMode.
- Catching all exceptions effectively disabled the test completely
-Origin: upstream, https://github.com/polyml/polyml/commit/880d868c9fdddc9a5499701750348b28760883fa
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/Tests/Succeed/Test121.ML
-+++ b/Tests/Succeed/Test121.ML
-@@ -3,10 +3,12 @@
- fun check x = if x then () else raise Fail "Wrong";
- open IEEEReal;
- 
-+exception NotImplemented;
-+
- (* setRoundingMode may raise an exception if it isn't implemented or
-    only permits certain rounding modes. *)
- let
--    val () = setRoundingMode(TO_POSINF);
-+    val () = setRoundingMode(TO_POSINF) handle Fail _ => raise NotImplemented
-     val () = check(getRoundingMode() = TO_POSINF);
-     val pos = 1.0/3.0;
-     val () = check(pos * 3.0 > 1.0);
-@@ -14,10 +16,10 @@
-     val () = check(neg * 3.0 > ~1.0)
- in
-     ()
--end handle _ => ();
-+end handle NotImplemented => ();
- 
- let
--    val () = setRoundingMode(TO_NEGINF);
-+    val () = setRoundingMode(TO_NEGINF) handle Fail _ => raise NotImplemented
-     val () = check(getRoundingMode() = TO_NEGINF);
-     val pos = 1.0/3.0;
-     val () = check(pos * 3.0 < 1.0);
-@@ -25,10 +27,10 @@
-     val () = check(neg * 3.0 < ~1.0);
- in
-     ()
--end handle _ => ();
-+end handle NotImplemented => ();
- 
- let
--    val () = setRoundingMode(TO_ZERO);
-+    val () = setRoundingMode(TO_ZERO) handle Fail _ => raise NotImplemented
-     val () = check(getRoundingMode() = TO_ZERO);
-     val pos = 1.0/3.0;
-     val () = check(pos * 3.0 < 1.0);
-@@ -37,14 +39,14 @@
-     val () = check(Real.==(~neg, pos));
- in
-     ()
--end handle _ => ();
-+end handle NotImplemented => ();
- 
- let
--    val () = setRoundingMode(TO_NEAREST);
-+    val () = setRoundingMode(TO_NEAREST) handle Fail _ => raise NotImplemented
-     val () = check(getRoundingMode() = TO_NEAREST);
-     val pos = 1.0/3.0;
-     val neg = ~1.0/3.0;
-     val () = check(Real.==(~neg, pos));
- in
-     ()
--end handle _ => ();
-+end handle NotImplemented => ();
diff --git a/debian/patches/s390.diff b/debian/patches/s390.diff
deleted file mode 100644
index 0ca9dbc..0000000
--- a/debian/patches/s390.diff
+++ /dev/null
@@ -1,55 +0,0 @@
-Description: Add support for S/390
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/17
-Applied-Upstream: https://github.com/polyml/polyml/commit/c2f37c3c0b63d89e216af863571a14573f9586b7
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -572,6 +572,12 @@
- /* Define if the host is a PowerPC (64-bit) */
- #undef HOSTARCHITECTURE_PPC64
- 
-+/* Define if the host is an S/390 (32-bit) */
-+#undef HOSTARCHITECTURE_S390
-+
-+/* Define if the host is an S/390 (64-bit) */
-+#undef HOSTARCHITECTURE_S390X
-+
- /* Define if the host is a Sparc (32-bit) */
- #undef HOSTARCHITECTURE_SPARC
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -451,6 +451,14 @@
-             AC_DEFINE([HOSTARCHITECTURE_MIPS], [1], [Define if the host is a MIPS (32-bit)])
-             polyarch=interpret
-             ;;
-+      s390x*)
-+            AC_DEFINE([HOSTARCHITECTURE_S390X], [1], [Define if the host is an S/390 (64-bit)])
-+            polyarch=interpret
-+            ;;
-+      s390*)
-+            AC_DEFINE([HOSTARCHITECTURE_S390], [1], [Define if the host is an S/390 (32-bit)])
-+            polyarch=interpret
-+            ;;
-       *) AC_MSG_ERROR([Poly/ML is not supported for this architecture]) ;;
- esac
- 
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -348,6 +348,14 @@
-     fhdr.e_machine = EM_PPC64;
-     directReloc = R_PPC64_ADDR64;
-     useRela = true;
-+#elif defined(HOSTARCHITECTURE_S390)
-+    fhdr.e_machine = EM_S390;
-+    directReloc = R_390_32;
-+    useRela = true;
-+#elif defined(HOSTARCHITECTURE_S390X)
-+    fhdr.e_machine = EM_S390;
-+    directReloc = R_390_64;
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_SPARC)
-     fhdr.e_machine = EM_SPARC;
-     directReloc = R_SPARC_32;
diff --git a/debian/patches/series b/debian/patches/series
index 9f3ee40..6928140 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,31 +1 @@
-streamtoken-endian.diff
-ioctl-int.diff
-s390.diff
-rounding-mode-test-allow-exceptions.diff
-rounding-mode-test-only-allow-exceptions-for-set-mode.diff
-soft-fpu.diff
-disable-compile-time-real-eval.diff
-mips-abi.diff
-unix-const-vec-unsigned.diff
-fix-script-args.diff
-fix-heap-ratio-assert.diff
-use-polyunsigned-consistently-for-stream-ids.diff
-alpha.diff
-m68k.diff
-mips64.diff
-x32.diff
-maxpathlen.diff
-noexec-stack-gnu.diff
-source-date-epoch.diff
-bss-ioarea.diff
-noflsh-unsigned.diff
-maxhostnamelen.diff
-sparc64.diff
-sh.diff
-hppa.diff
-thread-exited-interrupt-requested-overlap.diff
-polyc-it.diff
-reset-save-vector-sleep.diff
-wait-return-valid-status.diff
-polyc-dont-capture-build-path.diff
-spelling-errors.diff
+# No patches
diff --git a/debian/patches/sh.diff b/debian/patches/sh.diff
deleted file mode 100644
index eaaf7cc..0000000
--- a/debian/patches/sh.diff
+++ /dev/null
@@ -1,80 +0,0 @@
-Description: Add support for SuperH
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/46
-Applied-Upstream: https://github.com/polyml/polyml/commit/d84d17f7cdbd921eb26489a66df25037054ccdf7
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -590,6 +590,9 @@
- /* Define if the host is an S/390 (64-bit) */
- #undef HOSTARCHITECTURE_S390X
- 
-+/* Define if the host is a SuperH (32-bit) */
-+#undef HOSTARCHITECTURE_SH
-+
- /* Define if the host is a Sparc (32-bit) */
- #undef HOSTARCHITECTURE_SPARC
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -483,6 +483,10 @@
-             AC_DEFINE([HOSTARCHITECTURE_S390], [1], [Define if the host is an S/390 (32-bit)])
-             polyarch=interpret
-             ;;
-+      sh*)
-+            AC_DEFINE([HOSTARCHITECTURE_SH], [1], [Define if the host is a SuperH (32-bit)])
-+            polyarch=interpret
-+            ;;
-       alpha*)
-             AC_DEFINE([HOSTARCHITECTURE_ALPHA], [1], [Define if the host is an Alpha (64-bit)])
-             polyarch=interpret
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -390,6 +390,10 @@
-     fhdr.e_machine = EM_S390;
-     directReloc = R_390_64;
-     useRela = true;
-+#elif defined(HOSTARCHITECTURE_SH)
-+    fhdr.e_machine = EM_SH;
-+    directReloc = R_SH_DIR32;
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_SPARC)
-     fhdr.e_machine = EM_SPARC;
-     directReloc = R_SPARC_32;
---- a/libpolyml/reals.cpp
-+++ b/libpolyml/reals.cpp
-@@ -393,16 +393,18 @@
- // but they are frequently inlined 
- #elif defined(HAVE_FENV_H)
- // C99 version.  This is becoming the most common.
--static int getrounding(TaskData *)
-+static int getrounding(TaskData *taskData)
- {
-     switch (fegetround())
-     {
-     case FE_TONEAREST: return POLY_ROUND_TONEAREST;
-+#ifndef HOSTARCHITECTURE_SH
-     case FE_DOWNWARD: return POLY_ROUND_DOWNWARD;
-     case FE_UPWARD: return POLY_ROUND_UPWARD;
-+#endif
-     case FE_TOWARDZERO: return POLY_ROUND_TOZERO;
-     }
--    return 0; // Keep the compiler happy
-+    raise_exception_string(taskData, EXC_Fail, "Set to an unknown rounding mode");
- }
- 
- static void setrounding(TaskData *taskData, Handle args)
-@@ -410,9 +412,12 @@
-     switch (get_C_long(taskData, DEREFWORDHANDLE(args)))
-     {
-     case POLY_ROUND_TONEAREST: fesetround(FE_TONEAREST); break; // Choose nearest
-+#ifndef HOSTARCHITECTURE_SH
-     case POLY_ROUND_DOWNWARD: fesetround(FE_DOWNWARD); break; // Towards negative infinity
-     case POLY_ROUND_UPWARD: fesetround(FE_UPWARD); break; // Towards positive infinity
-+#endif
-     case POLY_ROUND_TOZERO: fesetround(FE_TOWARDZERO); break; // Truncate towards zero
-+    default: raise_exception_string(taskData, EXC_Fail, "Unsupported rounding mode");
-     }
- }
- 
diff --git a/debian/patches/soft-fpu.diff b/debian/patches/soft-fpu.diff
deleted file mode 100644
index 0b26508..0000000
--- a/debian/patches/soft-fpu.diff
+++ /dev/null
@@ -1,37 +0,0 @@
-Description: Handle setround/getround on soft fpu
-Origin: upstream, https://github.com/polyml/polyml/commit/5ebcc2893fa1d30c9493e2c9958205f5d6863ccb
-Author: James Clarke <jrtc27 at jrtc7.com>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/reals.cpp
-+++ b/libpolyml/reals.cpp
-@@ -370,9 +370,28 @@
- #define POLY_ROUND_UPWARD       2
- #define POLY_ROUND_TOZERO       3
- 
-+#if defined(__SOFTFP__)
-+// soft-float lacks proper rounding mode support
-+// While some systems will support fegetround/fesetround, it will have no
-+// effect on the actual rounding performed, as the software implementation only
-+// ever rounds to nearest.
-+static int getrounding(TaskData *)
-+{
-+    return POLY_ROUND_TONEAREST;
-+}
-+
-+static void setrounding(TaskData *taskData, Handle args)
-+{
-+    switch (get_C_long(taskData, DEREFWORDHANDLE(args)))
-+    {
-+    case POLY_ROUND_TONEAREST: return; // The only mode supported
-+    }
-+    raise_exception_string(taskData, EXC_Fail, "setRound: Not implemented");
-+}
-+
- // It would be nice to be able to use autoconf to test for these as functions
- // but they are frequently inlined 
--#if defined(HAVE_FENV_H)
-+#elif defined(HAVE_FENV_H)
- // C99 version.  This is becoming the most common.
- static int getrounding(TaskData *)
- {
diff --git a/debian/patches/source-date-epoch.diff b/debian/patches/source-date-epoch.diff
deleted file mode 100644
index 276b70d..0000000
--- a/debian/patches/source-date-epoch.diff
+++ /dev/null
@@ -1,252 +0,0 @@
-Description: Use SOURCE_DATE_EPOCH instead of current time if it is defined
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/31
-Applied-Upstream: https://github.com/polyml/polyml/commit/9f2cb26e5c91fc8cd59d1348961a4ded0ca1b1d3
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/basis/FinalPolyML.sml
-+++ b/basis/FinalPolyML.sml
-@@ -833,10 +833,6 @@
-     (* Time stamps. *)
-     type timeStamp = Time.time;
-     val firstTimeStamp : timeStamp = Time.zeroTime;
--    (* Get the current time. *)
--    val newTimeStamp : unit -> timeStamp = Time.now
--    (* Get the date of a file. *)
--    val fileTimeStamp : string -> timeStamp = OS.FileSys.modTime
-     
-     local
-         open ProtectedTable
-@@ -862,6 +858,27 @@
-     (* Main make function *)
-     fun make (targetName: string) : unit =
-     let
-+        local
-+            val sourceDateEpochEnv : string option = OS.Process.getEnv "SOURCE_DATE_EPOCH";
-+        in
-+            val sourceDateEpoch : timeStamp option =
-+                case sourceDateEpochEnv of
-+                     NONE => NONE
-+                   | SOME s =>
-+                       (case Int.fromString s of
-+                             NONE => NONE
-+                           | SOME t => SOME(Time.fromSeconds t) handle Time.Time => NONE)
-+        end;
-+
-+        (* Get the current time. *)
-+        val newTimeStamp : unit -> timeStamp = case sourceDateEpoch of
-+                                                    NONE => Time.now
-+                                                  | SOME t => fn _ => t;
-+        (* Get the date of a file. *)
-+        val fileTimeStamp : string -> timeStamp = case sourceDateEpoch of
-+                                                    NONE => OS.FileSys.modTime
-+                                                  | SOME t => fn _ => t;
-+
-         (* This serves two purposes. It provides a list of objects which have been
-            re-made to prevent them being made more than once, and it also prevents
-            circular dependencies from causing infinite loops (e.g. let x = f(x)) *)
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -115,6 +115,7 @@
- #include "run_time.h"
- #include "version.h"
- #include "polystring.h"
-+#include "timing.h"
- 
- #define sym_last_local_sym sym_data_section
- 
-@@ -687,7 +688,7 @@
-     // Set the value to be the offset relative to the base of the area.  We have set a relocation
-     // already which will add the base of the area.
-     exports.rootFunction = useRela ? 0 : (void*)rootOffset;
--    exports.timeStamp = time(NULL);
-+    exports.timeStamp = getBuildTime();
-     exports.ioSpacing = ioSpacing;
-     exports.architecture = machineDependent->MachineArchitecture();
-     exports.rtsVersion = POLY_version_number;
---- a/libpolyml/machoexport.cpp
-+++ b/libpolyml/machoexport.cpp
-@@ -78,7 +78,7 @@
- #include "run_time.h"
- #include "version.h"
- #include "polystring.h"
--
-+#include "timing.h"
- 
- // Mach-O seems to require each section to have a discrete virtual address range
- // so we have to adjust various offsets to fit.
-@@ -492,7 +492,7 @@
-     // Set the value to be the offset relative to the base of the area.  We have set a relocation
-     // already which will add the base of the area.
-     exports.rootFunction = (void*)rootOffset;
--    exports.timeStamp = time(NULL);
-+    exports.timeStamp = getBuildTime();
-     exports.ioSpacing = ioSpacing;
-     exports.architecture = machineDependent->MachineArchitecture();
-     exports.rtsVersion = POLY_version_number;
---- a/libpolyml/pecoffexport.cpp
-+++ b/libpolyml/pecoffexport.cpp
-@@ -56,7 +56,7 @@
- #include "../polyexports.h"
- #include "version.h"
- #include "polystring.h"
--
-+#include "timing.h"
- 
- #ifdef _DEBUG
- /* MS C defines _DEBUG for debug builds. */
-@@ -184,8 +184,7 @@
-     unsigned i;
-     // These are written out as the description of the data.
-     exportDescription exports;
--    time_t now;
--    time(&now);
-+    time_t now = getBuildTime();
- 
-     sections = new IMAGE_SECTION_HEADER [memTableEntries+1]; // Plus one for the tables.
- 
-@@ -198,7 +197,7 @@
-     fhdr.Machine = IMAGE_FILE_MACHINE_I386; // i386
- #endif
-     fhdr.NumberOfSections = memTableEntries+1; // One for each area plus one for the tables.
--    (void)time((time_t*)&fhdr.TimeDateStamp);
-+    fhdr.TimeDateStamp = (DWORD)now;
-     //fhdr.NumberOfSymbols = memTableEntries+1; // One for each area plus "poly_exports"
-     fwrite(&fhdr, sizeof(fhdr), 1, exportFile); // Write it for the moment.
- 
---- a/libpolyml/pexport.cpp
-+++ b/libpolyml/pexport.cpp
-@@ -30,10 +30,6 @@
- #include <stdio.h>
- #endif
- 
--#ifdef HAVE_TIME_H
--#include <time.h>
--#endif
--
- #ifdef HAVE_ERRNO_H
- #include <errno.h>
- #endif
-@@ -272,8 +268,6 @@
- void PExport::exportStore(void)
- {
-     unsigned i;
--    time_t now;
--    time(&now);
- 
-     // Calculate a first guess for the map size based on the space size
-     totalBytes = 0;
---- a/libpolyml/savestate.cpp
-+++ b/libpolyml/savestate.cpp
-@@ -100,6 +100,7 @@
- #include "machine_dep.h"
- #include "osmem.h"
- #include "gc.h" // For FullGC.
-+#include "timing.h"
- 
- #ifdef _MSC_VER
- // Don't tell me about ISO C++ changes.
-@@ -559,7 +560,7 @@
-         saveHeader.parentTimeStamp = hierarchyTable[newHierarchy-2]->timeStamp;
-         saveHeader.parentNameEntry = sizeof(TCHAR); // Always the first entry.
-     }
--    saveHeader.timeStamp = time(NULL);
-+    saveHeader.timeStamp = getBuildTime();
-     saveHeader.segmentDescrCount = exports.memTableEntries; // One segment for each space.
-     // Write out the header.
-     fwrite(&saveHeader, sizeof(saveHeader), 1, exports.exportFile);
-@@ -1348,7 +1349,7 @@
-         modHeader.rootSegment = mt->mtIndex;
-         modHeader.rootOffset = (char*)this->rootFunction - (char*)mt->mtAddr;
-     }
--    modHeader.timeStamp = time(NULL);
-+    modHeader.timeStamp = getBuildTime();
-     modHeader.segmentDescrCount = this->memTableEntries; // One segment for each space.
-     // Write out the header.
-     fwrite(&modHeader, sizeof(modHeader), 1, this->exportFile);
---- a/libpolyml/timing.cpp
-+++ b/libpolyml/timing.cpp
-@@ -99,6 +99,8 @@
- #include <windows.h>
- #endif
- 
-+#include <limits>
-+
- #include "locking.h"
- #include "globals.h"
- #include "arb.h"
-@@ -143,8 +145,10 @@
- 
- #if (defined(_WIN32) && ! defined(__CYGWIN__))
- static FILETIME startTime;
-+#define StrToLL _strtoi64
- #else
- static struct timeval startTime;
-+#define StrToLL strtoll
- #endif
- 
- #if(!(defined(HAVE_GMTIME_R) && defined(HAVE_LOCALTIME_R)))
-@@ -153,6 +157,9 @@
- static PLock timeLock("Timing");
- #endif
- 
-+#define XSTR(X) STR(X)
-+#define STR(X)  #X
-+
- Handle timing_dispatch_c(TaskData *taskData, Handle args, Handle code)
- {
-     unsigned c = get_C_unsigned(taskData, DEREFWORDHANDLE(code));
-@@ -513,3 +520,44 @@
-     gettimeofday(&startTime, NULL);
- #endif
- }
-+
-+// Windows headers define min/max macros, which messes up trying to use std::numeric_limits<T>::min/max()
-+#ifdef min
-+#undef min
-+#endif
-+#ifdef max
-+#undef max
-+#endif
-+
-+time_t getBuildTime(void)
-+{
-+    char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
-+    if (source_date_epoch) {
-+        errno = 0;
-+        char *endptr;
-+        long long epoch = StrToLL(source_date_epoch, &endptr, 10);
-+        if ((errno == ERANGE && (epoch == LLONG_MIN || epoch == LLONG_MAX)) || (errno != 0 && epoch == 0)) {
-+            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: " XSTR(StrToLL) ": %s\n", strerror(errno));
-+            goto err;
-+        }
-+        if (endptr == source_date_epoch) {
-+            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n", endptr);
-+            goto err;
-+        }
-+        if (*endptr != '\0') {
-+            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n", endptr);
-+            goto err;
-+        }
-+        if (epoch < (long long)std::numeric_limits<time_t>::min()) {
-+            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: value must be greater than or equal to: %lld but was found to be: %lld\n", (long long)std::numeric_limits<time_t>::min(), epoch);
-+            goto err;
-+        }
-+        if (epoch > (long long)std::numeric_limits<time_t>::max()) {
-+            fprintf(stderr, "Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lld but was found to be: %lld\n", (long long)std::numeric_limits<time_t>::max(), epoch);
-+            goto err;
-+        }
-+        return (time_t) epoch;
-+    }
-+err:
-+    return time(NULL);
-+}
---- a/libpolyml/timing.h
-+++ b/libpolyml/timing.h
-@@ -105,4 +105,6 @@
- extern float timevalToSeconds(const struct timeval *x);
- #endif
- 
-+extern time_t getBuildTime(void);
-+
- #endif
diff --git a/debian/patches/sparc64.diff b/debian/patches/sparc64.diff
deleted file mode 100644
index 35d106c..0000000
--- a/debian/patches/sparc64.diff
+++ /dev/null
@@ -1,47 +0,0 @@
-Description: Add support for 64-bit SPARC
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/25
-Applied-Upstream: https://github.com/polyml/polyml/commit/a0e161bbddb93439715c7958a14b2dfc10e1f526
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -593,6 +593,9 @@
- /* Define if the host is a Sparc (32-bit) */
- #undef HOSTARCHITECTURE_SPARC
- 
-+/* Define if the host is a Sparc (64-bit) */
-+#undef HOSTARCHITECTURE_SPARC64
-+
- /* Define if the host is an X86 (32-bit ABI, 64-bit processor) */
- #undef HOSTARCHITECTURE_X32
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -435,6 +435,10 @@
-                 polyarch=interpret
-             fi
-             ;;
-+      sparc64*)
-+            AC_DEFINE([HOSTARCHITECTURE_SPARC64], [1], [Define if the host is a Sparc (64-bit)])
-+            polyarch=interpret
-+            ;;
-       sparc*)
-             AC_DEFINE([HOSTARCHITECTURE_SPARC], [1], [Define if the host is a Sparc (32-bit)])
-             polyarch=interpret
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -398,6 +398,13 @@
-        though, it adds the value in the location being relocated (as with ELF32_Rel
-        relocations) as well as the addend. To be safe, whenever we use an ELF32_Rela
-        relocation we always zero the location to be relocated. */
-+#elif defined(HOSTARCHITECTURE_SPARC64)
-+    fhdr.e_machine = EM_SPARCV9;
-+    directReloc = R_SPARC_64;
-+    /* Use the most relaxed memory model. At link time, the most restrictive one is
-+       chosen, so it does no harm to be as permissive as possible here. */
-+    fhdr.e_flags = EF_SPARCV9_RMO;
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_X86_64)
-     /* It seems Solaris/X86-64 only supports ELF64_Rela relocations.  It appears that
-        Linux will support either so we now use Rela on X86-64. */
diff --git a/debian/patches/spelling-errors.diff b/debian/patches/spelling-errors.diff
deleted file mode 100644
index 248ff1e..0000000
--- a/debian/patches/spelling-errors.diff
+++ /dev/null
@@ -1,56 +0,0 @@
-Description: Export ioarea to bss section
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/74
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/mlsource/MLCompiler/CodeTree/ByteCode/CODE_SEG.ML
-+++ b/mlsource/MLCompiler/CodeTree/ByteCode/CODE_SEG.ML
-@@ -195,7 +195,7 @@ struct
-   end
- 
-   | csegCopySeg _ =
--    raise InternalError "csegCopySeg: can only copy between byte segements"
-+    raise InternalError "csegCopySeg: can only copy between byte segments"
-   
-   (* Returns a value from the vector. *)
-   fun csegGet (ref (_, addr), byteIndex : int) : Word8.word =
-@@ -220,7 +220,7 @@ struct
-   end;
-        
-   fun csegSet (ref (LockedCode, _), _, _) : unit =
--    raise InternalError "csegSet: can't change locked code segement"
-+    raise InternalError "csegSet: can't change locked code segment"
-    
-     | csegSet (r as (ref (status, addr)), byteIndex:int, value:Word8.word) : unit =
-   let
---- a/mlsource/MLCompiler/CodeTree/X86Code/CODE_ARRAY.ML
-+++ b/mlsource/MLCompiler/CodeTree/X86Code/CODE_ARRAY.ML
-@@ -131,7 +131,7 @@ struct
-         else System_move_bytes(fromAddr, 0w0, toAddr, offsetBytes, lengthBytes)
-     end
- 
--    |   csegCopySeg _ = raise InternalError "csegCopySeg: can only copy between byte segements"
-+    |   csegCopySeg _ = raise InternalError "csegCopySeg: can only copy between byte segments"
-   
-     (* Returns a value from the vector. *)
-     fun csegGet (ref (_, addr), byteIndex : word) : Word8.word =
-@@ -145,7 +145,7 @@ struct
-     end
-        
-     fun csegSet (ref (LockedCode, _), _, _) : unit =
--        raise InternalError "csegSet: can't change locked code segement"
-+        raise InternalError "csegSet: can't change locked code segment"
-    
-     |   csegSet (r as (ref (status, addr)), byteIndex, value:Word8.word) : unit =
-         let
---- a/mlsource/MLCompiler/LEX_.ML
-+++ b/mlsource/MLCompiler/LEX_.ML
-@@ -457,7 +457,7 @@ struct
-              else if isOperator c
-                then parseIdent state isOperator (idVal ^ ".")
-                  
--             else lexError(state, "invalid identifer - "^ idVal ^ "." ^ str c)
-+             else lexError(state, "invalid identifier - "^ idVal ^ "." ^ str c)
-         end
-         else 
-         (
diff --git a/debian/patches/streamtoken-endian.diff b/debian/patches/streamtoken-endian.diff
deleted file mode 100644
index 68d84f3..0000000
--- a/debian/patches/streamtoken-endian.diff
+++ /dev/null
@@ -1,23 +0,0 @@
-Description: Use a POLYUNSIGNED for StreamToken.streamNo
- On a 64-bit big-endian architecture with sizeof(unsigned) == 4, streamNo
- is set for stdin/stdout/stderr in add_word_to_io_area by treating it as
- a PolyWord, which is a 64-bit value. However, streamNo is a 32-bit
- value, so any code that uses it sees 4 bytes of zeroes, as the
- least-significant bits are in the next 4 bytes. By using a POLYUNSIGNED,
- the sizes match.
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/17
-Applied-Upstream: https://github.com/polyml/polyml/commit/c2f37c3c0b63d89e216af863571a14573f9586b7
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/globals.h
-+++ b/libpolyml/globals.h
-@@ -399,7 +399,7 @@
- class StreamToken: public PolyObject
- {
- public:
--    unsigned    streamNo;
-+    POLYUNSIGNED streamNo;
- };
- 
- /* Macro to round a number of bytes up to a number of words. */
diff --git a/debian/patches/thread-exited-interrupt-requested-overlap.diff b/debian/patches/thread-exited-interrupt-requested-overlap.diff
deleted file mode 100644
index 67e4527..0000000
--- a/debian/patches/thread-exited-interrupt-requested-overlap.diff
+++ /dev/null
@@ -1,21 +0,0 @@
-Description: Fix threadExited and interrupt_requested overlapping
- HAVE_PTHREAD isn't necessarily defined when processes.h is included, as
- it is defined in processes.cpp, but not when included by interpret.cpp.
- As a result, the root thread can believe that an interrupted thread has
- been killed, prematurely deleting its task data. This fixes #9.
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/51
-Applied-Upstream: https://github.com/polyml/polyml/commit/4ce6eee5829c256da2d2709787e19ea83a56f48c
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/processes.h
-+++ b/libpolyml/processes.h
-@@ -172,7 +172,7 @@
- #ifdef HAVE_WINDOWS_H
-     LONGLONG lastCPUTime; // Used for profiling
- #endif
--#ifdef HAVE_PTHREAD
-+#if ((!defined(_WIN32) || defined(__CYGWIN__)) && defined(HAVE_LIBPTHREAD) && defined(HAVE_PTHREAD_H))
- public:
-     bool threadExited;
- private:
diff --git a/debian/patches/unix-const-vec-unsigned.diff b/debian/patches/unix-const-vec-unsigned.diff
deleted file mode 100644
index cc264c0..0000000
--- a/debian/patches/unix-const-vec-unsigned.diff
+++ /dev/null
@@ -1,19 +0,0 @@
-Description: Define unixConstVec as unsigned
- .
- Fixes narrowing conversion inside braces on PowerPC with GCC 6
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/19
-Applied-Upstream: https://github.com/polyml/polyml/commit/185db53b08dfb606dc8f0f8bf3ce9f85260d1c59
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/unix_specific.cpp
-+++ b/libpolyml/unix_specific.cpp
-@@ -135,7 +135,7 @@
- #define SIZEOF(x) (sizeof(x)/sizeof(PolyWord))
- 
- /* Table of constants returned by call 4. */
--static int unixConstVec[] =
-+static unsigned unixConstVec[] =
- {
-     /* Error codes. */
-     E2BIG, /* 0 */
diff --git a/debian/patches/use-polyunsigned-consistently-for-stream-ids.diff b/debian/patches/use-polyunsigned-consistently-for-stream-ids.diff
deleted file mode 100644
index 66c1c4c..0000000
--- a/debian/patches/use-polyunsigned-consistently-for-stream-ids.diff
+++ /dev/null
@@ -1,158 +0,0 @@
-Description: Use POLYUNSIGNED consistently for stream IDs
- Handle failure in realloc correctly in make_stream_entry.
-Origin: upstream, https://github.com/polyml/polyml/commit/8423a37ce77b1811387a0932d44949f9c08970b8
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/basicio.cpp
-+++ b/libpolyml/basicio.cpp
-@@ -255,7 +255,7 @@
- 
- #endif
- 
--static unsigned max_streams;
-+static POLYUNSIGNED max_streams;
- 
- /* If we try opening a stream and it fails with EMFILE (too many files
-    open) we may be able to recover by garbage-collecting and closing some
-@@ -326,7 +326,7 @@
-    deleted if there is a garbage collection (Entries in the stream vector
-    itself are "weak". */ 
- {
--    unsigned stream_no;
-+    POLYUNSIGNED stream_no;
- 
-     ioLock.Lock();
-     // Find an unused entry.
-@@ -337,10 +337,12 @@
-     /* Check we have enough space. */
-     if (stream_no >= max_streams)
-     { /* No space. */
--        int oldMax = max_streams;
-+        POLYUNSIGNED oldMax = max_streams;
-         max_streams += max_streams/2;
--        basic_io_vector =
-+        PIOSTRUCT newVector =
-             (PIOSTRUCT)realloc(basic_io_vector, max_streams*sizeof(IOSTRUCT));
-+        if (newVector == NULL) return NULL;
-+        basic_io_vector = newVector;
-         /* Clear the new space. */
-         memset(basic_io_vector+oldMax, 0, (max_streams-oldMax)*sizeof(IOSTRUCT));
-     }
-@@ -375,7 +377,7 @@
-    run out and must perform a full garbage collection to recover
-    the unused ones. SPF 12/9/95
- */ 
--void free_stream_entry(unsigned stream_no)
-+void free_stream_entry(POLYUNSIGNED stream_no)
- {
-     ASSERT(0 <= stream_no && stream_no < max_streams);
- 
-@@ -410,7 +412,8 @@
-         TempString cFileName(filename->Word()); // Get file name
-         if (cFileName == 0) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-         Handle str_token = make_stream_entry(taskData);
--        unsigned stream_no = STREAMID(str_token);
-+        if (str_token == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+        POLYUNSIGNED stream_no = STREAMID(str_token);
-         int stream = _topen(cFileName, mode, access);
- 
-         if (stream >= 0)
-@@ -464,7 +467,7 @@
- static Handle close_file(TaskData *taskData, Handle stream)
- {
-     PIOSTRUCT strm = get_stream(DEREFHANDLE(stream));
--    unsigned stream_no = STREAMID(stream);
-+    POLYUNSIGNED stream_no = STREAMID(stream);
- 
-     if (strm != NULL && stream_no > 2)
-         /* Ignore closed streams, stdin, stdout or stderr. */
-@@ -1057,7 +1060,8 @@
-     while (1) // Only certain errors
-     {
-         Handle str_token = make_stream_entry(taskData);
--        unsigned stream_no    = STREAMID(str_token);
-+        if (str_token == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+        POLYUNSIGNED stream_no    = STREAMID(str_token);
-         PIOSTRUCT strm = &basic_io_vector[stream_no];
- #if (defined(_WIN32) && ! defined(__CYGWIN__))
-         {
-@@ -1608,7 +1612,8 @@
-             }
-             /* Have to make a new entry. */
-             Handle str_token = make_stream_entry(taskData);
--            unsigned stream_no    = STREAMID(str_token);
-+            if (str_token == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+            POLYUNSIGNED stream_no    = STREAMID(str_token);
-             str = &basic_io_vector[stream_no];
-             str->device.ioDesc = get_C_int(taskData, DEREFWORD(args));
-             /* We don't know whether it's open for read, write or even if
---- a/libpolyml/io_internal.h
-+++ b/libpolyml/io_internal.h
-@@ -106,7 +106,7 @@
- extern PIOSTRUCT get_stream(PolyObject *obj);
- 
- extern Handle make_stream_entry(TaskData *mdTaskData);
--extern void free_stream_entry(unsigned stream_no);
-+extern void free_stream_entry(POLYUNSIGNED stream_no);
- extern void close_stream(PIOSTRUCT str);
- 
- extern PIOSTRUCT basic_io_vector;
---- a/libpolyml/network.cpp
-+++ b/libpolyml/network.cpp
-@@ -548,8 +548,9 @@
-     case 14: /* Create a socket */
-         {
-             Handle str_token = make_stream_entry(taskData);
-+            if (str_token == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-             PIOSTRUCT strm;
--            unsigned stream_no = STREAMID(str_token);
-+            POLYUNSIGNED stream_no = STREAMID(str_token);
-             int af = get_C_int(taskData, DEREFHANDLE(args)->Get(0));
-             int type = get_C_int(taskData, DEREFHANDLE(args)->Get(1));
-             int proto = get_C_int(taskData, DEREFHANDLE(args)->Get(2));
-@@ -798,18 +799,17 @@
-             PIOSTRUCT strm = get_stream(args->WordP());
-             if (strm == NULL) raise_syscall(taskData, "Stream is closed", EBADF);
-             else {
--                SOCKET sock = strm->device.sock, result;
-+                SOCKET sock = strm->device.sock;
-                 struct sockaddr resultAddr;
--                socklen_t addrLen;
-                 Handle addrHandle, pair;
--                Handle str_token;
-                 PIOSTRUCT newStrm;
-                 /* Get a token for the new socket - may raise an
-                    exception if it fails. */
--                str_token = make_stream_entry(taskData);
--                unsigned stream_no = STREAMID(str_token);
--                addrLen = sizeof(resultAddr);
--                result = accept(sock, &resultAddr, &addrLen);
-+                Handle str_token = make_stream_entry(taskData);
-+                if (str_token == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-+                POLYUNSIGNED stream_no = STREAMID(str_token);
-+                socklen_t addrLen = sizeof(resultAddr);
-+                SOCKET result = accept(sock, &resultAddr, &addrLen);
- 
-                 if (result == INVALID_SOCKET)
-                 {
-@@ -1184,7 +1184,9 @@
- #else
-         {
-             Handle str_token1 = make_stream_entry(taskData);
-+            if (str_token1 == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-             Handle str_token2 = make_stream_entry(taskData);
-+            if (str_token2 == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-             Handle pair;
-             PIOSTRUCT strm1, strm2;
-             unsigned stream_no1 = STREAMID(str_token1);
---- a/libpolyml/windows_specific.cpp
-+++ b/libpolyml/windows_specific.cpp
-@@ -1013,6 +1013,7 @@
-     if (fIsText) mode |= _O_TEXT; else mode |= _O_BINARY;
- 
-     Handle str_token = make_stream_entry(taskData);
-+    if (str_token == NULL) raise_syscall(taskData, "Insufficient memory", ENOMEM);
-     PIOSTRUCT strm = &basic_io_vector[STREAMID(str_token)];
-     strm->device.ioDesc = _open_osfhandle ((POLYSIGNED) hStream, mode);
-     if (strm->device.ioDesc == -1)
diff --git a/debian/patches/wait-return-valid-status.diff b/debian/patches/wait-return-valid-status.diff
deleted file mode 100644
index c49d59f..0000000
--- a/debian/patches/wait-return-valid-status.diff
+++ /dev/null
@@ -1,30 +0,0 @@
-Description: Only return the "status" value from "wait" if the result is
- non-zero. The calling code in the Posix structure converts the status result
- to a value of type exit_status even if the pid is zero.  The result is
- ignored in that case but it can result in a Fail exception if the status is
- invalid.
-Origin: backport, https://github.com/polyml/polyml/commit/ba608ceb1dbc20db934bd01b0bccdd50c08ac4e9
-Author: David Matthews <dm at prolingua.co.uk>
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/libpolyml/unix_specific.cpp
-+++ b/libpolyml/unix_specific.cpp
-@@ -1256,7 +1256,7 @@
-     int callFlags = get_C_long(taskData, DEREFHANDLE(args)->Get(2));
-     int flags = callFlags | WNOHANG; // Add in WNOHANG so we never block.
-     pid_t pres = 0;
--    int status;
-+    int status = 0;
-     switch (kind)
-     {
-     case 0: /* Wait for any child. */
-@@ -1292,7 +1292,8 @@
-     {
-         Handle result, pidHandle, resHandle;
-         pidHandle = Make_arbitrary_precision(taskData, pres);
--        resHandle = Make_arbitrary_precision(taskData, status);
-+        // If the pid is zero status may not be a valid value and may overflow.
-+        resHandle = Make_arbitrary_precision(taskData, pres == 0 ? 0: status);
- 
-         result = ALLOC(2);
-         DEREFHANDLE(result)->Set(0, DEREFWORDHANDLE(pidHandle));
diff --git a/debian/patches/x32.diff b/debian/patches/x32.diff
deleted file mode 100644
index c36cf18..0000000
--- a/debian/patches/x32.diff
+++ /dev/null
@@ -1,82 +0,0 @@
-Description: Add support for x32 ABI
-Author: James Clarke <jrtc27 at jrtc27.com>
-Forwarded: https://github.com/polyml/polyml/pull/36
-Applied-Upstream: https://github.com/polyml/polyml/commit/a5e7ab1556e0d4923c6051cd0c84157b27bbfec4
----
-This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- a/config.h.in
-+++ b/config.h.in
-@@ -590,6 +590,9 @@
- /* Define if the host is a Sparc (32-bit) */
- #undef HOSTARCHITECTURE_SPARC
- 
-+/* Define if the host is an X86 (32-bit ABI, 64-bit processor) */
-+#undef HOSTARCHITECTURE_X32
-+
- /* Define if the host is an X86 (32-bit) */
- #undef HOSTARCHITECTURE_X86
- 
---- a/configure.ac
-+++ b/configure.ac
-@@ -420,8 +420,13 @@
-             polyarch=i386
-             ;;
-       x86_64* | amd64*)
--            AC_DEFINE([HOSTARCHITECTURE_X86_64], [1], [Define if the host is an X86 (64-bit)])
--            polyarch=x86_64
-+            if test X"$ac_cv_sizeof_voidp" = X8; then
-+                AC_DEFINE([HOSTARCHITECTURE_X86_64], [1], [Define if the host is an X86 (64-bit)])
-+                polyarch=x86_64
-+            else
-+                AC_DEFINE([HOSTARCHITECTURE_X32], [1], [Define if the host is an X86 (32-bit ABI, 64-bit processor)])
-+                polyarch=interpret
-+            fi
-             ;;
-       sparc*)
-             AC_DEFINE([HOSTARCHITECTURE_SPARC], [1], [Define if the host is a Sparc (32-bit)])
---- a/libpolyml/elfexport.cpp
-+++ b/libpolyml/elfexport.cpp
-@@ -220,7 +220,8 @@
-             }
-         }
-         break;
--#if(defined(HOSTARCHITECTURE_X86) || defined(HOSTARCHITECTURE_X86_64))
-+#if(defined(HOSTARCHITECTURE_X86) || defined(HOSTARCHITECTURE_X86_64) || \
-+        defined(HOSTARCHITECTURE_X32))
- #ifdef HOSTARCHITECTURE_X86
- #define R_PC_RELATIVE R_386_PC32
- #else
-@@ -402,6 +403,10 @@
-     fhdr.e_machine = EM_X86_64;
-     directReloc = R_X86_64_64;
-     useRela = true;
-+#elif defined(HOSTARCHITECTURE_X32)
-+    fhdr.e_machine = EM_X86_64;
-+    directReloc = R_X86_64_32;
-+    useRela = true;
- #elif defined(HOSTARCHITECTURE_ARM)
- #ifndef EF_ARM_EABI_VER4 
- #define EF_ARM_EABI_VER4     0x04000000
---- a/libpolyml/quick_gc.cpp
-+++ b/libpolyml/quick_gc.cpp
-@@ -137,7 +137,7 @@
-     POLYUNSIGNED result = InterlockedCompareExchange(address, update, testVal);
-     return result == testVal;
- # endif
--#elif(defined(HOSTARCHITECTURE_X86) && defined(__GNUC__))
-+#elif((defined(HOSTARCHITECTURE_X86) || defined(HOSTARCHITECTURE_X32)) && defined(__GNUC__))
-     POLYUNSIGNED result;
-     __asm__ __volatile__ (
-         "lock; cmpxchgl %1,%2"
---- a/libpolyml/realconv.cpp
-+++ b/libpolyml/realconv.cpp
-@@ -220,7 +220,8 @@
- 
- #if !defined(IEEE_8087) && ! defined(IEEE_MC68k)
- #if defined(_WIN32) || defined(HOSTARCHITECTURE_X86) || defined (__i386__) || defined (_M_IX86) || \
--        defined (vax) || defined (__alpha) || defined(HOSTARCHITECTURE_X86_64)
-+        defined (vax) || defined (__alpha) || defined(HOSTARCHITECTURE_X86_64) || \
-+        defined(HOSTARCHITECTURE_X32)
- #define IEEE_8087
- #else
- #define IEEE_MC68k

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/polyml.git



More information about the debian-science-commits mailing list