]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
CONSOLE: Fix PS3 build.
authorMike Pall <mike>
Sat, 9 Jun 2012 23:38:44 +0000 (01:38 +0200)
committerMike Pall <mike>
Sun, 10 Jun 2012 00:01:25 +0000 (02:01 +0200)
12 files changed:
src/Makefile
src/host/buildvm_asm.c
src/lib_io.c
src/lib_jit.c
src/lib_os.c
src/lib_package.c
src/lj_arch.h
src/lj_def.h
src/lj_err.c
src/lj_jit.h
src/lj_mcode.c
src/vm_ppc.dasc

index 86b8b4fa4ba446cca62caa09b05f5b26388de4dc..3f733c59534720c0fb9d9c2580afb57e7d30c7d5 100644 (file)
@@ -214,7 +214,7 @@ TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
 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)
@@ -249,6 +249,15 @@ endif
 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))
 
@@ -277,7 +286,7 @@ ifeq (Windows,$(HOST_SYS))
   HOST_RM= del
 endif
 
-TARGET_SYS= $(HOST_SYS)
+TARGET_SYS?= $(HOST_SYS)
 ifeq (Windows,$(TARGET_SYS))
   TARGET_STRIP+= --strip-unneeded
   TARGET_XSHLDFLAGS= -shared
@@ -310,7 +319,9 @@ else
     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
@@ -463,6 +474,9 @@ endif
 ifeq (SunOS,$(TARGET_SYS))
   BUILDMODE= static
 endif
+ifeq (PS3,$(TARGET_SYS))
+  BUILDMODE= static
+endif
 
 ifeq (static,$(BUILDMODE))
   TARGET_DYNCC= @:
index f975eadc7815abb522fabbe650c394f3b9f2f177..5fc3128788957ca799aa2c73de807774b22118c2 100644 (file)
@@ -141,6 +141,24 @@ static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc
 {
   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"
@@ -196,7 +214,7 @@ void emit_asm(BuildCtx *ctx)
   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"
@@ -210,8 +228,7 @@ void emit_asm(BuildCtx *ctx)
   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"
@@ -246,7 +263,7 @@ void emit_asm(BuildCtx *ctx)
 #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"
@@ -262,7 +279,7 @@ void emit_asm(BuildCtx *ctx)
 #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
index 90bc863bc2174d316921120f1faffc9c2e9c4fcf..ad99b9b7f30583be30e5526071806207c6346214 100644 (file)
@@ -405,7 +405,7 @@ LJLIB_CF(io_popen)
 #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
 }
 
index db6bcfa8c9e69b288b94d3fca7aa5347503d3eb7..3687ad760b7ccdc14e1be22601117ebd99d6da4a 100644 (file)
@@ -613,20 +613,13 @@ static uint32_t jit_cpudetect(lua_State *L)
 #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. */
index e968d5d5f6b67f496664bc1c193daca315a7dabe..38aada672729fdf5e37261326f7f92193467213a 100644 (file)
@@ -70,6 +70,10 @@ LJLIB_CF(os_rename)
 
 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;
@@ -86,6 +90,7 @@ LJLIB_CF(os_tmpname)
 #endif
   lua_pushstring(L, buf);
   return 1;
+#endif
 }
 
 LJLIB_CF(os_getenv)
index 57344cd407769e52e07c6d85b59fa51cb1027d63..7435f6dc9734dedca04a9b2732df1eeaf72d43ad 100644 (file)
@@ -521,6 +521,7 @@ static void setpath(lua_State *L, const char *fieldname, const char *envname,
 {
 #if LJ_TARGET_CONSOLE
   const char *path = NULL;
+  UNUSED(envname);
 #else
   const char *path = getenv(envname);
 #endif
index 476c1241a859ddedbc8a3aac881b0244d3363c65..8d6830a35d16b34d96c1daed21396680e9c8d98c 100644 (file)
 #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
index 876ce95fb783c99dfcea9fbc819439b23b3ffe5e..27b6d6b7dd6cb6280b77d415804db2bf166788be 100644 (file)
@@ -197,7 +197,16 @@ static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
 }
 #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 {
index 05813cf836ae92cd6761de0668e7b73c8a638d10..34736b3435f8ee59733e4aca986a9fac05e2b39f 100644 (file)
@@ -185,7 +185,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
 
 /* -- 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,
index 6d317a9e79cbbcc8ac2b89d0f33a7be8394b2b03..28cdd17a5a519b957142e2a0de6f9e21a6c7bfd4 100644 (file)
 #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
 
index 41f7951a28919014c5c8b92b5a8b086db596b832..34405b5aff59e57d2ffdce3cd55cdd18ccfec4be 100644 (file)
@@ -13,6 +13,8 @@
 #include "lj_mcode.h"
 #include "lj_trace.h"
 #include "lj_dispatch.h"
+#endif
+#if LJ_HASJIT || LJ_HASFFI
 #include "lj_vm.h"
 #endif
 
index 49f92d0abcc1394bc628b80d1ce7f65b51b6d944..2c4940cd53015381d1cf4346b8c37f6b78c45209 100644 (file)
@@ -4804,7 +4804,11 @@ static void emit_asm_debug(BuildCtx *ctx)
        "\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"
@@ -4812,6 +4816,7 @@ static void emit_asm_debug(BuildCtx *ctx)
        "\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"
@@ -4879,6 +4884,7 @@ static void emit_asm_debug(BuildCtx *ctx)
        "\t.byte 0xd\n\t.uleb128 0xe\n"
        "\t.align 2\n"
        ".LEFDE3:\n\n", (int)ctx->codesz - fcofs);
+#endif
 #endif
     break;
   default: