TARGET_XLDFLAGS=
TARGET_XLIBS= -lm
TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
-TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_ARCH) $(TARGET_FLAGS) $(TARGET_CFLAGS)
+TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
endif
endif
+ifneq (,$(findstring __CELLOS_LV2__ ,$(TARGET_TESTARCH)))
+ TARGET_SYS= PS3
+ TARGET_ARCH+= -D__CELLOS_LV2__
+ TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
+endif
+ifneq (,$(findstring LJ_NO_UNWIND ,$(TARGET_TESTARCH)))
+ TARGET_ARCH+= -DLUAJIT_NO_UNWIND
+endif
+
TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
HOST_RM= del
endif
-TARGET_SYS= $(HOST_SYS)
+TARGET_SYS?= $(HOST_SYS)
ifeq (Windows,$(TARGET_SYS))
TARGET_STRIP+= --strip-unneeded
TARGET_XSHLDFLAGS= -shared
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifneq (SunOS,$(TARGET_SYS))
- TARGET_XLDFLAGS+= -Wl,-E
+ ifneq (PS3,$(TARGET_SYS))
+ TARGET_XLDFLAGS+= -Wl,-E
+ endif
endif
ifeq (Linux,$(TARGET_SYS))
TARGET_XLIBS+= -ldl
ifeq (SunOS,$(TARGET_SYS))
BUILDMODE= static
endif
+ifeq (PS3,$(TARGET_SYS))
+ BUILDMODE= static
+endif
ifeq (static,$(BUILDMODE))
TARGET_DYNCC= @:
{
switch (ctx->mode) {
case BUILD_elfasm:
+#if LJ_TARGET_PS3
+ if (!strncmp(name, "lj_vm_", 6)) {
+ fprintf(ctx->fp,
+ "\n\t.globl %s\n"
+ "\n\t.section \".opd\",\"aw\"\n"
+ "%s:\n"
+ "\t.long .%s,.TOC.@tocbase32\n"
+ "\t.size %s,8\n"
+ "\t.previous\n"
+ "\t.globl .%s\n"
+ "\t.hidden .%s\n"
+ "\t.type .%s, " ELFASM_PX "function\n"
+ "\t.size .%s, %d\n"
+ ".%s:\n",
+ name, name, name, name, name, name, name, name, size, name);
+ break;
+ }
+#endif
fprintf(ctx->fp,
"\n\t.globl %s\n"
"\t.hidden %s\n"
if (ctx->mode != BUILD_machasm)
fprintf(ctx->fp, ".Lbegin:\n");
-#if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND)
+#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
/* This should really be moved into buildvm_arm.dasc. */
fprintf(ctx->fp,
".fnstart\n"
for (i = rel = 0; i < ctx->nsym; i++) {
int32_t ofs = ctx->sym[i].ofs;
int32_t next = ctx->sym[i+1].ofs;
-#if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND) && \
- LJ_HASFFI
+#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI
if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call"))
fprintf(ctx->fp,
".globl lj_err_unwind_arm\n"
#endif
}
-#if LJ_TARGET_ARM && defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND)
+#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
fprintf(ctx->fp,
#if !LJ_HASFFI
".globl lj_err_unwind_arm\n"
#if LJ_TARGET_PPCSPE
/* Soft-float ABI + SPE. */
fprintf(ctx->fp, "\t.gnu_attribute 4, 2\n\t.gnu_attribute 8, 3\n");
-#elif LJ_TARGET_PPC
+#elif LJ_TARGET_PPC && !LJ_TARGET_PS3
/* Hard-float ABI. */
fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n");
#endif
#endif
return iof->fp != NULL ? 1 : io_pushresult(L, 0, fname);
#else
- luaL_error(L, LUA_QL("popen") " not supported");
+ return luaL_error(L, LUA_QL("popen") " not supported");
#endif
}
#endif
#endif
#elif LJ_TARGET_PPC
-#if LJ_ARCH_PPC64
- flags |= JIT_F_PPC64;
-#endif
+#if LJ_HASJIT
#if LJ_ARCH_SQRT
flags |= JIT_F_SQRT;
#endif
#if LJ_ARCH_ROUND
flags |= JIT_F_ROUND;
#endif
-#if LJ_ARCH_CELL
- flags |= JIT_F_CELL;
-#endif
-#if LJ_ARCH_XENON
- flags |= JIT_F_XENON;
#endif
#elif LJ_TARGET_PPCSPE
/* Nothing to do. */
LJLIB_CF(os_tmpname)
{
+#if LJ_TARGET_PS3
+ lj_err_caller(L, LJ_ERR_OSUNIQF);
+ return 0;
+#else
#if LJ_TARGET_POSIX
char buf[15+1];
int fp;
#endif
lua_pushstring(L, buf);
return 1;
+#endif
}
LJLIB_CF(os_getenv)
{
#if LJ_TARGET_CONSOLE
const char *path = NULL;
+ UNUSED(envname);
#else
const char *path = getenv(envname);
#endif
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
#error "Need at least GCC 4.2 or newer"
#endif
-#else
+#elif !LJ_TARGET_PS3
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
#error "Need at least GCC 4.3 or newer"
#endif
#define LUAJIT_NO_EXP2
#endif
-#if defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
-#define LUAJIT_NO_UNWIND
+#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
+#define LJ_NO_UNWIND 1
#endif
#endif
}
#endif
#else
-#error "missing define for lj_bswap()"
+static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
+{
+ return (x << 24) | ((x & 0xff00) << 8) | ((x >> 8) & 0xff00) | (x >> 24);
+}
+
+static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
+{
+ return (uint64_t)lj_bswap((uint32_t)(x >> 32)) |
+ ((uint64_t)lj_bswap((uint32_t)x) << 32);
+}
#endif
typedef union __attribute__((packed)) Unaligned16 {
/* -- External frame unwinding -------------------------------------------- */
-#if defined(__GNUC__) && !defined(LUAJIT_NO_UNWIND)
+#if defined(__GNUC__) && !LJ_NO_UNWIND
/*
** We have to use our own definitions instead of the mandatory (!) unwind.h,
#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
+#define JIT_F_SQRT 0x00000010
+#define JIT_F_ROUND 0x00000020
/* 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"
+#define JIT_F_CPU_FIRST JIT_F_SQRT
+#define JIT_F_CPUSTRING "\4SQRT\5ROUND"
#elif LJ_TARGET_MIPS
#define JIT_F_MIPS32R2 0x00000010
#include "lj_mcode.h"
#include "lj_trace.h"
#include "lj_dispatch.h"
+#endif
+#if LJ_HASJIT || LJ_HASFFI
#include "lj_vm.h"
#endif
"\t.long .LEFDE1-.LASFDE1\n"
".LASFDE1:\n"
"\t.long .Lframe0\n"
+#if LJ_TARGET_PS3
+ "\t.long .lj_vm_ffi_call\n"
+#else
"\t.long lj_vm_ffi_call\n"
+#endif
"\t.long %d\n"
"\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n"
"\t.byte 0x8e\n\t.uleb128 2\n"
"\t.align 2\n"
".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
#endif
+#if !LJ_NO_UNWIND
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
fprintf(ctx->fp,
".Lframe1:\n"
"\t.byte 0xd\n\t.uleb128 0xe\n"
"\t.align 2\n"
".LEFDE3:\n\n", (int)ctx->codesz - fcofs);
+#endif
#endif
break;
default: