summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen Demeyer <jdemeyer@cage.ugent.be>2017-03-17 20:08:17 +0100
committerJeroen Demeyer <jdemeyer@cage.ugent.be>2017-04-04 10:51:00 +0200
commit343f241bdd3a262cbff496ca9ec6ad6dfd8fbb4a (patch)
tree17523d965dac3e72c93cd53dcacd49ad07f77731
parentUpdated SageMath version to 8.0.beta0 (diff)
mmap() PARI stack with MAP_NORESERVE (for Cygwin)u/jdemeyer/cygwin/pari-mmap
-rw-r--r--build/pkgs/pari/package-version.txt2
-rw-r--r--build/pkgs/pari/patches/prot_none_4.patch53
2 files changed, 54 insertions, 1 deletions
diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
index c457e4f..fb3a232 100644
--- a/build/pkgs/pari/package-version.txt
+++ b/build/pkgs/pari/package-version.txt
@@ -1 +1 @@
-2.9.1.p2
+2.9.1.p3
diff --git a/build/pkgs/pari/patches/prot_none_4.patch b/build/pkgs/pari/patches/prot_none_4.patch
new file mode 100644
index 00000000..36e9528
--- /dev/null
+++ b/build/pkgs/pari/patches/prot_none_4.patch
@@ -0,0 +1,53 @@
+commit c3dc1546580eda3bff6243cf563801c8a26ec67f
+Author: Jeroen Demeyer <jdemeyer@cage.ugent.be>
+Date: Mon Apr 3 16:11:54 2017 +0200
+
+ mmap the PARI stack with MAP_NORESERVE
+
+diff --git a/src/language/init.c b/src/language/init.c
+index 34cce31..acebe2f 100644
+--- a/src/language/init.c
++++ b/src/language/init.c
+@@ -597,12 +597,26 @@ pari_add_defaults_module(entree *ep)
+ #ifndef MAP_ANONYMOUS
+ #define MAP_ANONYMOUS MAP_ANON
+ #endif
++#ifndef MAP_NORESERVE
++#define MAP_NORESERVE 0
++#endif
+ static void *
+ pari_mainstack_malloc(size_t size)
+ {
++ /* Check that the system allows reserving "size" bytes. This is just
++ * a check, we immediately free the memory. */
+ void *b = mmap(NULL, size, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+- return (b == MAP_FAILED) ? NULL: b;
++ if (b == MAP_FAILED) return NULL;
++ munmap(b, size);
++
++ /* Map again, this time with MAP_NORESERVE. On some operating systems
++ * like Cygwin, this is needed because remapping with PROT_NONE and
++ * MAP_NORESERVE does not work as expected. */
++ b = mmap(NULL, size, PROT_READ|PROT_WRITE,
++ MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
++ if (b == MAP_FAILED) return NULL;
++ return b;
+ }
+
+ static void
+@@ -628,7 +642,13 @@ static void
+ pari_mainstack_mreset(pari_sp from, pari_sp to)
+ {
+ size_t s = to - from;
+- mmap((void*)from, s, PROT_NONE, MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
++ void *addr, *res;
++ if (!s) return;
++
++ addr = (void*)from;
++ res = mmap(addr, s, PROT_NONE,
++ MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
++ if (res != addr) pari_err(e_MEM);
+ }
+
+ /* Commit (make available) the virtual memory mapped between the