summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2016-10-09 23:46:56 -0400
committerJune McEnroe <programble@gmail.com>2016-10-09 23:46:56 -0400
commitfdb19337f0d8ad0f61b17bfcfb81b0d9c1ea6994 (patch)
treeb5ddc9200297636a488f12e824ee082e21c73665
parentFix jrp snprintf len (diff)
downloadsrc-fdb19337f0d8ad0f61b17bfcfb81b0d9c1ea6994.tar.gz
src-fdb19337f0d8ad0f61b17bfcfb81b0d9c1ea6994.zip
Allocate two pages of stack for jrp
Diffstat (limited to '')
-rwxr-xr-x.bin/jrp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/.bin/jrp.c b/.bin/jrp.c
index cde2fcce..de137cf7 100755
--- a/.bin/jrp.c
+++ b/.bin/jrp.c
@@ -133,10 +133,10 @@ static void jitInit(void) {
 }
 
 static void stackInit(void) {
-    stack.base = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+    stack.base = mmap(0, 2 * getpagesize(), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
     if (stack.base == MAP_FAILED) err(EX_OSERR, "mmap");
     stack.limit = stack.base + getpagesize() / sizeof(qvalue);
-    stack.ptr = stack.limit - 1;
+    stack.ptr = stack.limit;
 }
 
 static void jitExec(void) {
@@ -144,6 +144,7 @@ static void jitExec(void) {
     error = mprotect(code.base, getpagesize(), PROT_READ | PROT_EXEC);
     if (error) err(EX_OSERR, "mprotect");
     stack.ptr = ((jitFn)code.base)(stack.ptr);
+    if (stack.ptr > stack.limit) stack.ptr = stack.limit;
     error = mprotect(code.base, getpagesize(), PROT_READ | PROT_WRITE);
     if (error) err(EX_OSERR, "mprotect");
 }
@@ -215,6 +216,7 @@ static char *prompt(EditLine *el __attribute((unused))) {
         }
     }
     buf[0] = '[';
+    if (bufPtr == buf) bufPtr++;
     *bufPtr++ = ']';
     *bufPtr++ = ' ';
     *bufPtr = 0;