CONSOLE: Handle unimplemented features for console toolchains.

master
Mike Pall 2012-06-09 20:54:34 +02:00
parent 9f443e8b89
commit 37be8a5478
6 changed files with 41 additions and 2 deletions

View File

@ -412,7 +412,11 @@ LJLIB_CF(io_popen)
LJLIB_CF(io_tmpfile)
{
IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_PS3
iof->fp = NULL; errno = ENOSYS;
#else
iof->fp = tmpfile();
#endif
return iof->fp != NULL ? 1 : io_pushresult(L, 0, NULL);
}

View File

@ -47,7 +47,11 @@ static int os_pushresult(lua_State *L, int i, const char *filename)
LJLIB_CF(os_execute)
{
#if LJ_TARGET_CONSOLE
lua_pushinteger(L, -1);
#else
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
#endif
return 1;
}
@ -86,7 +90,11 @@ LJLIB_CF(os_tmpname)
LJLIB_CF(os_getenv)
{
#if LJ_TARGET_CONSOLE
lua_pushnil(L);
#else
lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */
#endif
return 1;
}

View File

@ -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,
const char *def)
{
#if LJ_TARGET_CONSOLE
const char *path = NULL;
#else
const char *path = getenv(envname);
#endif
if (path == NULL) {
lua_pushstring(L, def);
} else {

View File

@ -120,7 +120,7 @@ typedef uintptr_t BloomFilter;
#define LJ_NOINLINE __attribute__((noinline))
#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")))
#endif
#endif

View File

@ -34,6 +34,16 @@
/* Names for the CPU-specific flags. Must match the order above. */
#define JIT_F_CPU_FIRST JIT_F_ARMV6
#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
#define JIT_F_MIPS32R2 0x00000010

View File

@ -6,7 +6,6 @@
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
*/
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -34,9 +33,14 @@
#define lua_stdin_is_tty() 1
#endif
#if !LJ_TARGET_CONSOLE
#include <signal.h>
#endif
static lua_State *globalL = NULL;
static const char *progname = LUA_PROGNAME;
#if !LJ_TARGET_CONSOLE
static void lstop(lua_State *L, lua_Debug *ar)
{
(void)ar; /* unused arg. */
@ -53,6 +57,7 @@ static void laction(int i)
terminate process (default action) */
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
}
#endif
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 */
lua_pushcfunction(L, traceback); /* push traceback function */
lua_insert(L, base); /* put it under chunk and args */
#if !LJ_TARGET_CONSOLE
signal(SIGINT, laction);
#endif
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
#if !LJ_TARGET_CONSOLE
signal(SIGINT, SIG_DFL);
#endif
lua_remove(L, base); /* remove traceback function */
/* force a complete garbage collection in case of errors */
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)
{
#if LJ_TARGET_CONSOLE
const char *init = NULL;
#else
const char *init = getenv(LUA_INIT);
#endif
if (init == NULL)
return 0; /* status OK */
else if (init[0] == '@')