diff options
author | Mike Pall <mike> | 2014-04-27 00:09:45 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2014-04-27 00:09:45 +0200 |
commit | 7a39be0ac45d8cd19c13bab38d4dda31ea599760 (patch) | |
tree | 502799316175fed602af6e9d93462b02120b6f9c /src | |
parent | 2715fe3aee7c8202b4b5d04748d1c5faa6d8fd9c (diff) | |
download | luajit-7a39be0ac45d8cd19c13bab38d4dda31ea599760.tar.gz luajit-7a39be0ac45d8cd19c13bab38d4dda31ea599760.tar.bz2 luajit-7a39be0ac45d8cd19c13bab38d4dda31ea599760.zip |
Add PS Vita port.
Thanks to Anton Stenmark.
Diffstat (limited to '')
-rw-r--r-- | src/host/buildvm_asm.c | 2 | ||||
-rw-r--r-- | src/lib_io.c | 2 | ||||
-rw-r--r-- | src/lib_os.c | 11 | ||||
-rw-r--r-- | src/lj_arch.h | 5 | ||||
-rw-r--r-- | src/lj_def.h | 8 | ||||
-rw-r--r-- | src/psvitabuild.bat | 93 |
6 files changed, 115 insertions, 6 deletions
diff --git a/src/host/buildvm_asm.c b/src/host/buildvm_asm.c index 9b28b3b3..079e9a80 100644 --- a/src/host/buildvm_asm.c +++ b/src/host/buildvm_asm.c | |||
@@ -286,7 +286,7 @@ void emit_asm(BuildCtx *ctx) | |||
286 | fprintf(ctx->fp, "\n"); | 286 | fprintf(ctx->fp, "\n"); |
287 | switch (ctx->mode) { | 287 | switch (ctx->mode) { |
288 | case BUILD_elfasm: | 288 | case BUILD_elfasm: |
289 | #if !LJ_TARGET_PS3 | 289 | #if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA) |
290 | fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); | 290 | fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); |
291 | #endif | 291 | #endif |
292 | #if LJ_TARGET_PPCSPE | 292 | #if LJ_TARGET_PPCSPE |
diff --git a/src/lib_io.c b/src/lib_io.c index 04f0f739..90f310bb 100644 --- a/src/lib_io.c +++ b/src/lib_io.c | |||
@@ -426,7 +426,7 @@ LJLIB_CF(io_popen) | |||
426 | LJLIB_CF(io_tmpfile) | 426 | LJLIB_CF(io_tmpfile) |
427 | { | 427 | { |
428 | IOFileUD *iof = io_file_new(L); | 428 | IOFileUD *iof = io_file_new(L); |
429 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 | 429 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA |
430 | iof->fp = NULL; errno = ENOSYS; | 430 | iof->fp = NULL; errno = ENOSYS; |
431 | #else | 431 | #else |
432 | iof->fp = tmpfile(); | 432 | iof->fp = tmpfile(); |
diff --git a/src/lib_os.c b/src/lib_os.c index f62e8c8b..713ec935 100644 --- a/src/lib_os.c +++ b/src/lib_os.c | |||
@@ -7,7 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <locale.h> | ||
11 | #include <time.h> | 10 | #include <time.h> |
12 | 11 | ||
13 | #define lib_os_c | 12 | #define lib_os_c |
@@ -27,6 +26,10 @@ | |||
27 | #include <stdio.h> | 26 | #include <stdio.h> |
28 | #endif | 27 | #endif |
29 | 28 | ||
29 | #if !LJ_TARGET_PSVITA | ||
30 | #include <locale.h> | ||
31 | #endif | ||
32 | |||
30 | /* ------------------------------------------------------------------------ */ | 33 | /* ------------------------------------------------------------------------ */ |
31 | 34 | ||
32 | #define LJLIB_MODULE_os | 35 | #define LJLIB_MODULE_os |
@@ -70,7 +73,7 @@ LJLIB_CF(os_rename) | |||
70 | 73 | ||
71 | LJLIB_CF(os_tmpname) | 74 | LJLIB_CF(os_tmpname) |
72 | { | 75 | { |
73 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 | 76 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA |
74 | lj_err_caller(L, LJ_ERR_OSUNIQF); | 77 | lj_err_caller(L, LJ_ERR_OSUNIQF); |
75 | return 0; | 78 | return 0; |
76 | #else | 79 | #else |
@@ -254,6 +257,9 @@ LJLIB_CF(os_difftime) | |||
254 | 257 | ||
255 | LJLIB_CF(os_setlocale) | 258 | LJLIB_CF(os_setlocale) |
256 | { | 259 | { |
260 | #if LJ_TARGET_PSVITA | ||
261 | lua_pushliteral(L, "C"); | ||
262 | #else | ||
257 | GCstr *s = lj_lib_optstr(L, 1); | 263 | GCstr *s = lj_lib_optstr(L, 1); |
258 | const char *str = s ? strdata(s) : NULL; | 264 | const char *str = s ? strdata(s) : NULL; |
259 | int opt = lj_lib_checkopt(L, 2, 6, | 265 | int opt = lj_lib_checkopt(L, 2, 6, |
@@ -265,6 +271,7 @@ LJLIB_CF(os_setlocale) | |||
265 | else if (opt == 4) opt = LC_MONETARY; | 271 | else if (opt == 4) opt = LC_MONETARY; |
266 | else if (opt == 6) opt = LC_ALL; | 272 | else if (opt == 6) opt = LC_ALL; |
267 | lua_pushstring(L, setlocale(opt, str)); | 273 | lua_pushstring(L, setlocale(opt, str)); |
274 | #endif | ||
268 | return 1; | 275 | return 1; |
269 | } | 276 | } |
270 | 277 | ||
diff --git a/src/lj_arch.h b/src/lj_arch.h index 0196eedc..f04da3bf 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h | |||
@@ -111,6 +111,11 @@ | |||
111 | #define NULL ((void*)0) | 111 | #define NULL ((void*)0) |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #ifdef __psp2__ | ||
115 | #define LJ_TARGET_PSVITA 1 | ||
116 | #define LJ_TARGET_CONSOLE 1 | ||
117 | #endif | ||
118 | |||
114 | #if _XBOX_VER >= 200 | 119 | #if _XBOX_VER >= 200 |
115 | #define LJ_TARGET_XBOX360 1 | 120 | #define LJ_TARGET_XBOX360 1 |
116 | #define LJ_TARGET_CONSOLE 1 | 121 | #define LJ_TARGET_CONSOLE 1 |
diff --git a/src/lj_def.h b/src/lj_def.h index 3c43be78..8624aed2 100644 --- a/src/lj_def.h +++ b/src/lj_def.h | |||
@@ -111,7 +111,7 @@ typedef uintptr_t BloomFilter; | |||
111 | #define bloomset(b, x) ((b) |= bloombit((x))) | 111 | #define bloomset(b, x) ((b) |= bloombit((x))) |
112 | #define bloomtest(b, x) ((b) & bloombit((x))) | 112 | #define bloomtest(b, x) ((b) & bloombit((x))) |
113 | 113 | ||
114 | #if defined(__GNUC__) | 114 | #if defined(__GNUC__) || defined(__psp2__) |
115 | 115 | ||
116 | #define LJ_NORET __attribute__((noreturn)) | 116 | #define LJ_NORET __attribute__((noreturn)) |
117 | #define LJ_ALIGN(n) __attribute__((aligned(n))) | 117 | #define LJ_ALIGN(n) __attribute__((aligned(n))) |
@@ -119,7 +119,7 @@ typedef uintptr_t BloomFilter; | |||
119 | #define LJ_AINLINE inline __attribute__((always_inline)) | 119 | #define LJ_AINLINE inline __attribute__((always_inline)) |
120 | #define LJ_NOINLINE __attribute__((noinline)) | 120 | #define LJ_NOINLINE __attribute__((noinline)) |
121 | 121 | ||
122 | #if defined(__ELF__) || defined(__MACH__) | 122 | #if defined(__ELF__) || defined(__MACH__) || defined(__psp2__) |
123 | #if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) | 123 | #if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) |
124 | #define LJ_NOAPI extern __attribute__((visibility("hidden"))) | 124 | #define LJ_NOAPI extern __attribute__((visibility("hidden"))) |
125 | #endif | 125 | #endif |
@@ -150,6 +150,9 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x) | |||
150 | #if defined(__arm__) | 150 | #if defined(__arm__) |
151 | static LJ_AINLINE uint32_t lj_bswap(uint32_t x) | 151 | static LJ_AINLINE uint32_t lj_bswap(uint32_t x) |
152 | { | 152 | { |
153 | #if defined(__psp2__) | ||
154 | return __builtin_rev(x); | ||
155 | #else | ||
153 | uint32_t r; | 156 | uint32_t r; |
154 | #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ | 157 | #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ |
155 | __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ | 158 | __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ |
@@ -163,6 +166,7 @@ static LJ_AINLINE uint32_t lj_bswap(uint32_t x) | |||
163 | #endif | 166 | #endif |
164 | return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); | 167 | return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); |
165 | #endif | 168 | #endif |
169 | #endif | ||
166 | } | 170 | } |
167 | 171 | ||
168 | static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) | 172 | static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) |
diff --git a/src/psvitabuild.bat b/src/psvitabuild.bat new file mode 100644 index 00000000..3991dc65 --- /dev/null +++ b/src/psvitabuild.bat | |||
@@ -0,0 +1,93 @@ | |||
1 | @rem Script to build LuaJIT with the PS Vita SDK. | ||
2 | @rem Donated to the public domain. | ||
3 | @rem | ||
4 | @rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) | ||
5 | @rem Then cd to this directory and run this script. | ||
6 | |||
7 | @if not defined INCLUDE goto :FAIL | ||
8 | @if not defined SCE_PSP2_SDK_DIR goto :FAIL | ||
9 | |||
10 | @setlocal | ||
11 | @rem ---- Host compiler ---- | ||
12 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE | ||
13 | @set LJLINK=link /nologo | ||
14 | @set LJMT=mt /nologo | ||
15 | @set DASMDIR=..\dynasm | ||
16 | @set DASM=%DASMDIR%\dynasm.lua | ||
17 | @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c | ||
18 | |||
19 | %LJCOMPILE% host\minilua.c | ||
20 | @if errorlevel 1 goto :BAD | ||
21 | %LJLINK% /out:minilua.exe minilua.obj | ||
22 | @if errorlevel 1 goto :BAD | ||
23 | if exist minilua.exe.manifest^ | ||
24 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe | ||
25 | |||
26 | @rem Check for 32 bit host compiler. | ||
27 | @minilua | ||
28 | @if errorlevel 8 goto :FAIL | ||
29 | |||
30 | @set DASMFLAGS=-D FPU -D HFABI | ||
31 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_arm.dasc | ||
32 | @if errorlevel 1 goto :BAD | ||
33 | |||
34 | %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_ARM -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLJ_TARGET_PSVITA=1 host\buildvm*.c | ||
35 | @if errorlevel 1 goto :BAD | ||
36 | %LJLINK% /out:buildvm.exe buildvm*.obj | ||
37 | @if errorlevel 1 goto :BAD | ||
38 | if exist buildvm.exe.manifest^ | ||
39 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe | ||
40 | |||
41 | buildvm -m elfasm -o lj_vm.s | ||
42 | @if errorlevel 1 goto :BAD | ||
43 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% | ||
44 | @if errorlevel 1 goto :BAD | ||
45 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% | ||
46 | @if errorlevel 1 goto :BAD | ||
47 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% | ||
48 | @if errorlevel 1 goto :BAD | ||
49 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% | ||
50 | @if errorlevel 1 goto :BAD | ||
51 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% | ||
52 | @if errorlevel 1 goto :BAD | ||
53 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c | ||
54 | @if errorlevel 1 goto :BAD | ||
55 | |||
56 | @rem ---- Cross compiler ---- | ||
57 | @set LJCOMPILE="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2snc" -c -w -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC | ||
58 | @set LJLIB="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2ld32" -r --output= | ||
59 | @set INCLUDE="" | ||
60 | |||
61 | "%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2as" -o lj_vm.o lj_vm.s | ||
62 | |||
63 | @if "%1" neq "debug" goto :NODEBUG | ||
64 | @shift | ||
65 | @set LJCOMPILE=%LJCOMPILE% -g -O0 | ||
66 | @set TARGETLIB=libluajitD.a | ||
67 | goto :BUILD | ||
68 | :NODEBUG | ||
69 | @set LJCOMPILE=%LJCOMPILE% -O2 | ||
70 | @set TARGETLIB=libluajit.a | ||
71 | :BUILD | ||
72 | del %TARGETLIB% | ||
73 | |||
74 | %LJCOMPILE% ljamalg.c | ||
75 | @if errorlevel 1 goto :BAD | ||
76 | %LJLIB%%TARGETLIB% ljamalg.o lj_vm.o | ||
77 | @if errorlevel 1 goto :BAD | ||
78 | |||
79 | @del *.o *.obj *.manifest minilua.exe buildvm.exe | ||
80 | @echo. | ||
81 | @echo === Successfully built LuaJIT for PS Vita === | ||
82 | |||
83 | @goto :END | ||
84 | :BAD | ||
85 | @echo. | ||
86 | @echo ******************************************************* | ||
87 | @echo *** Build FAILED -- Please check the error messages *** | ||
88 | @echo ******************************************************* | ||
89 | @goto :END | ||
90 | :FAIL | ||
91 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" | ||
92 | @echo (32 bit host compiler). The PS Vita SDK must be installed, too. | ||
93 | :END | ||