mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
CONSOLE: Handle unimplemented features for console toolchains.
This commit is contained in:
parent
9f443e8b89
commit
37be8a5478
@ -412,7 +412,11 @@ LJLIB_CF(io_popen)
|
|||||||
LJLIB_CF(io_tmpfile)
|
LJLIB_CF(io_tmpfile)
|
||||||
{
|
{
|
||||||
IOFileUD *iof = io_file_new(L);
|
IOFileUD *iof = io_file_new(L);
|
||||||
|
#if LJ_TARGET_PS3
|
||||||
|
iof->fp = NULL; errno = ENOSYS;
|
||||||
|
#else
|
||||||
iof->fp = tmpfile();
|
iof->fp = tmpfile();
|
||||||
|
#endif
|
||||||
return iof->fp != NULL ? 1 : io_pushresult(L, 0, NULL);
|
return iof->fp != NULL ? 1 : io_pushresult(L, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,11 @@ static int os_pushresult(lua_State *L, int i, const char *filename)
|
|||||||
|
|
||||||
LJLIB_CF(os_execute)
|
LJLIB_CF(os_execute)
|
||||||
{
|
{
|
||||||
|
#if LJ_TARGET_CONSOLE
|
||||||
|
lua_pushinteger(L, -1);
|
||||||
|
#else
|
||||||
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
|
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +90,11 @@ LJLIB_CF(os_tmpname)
|
|||||||
|
|
||||||
LJLIB_CF(os_getenv)
|
LJLIB_CF(os_getenv)
|
||||||
{
|
{
|
||||||
|
#if LJ_TARGET_CONSOLE
|
||||||
|
lua_pushnil(L);
|
||||||
|
#else
|
||||||
lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */
|
lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +519,11 @@ static int lj_cf_package_seeall(lua_State *L)
|
|||||||
static void setpath(lua_State *L, const char *fieldname, const char *envname,
|
static void setpath(lua_State *L, const char *fieldname, const char *envname,
|
||||||
const char *def)
|
const char *def)
|
||||||
{
|
{
|
||||||
|
#if LJ_TARGET_CONSOLE
|
||||||
|
const char *path = NULL;
|
||||||
|
#else
|
||||||
const char *path = getenv(envname);
|
const char *path = getenv(envname);
|
||||||
|
#endif
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
lua_pushstring(L, def);
|
lua_pushstring(L, def);
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,7 +120,7 @@ typedef uintptr_t BloomFilter;
|
|||||||
#define LJ_NOINLINE __attribute__((noinline))
|
#define LJ_NOINLINE __attribute__((noinline))
|
||||||
|
|
||||||
#if defined(__ELF__) || defined(__MACH__)
|
#if defined(__ELF__) || defined(__MACH__)
|
||||||
#if !((defined(__sun__) && defined(__svr4__)) || defined(__solaris__))
|
#if !((defined(__sun__) && defined(__svr4__)) || defined(__solaris__) || defined(__CELLOS_LV2__))
|
||||||
#define LJ_NOAPI extern __attribute__((visibility("hidden")))
|
#define LJ_NOAPI extern __attribute__((visibility("hidden")))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
10
src/lj_jit.h
10
src/lj_jit.h
@ -34,6 +34,16 @@
|
|||||||
/* Names for the CPU-specific flags. Must match the order above. */
|
/* Names for the CPU-specific flags. Must match the order above. */
|
||||||
#define JIT_F_CPU_FIRST JIT_F_ARMV6
|
#define JIT_F_CPU_FIRST JIT_F_ARMV6
|
||||||
#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7"
|
#define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7"
|
||||||
|
#elif LJ_TARGET_PPC
|
||||||
|
#define JIT_F_PPC64 0x00000010
|
||||||
|
#define JIT_F_SQRT 0x00000020
|
||||||
|
#define JIT_F_ROUND 0x00000040
|
||||||
|
#define JIT_F_CELL 0x00000080
|
||||||
|
#define JIT_F_XENON 0x00000100
|
||||||
|
|
||||||
|
/* Names for the CPU-specific flags. Must match the order above. */
|
||||||
|
#define JIT_F_CPU_FIRST JIT_F_PPC64
|
||||||
|
#define JIT_F_CPUSTRING "\5PPC64\4SQRT\5ROUND\4CELL\5XENON"
|
||||||
#elif LJ_TARGET_MIPS
|
#elif LJ_TARGET_MIPS
|
||||||
#define JIT_F_MIPS32R2 0x00000010
|
#define JIT_F_MIPS32R2 0x00000010
|
||||||
|
|
||||||
|
15
src/luajit.c
15
src/luajit.c
@ -6,7 +6,6 @@
|
|||||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -34,9 +33,14 @@
|
|||||||
#define lua_stdin_is_tty() 1
|
#define lua_stdin_is_tty() 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !LJ_TARGET_CONSOLE
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static lua_State *globalL = NULL;
|
static lua_State *globalL = NULL;
|
||||||
static const char *progname = LUA_PROGNAME;
|
static const char *progname = LUA_PROGNAME;
|
||||||
|
|
||||||
|
#if !LJ_TARGET_CONSOLE
|
||||||
static void lstop(lua_State *L, lua_Debug *ar)
|
static void lstop(lua_State *L, lua_Debug *ar)
|
||||||
{
|
{
|
||||||
(void)ar; /* unused arg. */
|
(void)ar; /* unused arg. */
|
||||||
@ -53,6 +57,7 @@ static void laction(int i)
|
|||||||
terminate process (default action) */
|
terminate process (default action) */
|
||||||
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void print_usage(void)
|
static void print_usage(void)
|
||||||
{
|
{
|
||||||
@ -122,9 +127,13 @@ static int docall(lua_State *L, int narg, int clear)
|
|||||||
int base = lua_gettop(L) - narg; /* function index */
|
int base = lua_gettop(L) - narg; /* function index */
|
||||||
lua_pushcfunction(L, traceback); /* push traceback function */
|
lua_pushcfunction(L, traceback); /* push traceback function */
|
||||||
lua_insert(L, base); /* put it under chunk and args */
|
lua_insert(L, base); /* put it under chunk and args */
|
||||||
|
#if !LJ_TARGET_CONSOLE
|
||||||
signal(SIGINT, laction);
|
signal(SIGINT, laction);
|
||||||
|
#endif
|
||||||
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
||||||
|
#if !LJ_TARGET_CONSOLE
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
|
#endif
|
||||||
lua_remove(L, base); /* remove traceback function */
|
lua_remove(L, base); /* remove traceback function */
|
||||||
/* force a complete garbage collection in case of errors */
|
/* force a complete garbage collection in case of errors */
|
||||||
if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
|
if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
|
||||||
@ -484,7 +493,11 @@ static int runargs(lua_State *L, char **argv, int n)
|
|||||||
|
|
||||||
static int handle_luainit(lua_State *L)
|
static int handle_luainit(lua_State *L)
|
||||||
{
|
{
|
||||||
|
#if LJ_TARGET_CONSOLE
|
||||||
|
const char *init = NULL;
|
||||||
|
#else
|
||||||
const char *init = getenv(LUA_INIT);
|
const char *init = getenv(LUA_INIT);
|
||||||
|
#endif
|
||||||
if (init == NULL)
|
if (init == NULL)
|
||||||
return 0; /* status OK */
|
return 0; /* status OK */
|
||||||
else if (init[0] == '@')
|
else if (init[0] == '@')
|
||||||
|
Loading…
Reference in New Issue
Block a user