mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
Merge branch 'master' into v2.1
This commit is contained in:
commit
26e4287e60
@ -188,21 +188,24 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
|
|||||||
return ptr;
|
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.
|
/* 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,
|
** 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
|
** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs
|
||||||
** to be reduced to 250MB on FreeBSD.
|
** to be reduced to 250MB on FreeBSD.
|
||||||
*/
|
*/
|
||||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
|
#if LJ_TARGET_OSX
|
||||||
#include <sys/resource.h>
|
|
||||||
#define MMAP_REGION_START ((uintptr_t)0x10000000)
|
|
||||||
#else
|
|
||||||
#define MMAP_REGION_START ((uintptr_t)0x10000)
|
#define MMAP_REGION_START ((uintptr_t)0x10000)
|
||||||
|
#else
|
||||||
|
#define MMAP_REGION_START ((uintptr_t)0x10000000)
|
||||||
#endif
|
#endif
|
||||||
#define MMAP_REGION_END ((uintptr_t)0x80000000)
|
#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)
|
static LJ_AINLINE void *CALL_MMAP(size_t size)
|
||||||
{
|
{
|
||||||
int olderr = errno;
|
int olderr = errno;
|
||||||
@ -227,6 +230,10 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
if (p != CMFAIL) munmap(p, size);
|
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;
|
if (retry) break;
|
||||||
retry = 1;
|
retry = 1;
|
||||||
alloc_hint = MMAP_REGION_START;
|
alloc_hint = MMAP_REGION_START;
|
||||||
|
15
src/luajit.c
15
src/luajit.c
@ -498,15 +498,15 @@ static int handle_luainit(lua_State *L)
|
|||||||
return dostring(L, init, "=" LUA_INIT);
|
return dostring(L, init, "=" LUA_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Smain {
|
static struct Smain {
|
||||||
char **argv;
|
char **argv;
|
||||||
int argc;
|
int argc;
|
||||||
int status;
|
int status;
|
||||||
};
|
} smain;
|
||||||
|
|
||||||
static int pmain(lua_State *L)
|
static int pmain(lua_State *L)
|
||||||
{
|
{
|
||||||
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
|
struct Smain *s = &smain;
|
||||||
char **argv = s->argv;
|
char **argv = s->argv;
|
||||||
int script;
|
int script;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
@ -555,17 +555,16 @@ static int pmain(lua_State *L)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct Smain s;
|
|
||||||
lua_State *L = lua_open(); /* create state */
|
lua_State *L = lua_open(); /* create state */
|
||||||
if (L == NULL) {
|
if (L == NULL) {
|
||||||
l_message(argv[0], "cannot create state: not enough memory");
|
l_message(argv[0], "cannot create state: not enough memory");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
s.argc = argc;
|
smain.argc = argc;
|
||||||
s.argv = argv;
|
smain.argv = argv;
|
||||||
status = lua_cpcall(L, pmain, &s);
|
status = lua_cpcall(L, pmain, NULL);
|
||||||
report(L, status);
|
report(L, status);
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
|
return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5659,7 +5659,11 @@ static void emit_asm_debug(BuildCtx *ctx)
|
|||||||
".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
|
".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
|
||||||
#endif
|
#endif
|
||||||
#if (defined(__sun__) && defined(__svr4__))
|
#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");
|
fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n");
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
|
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user