summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2013-05-25 10:18:12 +0200
committerMike Pall <mike>2013-05-25 10:18:12 +0200
commit5a261dd92c72d8f9d2aab0714ce9e051f0d70219 (patch)
treeee36a876cb6ef4229a426efa9083811037371507
parentd686217926b75e6f93044b190943ad098d103bfe (diff)
downloadluajit2-5a261dd92c72d8f9d2aab0714ce9e051f0d70219.tar.gz
Fix compatibility issues with Illumos.
Thanks to Theo Schlossnagle.
-rw-r--r--src/lj_alloc.c17
-rw-r--r--src/luajit.c15
-rw-r--r--src/vm_x86.dasc4
3 files changed, 23 insertions, 13 deletions
diff --git a/src/lj_alloc.c b/src/lj_alloc.c
index 82b4e5b1..8f285d17 100644
--- a/src/lj_alloc.c
+++ b/src/lj_alloc.c
@@ -188,21 +188,24 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
return ptr;
}
-#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__)
/* OSX and FreeBSD mmap() use a naive first-fit linear search.
** That's perfect for us. Except that -pagezero_size must be set for OSX,
** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs
** to be reduced to 250MB on FreeBSD.
*/
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
-#include <sys/resource.h>
-#define MMAP_REGION_START ((uintptr_t)0x10000000)
-#else
+#if LJ_TARGET_OSX
#define MMAP_REGION_START ((uintptr_t)0x10000)
+#else
+#define MMAP_REGION_START ((uintptr_t)0x10000000)
#endif
#define MMAP_REGION_END ((uintptr_t)0x80000000)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <sys/resource.h>
+#endif
+
static LJ_AINLINE void *CALL_MMAP(size_t size)
{
int olderr = errno;
@@ -227,6 +230,10 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
return p;
}
if (p != CMFAIL) munmap(p, size);
+#ifdef __sun__
+ alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */
+ if (alloc_hint + size < MMAP_REGION_END) continue;
+#endif
if (retry) break;
retry = 1;
alloc_hint = MMAP_REGION_START;
diff --git a/src/luajit.c b/src/luajit.c
index 37b0deb3..e0eacc42 100644
--- a/src/luajit.c
+++ b/src/luajit.c
@@ -499,15 +499,15 @@ static int handle_luainit(lua_State *L)
return dostring(L, init, "=" LUA_INIT);
}
-struct Smain {
+static struct Smain {
char **argv;
int argc;
int status;
-};
+} smain;
static int pmain(lua_State *L)
{
- struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
+ struct Smain *s = &smain;
char **argv = s->argv;
int script;
int flags = 0;
@@ -556,17 +556,16 @@ static int pmain(lua_State *L)
int main(int argc, char **argv)
{
int status;
- struct Smain s;
lua_State *L = lua_open(); /* create state */
if (L == NULL) {
l_message(argv[0], "cannot create state: not enough memory");
return EXIT_FAILURE;
}
- s.argc = argc;
- s.argv = argv;
- status = lua_cpcall(L, pmain, &s);
+ smain.argc = argc;
+ smain.argv = argv;
+ status = lua_cpcall(L, pmain, NULL);
report(L, status);
lua_close(L);
- return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
+ return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index b4674e2b..f25dfd30 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -6152,7 +6152,11 @@ static void emit_asm_debug(BuildCtx *ctx)
".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
#endif
#if (defined(__sun__) && defined(__svr4__))
+#if LJ_64
+ fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n");
+#else
fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n");
+#endif
#else
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
#endif