diff options
author | Mike Pall <mike> | 2014-02-26 15:56:07 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2014-02-26 15:56:07 +0100 |
commit | 6a47e123a4339e33a7942525a19348cd2068b057 (patch) | |
tree | bd361431f9a2f6ba821ff6cfb3a1d20034fc6063 | |
parent | 998651fcdafc8b6f3d922e1e60864fec83409118 (diff) | |
download | luajit-6a47e123a4339e33a7942525a19348cd2068b057.tar.gz luajit-6a47e123a4339e33a7942525a19348cd2068b057.tar.bz2 luajit-6a47e123a4339e33a7942525a19348cd2068b057.zip |
Add PS4 port.
Thanks to Eddie Edwards.
-rw-r--r-- | doc/install.html | 20 | ||||
-rw-r--r-- | doc/luajit.html | 2 | ||||
-rw-r--r-- | src/lib_io.c | 2 | ||||
-rw-r--r-- | src/lib_os.c | 2 | ||||
-rw-r--r-- | src/lj_alloc.c | 8 | ||||
-rw-r--r-- | src/lj_arch.h | 11 | ||||
-rw-r--r-- | src/ps4build.bat | 103 |
7 files changed, 138 insertions, 10 deletions
diff --git a/doc/install.html b/doc/install.html index 15193b81..baf14690 100644 --- a/doc/install.html +++ b/doc/install.html | |||
@@ -120,7 +120,7 @@ operating systems, CPUs and compilers: | |||
120 | <tr class="even"> | 120 | <tr class="even"> |
121 | <td class="compatcpu">x64 (64 bit)</td> | 121 | <td class="compatcpu">x64 (64 bit)</td> |
122 | <td class="compatos">GCC 4.x</td> | 122 | <td class="compatos">GCC 4.x</td> |
123 | <td class="compatos compatno"> </td> | 123 | <td class="compatos">ORBIS (<a href="#ps4">PS4</a>)</td> |
124 | <td class="compatos">GCC 4.x</td> | 124 | <td class="compatos">GCC 4.x</td> |
125 | <td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0</td> | 125 | <td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0</td> |
126 | </tr> | 126 | </tr> |
@@ -460,7 +460,7 @@ make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \ | |||
460 | </pre> | 460 | </pre> |
461 | <p> | 461 | <p> |
462 | You can cross-compile for <b id="ps3">PS3</b> using the PS3 SDK from | 462 | You can cross-compile for <b id="ps3">PS3</b> using the PS3 SDK from |
463 | a Linux host or a Windows host (requires 32 bit MinGW (GCC) on the host, | 463 | a Linux host or a Windows host (requires 32 bit MinGW (GCC) on the host, |
464 | too). Due to restrictions on consoles, the JIT compiler is disabled and | 464 | too). Due to restrictions on consoles, the JIT compiler is disabled and |
465 | only the fast interpreter is built: | 465 | only the fast interpreter is built: |
466 | </p> | 466 | </p> |
@@ -468,6 +468,22 @@ only the fast interpreter is built: | |||
468 | make HOST_CC="gcc -m32" CROSS=ppu-lv2- | 468 | make HOST_CC="gcc -m32" CROSS=ppu-lv2- |
469 | </pre> | 469 | </pre> |
470 | <p> | 470 | <p> |
471 | You can cross-compile for <b id="ps4">PS4</b> from a Windows host using | ||
472 | the PS4 SDK (ORBIS) plus 64 bit MSVC. Due to restrictions on | ||
473 | consoles, the JIT compiler is disabled and only the fast interpreter | ||
474 | is built. | ||
475 | </p> | ||
476 | <p> | ||
477 | Open a "Visual Studio .NET Command Prompt" (64 bit host compiler), | ||
478 | <tt>cd</tt> to the directory where you've unpacked the sources and run | ||
479 | the following commands. This builds a static library <tt>libluajit.a</tt>, | ||
480 | which can be linked against your game, just like the Lua library. | ||
481 | </p> | ||
482 | <pre class="code"> | ||
483 | cd src | ||
484 | ps4build | ||
485 | </pre> | ||
486 | <p> | ||
471 | You can cross-compile for <b id="xbox360">Xbox 360</b> using the | 487 | You can cross-compile for <b id="xbox360">Xbox 360</b> using the |
472 | Xbox 360 SDK (MSVC + XEDK). Due to restrictions on consoles, the | 488 | Xbox 360 SDK (MSVC + XEDK). Due to restrictions on consoles, the |
473 | JIT compiler is disabled and only the fast interpreter is built. | 489 | JIT compiler is disabled and only the fast interpreter is built. |
diff --git a/doc/luajit.html b/doc/luajit.html index 07ef9b97..43af69c9 100644 --- a/doc/luajit.html +++ b/doc/luajit.html | |||
@@ -158,7 +158,7 @@ LuaJIT is Copyright © 2005-2014 Mike Pall, released under the | |||
158 | <tr><td>Windows</td><td>Linux</td><td>BSD</td><td>OSX</td><td>POSIX</td></tr> | 158 | <tr><td>Windows</td><td>Linux</td><td>BSD</td><td>OSX</td><td>POSIX</td></tr> |
159 | </table> | 159 | </table> |
160 | <table class="feature os os2"> | 160 | <table class="feature os os2"> |
161 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td><td>PS3</td><td>Xbox 360</td></tr> | 161 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td><td>PS3</td><td>PS4</td><td>Xbox 360</td></tr> |
162 | </table> | 162 | </table> |
163 | <table class="feature compiler"> | 163 | <table class="feature compiler"> |
164 | <tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr> | 164 | <tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr> |
diff --git a/src/lib_io.c b/src/lib_io.c index 51cad52f..04f0f739 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 | 429 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 |
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 70d9c55a..f62e8c8b 100644 --- a/src/lib_os.c +++ b/src/lib_os.c | |||
@@ -70,7 +70,7 @@ LJLIB_CF(os_rename) | |||
70 | 70 | ||
71 | LJLIB_CF(os_tmpname) | 71 | LJLIB_CF(os_tmpname) |
72 | { | 72 | { |
73 | #if LJ_TARGET_PS3 | 73 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 |
74 | lj_err_caller(L, LJ_ERR_OSUNIQF); | 74 | lj_err_caller(L, LJ_ERR_OSUNIQF); |
75 | return 0; | 75 | return 0; |
76 | #else | 76 | #else |
diff --git a/src/lj_alloc.c b/src/lj_alloc.c index b381bba1..f856a7a0 100644 --- a/src/lj_alloc.c +++ b/src/lj_alloc.c | |||
@@ -188,7 +188,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size) | |||
188 | return ptr; | 188 | return ptr; |
189 | } | 189 | } |
190 | 190 | ||
191 | #elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__) | 191 | #elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__) |
192 | 192 | ||
193 | /* OSX and FreeBSD mmap() use a naive first-fit linear search. | 193 | /* OSX and FreeBSD mmap() use a naive first-fit linear search. |
194 | ** That's perfect for us. Except that -pagezero_size must be set for OSX, | 194 | ** That's perfect for us. Except that -pagezero_size must be set for OSX, |
@@ -197,12 +197,14 @@ static LJ_AINLINE void *CALL_MMAP(size_t size) | |||
197 | */ | 197 | */ |
198 | #if LJ_TARGET_OSX | 198 | #if LJ_TARGET_OSX |
199 | #define MMAP_REGION_START ((uintptr_t)0x10000) | 199 | #define MMAP_REGION_START ((uintptr_t)0x10000) |
200 | #elif LJ_TARGET_PS4 | ||
201 | #define MMAP_REGION_START ((uintptr_t)0x4000) | ||
200 | #else | 202 | #else |
201 | #define MMAP_REGION_START ((uintptr_t)0x10000000) | 203 | #define MMAP_REGION_START ((uintptr_t)0x10000000) |
202 | #endif | 204 | #endif |
203 | #define MMAP_REGION_END ((uintptr_t)0x80000000) | 205 | #define MMAP_REGION_END ((uintptr_t)0x80000000) |
204 | 206 | ||
205 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) | 207 | #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 |
206 | #include <sys/resource.h> | 208 | #include <sys/resource.h> |
207 | #endif | 209 | #endif |
208 | 210 | ||
@@ -212,7 +214,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size) | |||
212 | /* Hint for next allocation. Doesn't need to be thread-safe. */ | 214 | /* Hint for next allocation. Doesn't need to be thread-safe. */ |
213 | static uintptr_t alloc_hint = MMAP_REGION_START; | 215 | static uintptr_t alloc_hint = MMAP_REGION_START; |
214 | int retry = 0; | 216 | int retry = 0; |
215 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) | 217 | #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 |
216 | static int rlimit_modified = 0; | 218 | static int rlimit_modified = 0; |
217 | if (LJ_UNLIKELY(rlimit_modified == 0)) { | 219 | if (LJ_UNLIKELY(rlimit_modified == 0)) { |
218 | struct rlimit rlim; | 220 | struct rlimit rlim; |
diff --git a/src/lj_arch.h b/src/lj_arch.h index 8b276e8f..0196eedc 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h | |||
@@ -66,8 +66,8 @@ | |||
66 | #define LUAJIT_OS LUAJIT_OS_LINUX | 66 | #define LUAJIT_OS LUAJIT_OS_LINUX |
67 | #elif defined(__MACH__) && defined(__APPLE__) | 67 | #elif defined(__MACH__) && defined(__APPLE__) |
68 | #define LUAJIT_OS LUAJIT_OS_OSX | 68 | #define LUAJIT_OS LUAJIT_OS_OSX |
69 | #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ | 69 | #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ |
70 | defined(__NetBSD__) || defined(__OpenBSD__) | 70 | defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(__ORBIS__) |
71 | #define LUAJIT_OS LUAJIT_OS_BSD | 71 | #define LUAJIT_OS LUAJIT_OS_BSD |
72 | #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__) | 72 | #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__) |
73 | #define LUAJIT_OS LUAJIT_OS_POSIX | 73 | #define LUAJIT_OS LUAJIT_OS_POSIX |
@@ -104,6 +104,13 @@ | |||
104 | #define LJ_TARGET_CONSOLE 1 | 104 | #define LJ_TARGET_CONSOLE 1 |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | #ifdef __ORBIS__ | ||
108 | #define LJ_TARGET_PS4 1 | ||
109 | #define LJ_TARGET_CONSOLE 1 | ||
110 | #undef NULL | ||
111 | #define NULL ((void*)0) | ||
112 | #endif | ||
113 | |||
107 | #if _XBOX_VER >= 200 | 114 | #if _XBOX_VER >= 200 |
108 | #define LJ_TARGET_XBOX360 1 | 115 | #define LJ_TARGET_XBOX360 1 |
109 | #define LJ_TARGET_CONSOLE 1 | 116 | #define LJ_TARGET_CONSOLE 1 |
diff --git a/src/ps4build.bat b/src/ps4build.bat new file mode 100644 index 00000000..42fc9a64 --- /dev/null +++ b/src/ps4build.bat | |||
@@ -0,0 +1,103 @@ | |||
1 | @rem Script to build LuaJIT with the PS4 SDK. | ||
2 | @rem Donated to the public domain. | ||
3 | @rem | ||
4 | @rem Open a "Visual Studio .NET Command Prompt" (64 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_ORBIS_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 64 bit host compiler. | ||
27 | @minilua | ||
28 | @if not errorlevel 8 goto :FAIL | ||
29 | |||
30 | @set DASMFLAGS=-D P64 | ||
31 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc | ||
32 | @if errorlevel 1 goto :BAD | ||
33 | |||
34 | %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI 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_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI | ||
58 | @set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus | ||
59 | @set INCLUDE="" | ||
60 | |||
61 | orbis-as -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 | @if "%1"=="amalg" goto :AMALG | ||
74 | for %%f in (lj_*.c lib_*.c) do ( | ||
75 | %LJCOMPILE% %%f | ||
76 | @if errorlevel 1 goto :BAD | ||
77 | ) | ||
78 | |||
79 | %LJLIB% %TARGETLIB% lj_*.o lib_*.o | ||
80 | @if errorlevel 1 goto :BAD | ||
81 | @goto :NOAMALG | ||
82 | :AMALG | ||
83 | %LJCOMPILE% ljamalg.c | ||
84 | @if errorlevel 1 goto :BAD | ||
85 | %LJLIB% %TARGETLIB% ljamalg.o lj_vm.o | ||
86 | @if errorlevel 1 goto :BAD | ||
87 | :NOAMALG | ||
88 | |||
89 | @del *.o *.obj *.manifest minilua.exe buildvm.exe | ||
90 | @echo. | ||
91 | @echo === Successfully built LuaJIT for PS4 === | ||
92 | |||
93 | @goto :END | ||
94 | :BAD | ||
95 | @echo. | ||
96 | @echo ******************************************************* | ||
97 | @echo *** Build FAILED -- Please check the error messages *** | ||
98 | @echo ******************************************************* | ||
99 | @goto :END | ||
100 | :FAIL | ||
101 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" | ||
102 | @echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too. | ||
103 | :END | ||