diff options
| author | Mike Pall <mike> | 2013-05-25 10:18:12 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2013-05-25 10:18:12 +0200 |
| commit | 5a261dd92c72d8f9d2aab0714ce9e051f0d70219 (patch) | |
| tree | ee36a876cb6ef4229a426efa9083811037371507 /src | |
| parent | d686217926b75e6f93044b190943ad098d103bfe (diff) | |
| download | luajit-5a261dd92c72d8f9d2aab0714ce9e051f0d70219.tar.gz luajit-5a261dd92c72d8f9d2aab0714ce9e051f0d70219.tar.bz2 luajit-5a261dd92c72d8f9d2aab0714ce9e051f0d70219.zip | |
Fix compatibility issues with Illumos.
Thanks to Theo Schlossnagle.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_alloc.c | 17 | ||||
| -rw-r--r-- | src/luajit.c | 15 | ||||
| -rw-r--r-- | src/vm_x86.dasc | 4 |
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) | |||
| 188 | return ptr; | 188 | return ptr; |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | #elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) | 191 | #elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__) |
| 192 | 192 | ||
| 193 | /* OSX and FreeBSD mmap() use a naive first-fit linear search. | 193 | /* OSX and FreeBSD mmap() use a naive first-fit linear search. |
| 194 | ** That's perfect for us. Except that -pagezero_size must be set for OSX, | 194 | ** That's perfect for us. Except that -pagezero_size must be set for OSX, |
| 195 | ** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs | 195 | ** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs |
| 196 | ** to be reduced to 250MB on FreeBSD. | 196 | ** to be reduced to 250MB on FreeBSD. |
| 197 | */ | 197 | */ |
| 198 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) | 198 | #if LJ_TARGET_OSX |
| 199 | #include <sys/resource.h> | ||
| 200 | #define MMAP_REGION_START ((uintptr_t)0x10000000) | ||
| 201 | #else | ||
| 202 | #define MMAP_REGION_START ((uintptr_t)0x10000) | 199 | #define MMAP_REGION_START ((uintptr_t)0x10000) |
| 200 | #else | ||
| 201 | #define MMAP_REGION_START ((uintptr_t)0x10000000) | ||
| 203 | #endif | 202 | #endif |
| 204 | #define MMAP_REGION_END ((uintptr_t)0x80000000) | 203 | #define MMAP_REGION_END ((uintptr_t)0x80000000) |
| 205 | 204 | ||
| 205 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) | ||
| 206 | #include <sys/resource.h> | ||
| 207 | #endif | ||
| 208 | |||
| 206 | static LJ_AINLINE void *CALL_MMAP(size_t size) | 209 | static LJ_AINLINE void *CALL_MMAP(size_t size) |
| 207 | { | 210 | { |
| 208 | int olderr = errno; | 211 | int olderr = errno; |
| @@ -227,6 +230,10 @@ static LJ_AINLINE void *CALL_MMAP(size_t size) | |||
| 227 | return p; | 230 | return p; |
| 228 | } | 231 | } |
| 229 | if (p != CMFAIL) munmap(p, size); | 232 | if (p != CMFAIL) munmap(p, size); |
| 233 | #ifdef __sun__ | ||
| 234 | alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */ | ||
| 235 | if (alloc_hint + size < MMAP_REGION_END) continue; | ||
| 236 | #endif | ||
| 230 | if (retry) break; | 237 | if (retry) break; |
| 231 | retry = 1; | 238 | retry = 1; |
| 232 | alloc_hint = MMAP_REGION_START; | 239 | 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) | |||
| 499 | return dostring(L, init, "=" LUA_INIT); | 499 | return dostring(L, init, "=" LUA_INIT); |
| 500 | } | 500 | } |
| 501 | 501 | ||
| 502 | struct Smain { | 502 | static struct Smain { |
| 503 | char **argv; | 503 | char **argv; |
| 504 | int argc; | 504 | int argc; |
| 505 | int status; | 505 | int status; |
| 506 | }; | 506 | } smain; |
| 507 | 507 | ||
| 508 | static int pmain(lua_State *L) | 508 | static int pmain(lua_State *L) |
| 509 | { | 509 | { |
| 510 | struct Smain *s = (struct Smain *)lua_touserdata(L, 1); | 510 | struct Smain *s = &smain; |
| 511 | char **argv = s->argv; | 511 | char **argv = s->argv; |
| 512 | int script; | 512 | int script; |
| 513 | int flags = 0; | 513 | int flags = 0; |
| @@ -556,17 +556,16 @@ static int pmain(lua_State *L) | |||
| 556 | int main(int argc, char **argv) | 556 | int main(int argc, char **argv) |
| 557 | { | 557 | { |
| 558 | int status; | 558 | int status; |
| 559 | struct Smain s; | ||
| 560 | lua_State *L = lua_open(); /* create state */ | 559 | lua_State *L = lua_open(); /* create state */ |
| 561 | if (L == NULL) { | 560 | if (L == NULL) { |
| 562 | l_message(argv[0], "cannot create state: not enough memory"); | 561 | l_message(argv[0], "cannot create state: not enough memory"); |
| 563 | return EXIT_FAILURE; | 562 | return EXIT_FAILURE; |
| 564 | } | 563 | } |
| 565 | s.argc = argc; | 564 | smain.argc = argc; |
| 566 | s.argv = argv; | 565 | smain.argv = argv; |
| 567 | status = lua_cpcall(L, pmain, &s); | 566 | status = lua_cpcall(L, pmain, NULL); |
| 568 | report(L, status); | 567 | report(L, status); |
| 569 | lua_close(L); | 568 | lua_close(L); |
| 570 | return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; | 569 | return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS; |
| 571 | } | 570 | } |
| 572 | 571 | ||
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) | |||
| 6152 | ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); | 6152 | ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); |
| 6153 | #endif | 6153 | #endif |
| 6154 | #if (defined(__sun__) && defined(__svr4__)) | 6154 | #if (defined(__sun__) && defined(__svr4__)) |
| 6155 | #if LJ_64 | ||
| 6156 | fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); | ||
| 6157 | #else | ||
| 6155 | fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); | 6158 | fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); |
| 6159 | #endif | ||
| 6156 | #else | 6160 | #else |
| 6157 | fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); | 6161 | fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); |
| 6158 | #endif | 6162 | #endif |
