Add PS4 port.
Thanks to Eddie Edwards.
This commit is contained in:
@@ -426,7 +426,7 @@ LJLIB_CF(io_popen)
|
||||
LJLIB_CF(io_tmpfile)
|
||||
{
|
||||
IOFileUD *iof = io_file_new(L);
|
||||
#if LJ_TARGET_PS3
|
||||
#if LJ_TARGET_PS3 || LJ_TARGET_PS4
|
||||
iof->fp = NULL; errno = ENOSYS;
|
||||
#else
|
||||
iof->fp = tmpfile();
|
||||
|
||||
@@ -70,7 +70,7 @@ LJLIB_CF(os_rename)
|
||||
|
||||
LJLIB_CF(os_tmpname)
|
||||
{
|
||||
#if LJ_TARGET_PS3
|
||||
#if LJ_TARGET_PS3 || LJ_TARGET_PS4
|
||||
lj_err_caller(L, LJ_ERR_OSUNIQF);
|
||||
return 0;
|
||||
#else
|
||||
|
||||
@@ -188,7 +188,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__)
|
||||
#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__)
|
||||
|
||||
/* OSX and FreeBSD mmap() use a naive first-fit linear search.
|
||||
** 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)
|
||||
*/
|
||||
#if LJ_TARGET_OSX
|
||||
#define MMAP_REGION_START ((uintptr_t)0x10000)
|
||||
#elif LJ_TARGET_PS4
|
||||
#define MMAP_REGION_START ((uintptr_t)0x4000)
|
||||
#else
|
||||
#define MMAP_REGION_START ((uintptr_t)0x10000000)
|
||||
#endif
|
||||
#define MMAP_REGION_END ((uintptr_t)0x80000000)
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
@@ -212,7 +214,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
|
||||
/* Hint for next allocation. Doesn't need to be thread-safe. */
|
||||
static uintptr_t alloc_hint = MMAP_REGION_START;
|
||||
int retry = 0;
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4
|
||||
static int rlimit_modified = 0;
|
||||
if (LJ_UNLIKELY(rlimit_modified == 0)) {
|
||||
struct rlimit rlim;
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
#define LUAJIT_OS LUAJIT_OS_LINUX
|
||||
#elif defined(__MACH__) && defined(__APPLE__)
|
||||
#define LUAJIT_OS LUAJIT_OS_OSX
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
|
||||
defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
|
||||
defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(__ORBIS__)
|
||||
#define LUAJIT_OS LUAJIT_OS_BSD
|
||||
#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)
|
||||
#define LUAJIT_OS LUAJIT_OS_POSIX
|
||||
@@ -104,6 +104,13 @@
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
#endif
|
||||
|
||||
#ifdef __ORBIS__
|
||||
#define LJ_TARGET_PS4 1
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
#undef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
#if _XBOX_VER >= 200
|
||||
#define LJ_TARGET_XBOX360 1
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
|
||||
103
src/ps4build.bat
Normal file
103
src/ps4build.bat
Normal file
@@ -0,0 +1,103 @@
|
||||
@rem Script to build LuaJIT with the PS4 SDK.
|
||||
@rem Donated to the public domain.
|
||||
@rem
|
||||
@rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler)
|
||||
@rem Then cd to this directory and run this script.
|
||||
|
||||
@if not defined INCLUDE goto :FAIL
|
||||
@if not defined SCE_ORBIS_SDK_DIR goto :FAIL
|
||||
|
||||
@setlocal
|
||||
@rem ---- Host compiler ----
|
||||
@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
|
||||
@set LJLINK=link /nologo
|
||||
@set LJMT=mt /nologo
|
||||
@set DASMDIR=..\dynasm
|
||||
@set DASM=%DASMDIR%\dynasm.lua
|
||||
@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
|
||||
|
||||
%LJCOMPILE% host\minilua.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLINK% /out:minilua.exe minilua.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
if exist minilua.exe.manifest^
|
||||
%LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
|
||||
|
||||
@rem Check for 64 bit host compiler.
|
||||
@minilua
|
||||
@if not errorlevel 8 goto :FAIL
|
||||
|
||||
@set DASMFLAGS=-D P64
|
||||
minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
|
||||
@if errorlevel 1 goto :BAD
|
||||
|
||||
%LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI host\buildvm*.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLINK% /out:buildvm.exe buildvm*.obj
|
||||
@if errorlevel 1 goto :BAD
|
||||
if exist buildvm.exe.manifest^
|
||||
%LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
|
||||
|
||||
buildvm -m elfasm -o lj_vm.s
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m libdef -o lj_libdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m recdef -o lj_recdef.h %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
|
||||
@if errorlevel 1 goto :BAD
|
||||
buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
|
||||
@rem ---- Cross compiler ----
|
||||
@set LJCOMPILE="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-clang" -c -Wall -DLUAJIT_DISABLE_FFI
|
||||
@set LJLIB="%SCE_ORBIS_SDK_DIR%\host_tools\bin\orbis-ar" rcus
|
||||
@set INCLUDE=""
|
||||
|
||||
orbis-as -o lj_vm.o lj_vm.s
|
||||
|
||||
@if "%1" neq "debug" goto :NODEBUG
|
||||
@shift
|
||||
@set LJCOMPILE=%LJCOMPILE% -g -O0
|
||||
@set TARGETLIB=libluajitD.a
|
||||
goto :BUILD
|
||||
:NODEBUG
|
||||
@set LJCOMPILE=%LJCOMPILE% -O2
|
||||
@set TARGETLIB=libluajit.a
|
||||
:BUILD
|
||||
del %TARGETLIB%
|
||||
@if "%1"=="amalg" goto :AMALG
|
||||
for %%f in (lj_*.c lib_*.c) do (
|
||||
%LJCOMPILE% %%f
|
||||
@if errorlevel 1 goto :BAD
|
||||
)
|
||||
|
||||
%LJLIB% %TARGETLIB% lj_*.o lib_*.o
|
||||
@if errorlevel 1 goto :BAD
|
||||
@goto :NOAMALG
|
||||
:AMALG
|
||||
%LJCOMPILE% ljamalg.c
|
||||
@if errorlevel 1 goto :BAD
|
||||
%LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
|
||||
@if errorlevel 1 goto :BAD
|
||||
:NOAMALG
|
||||
|
||||
@del *.o *.obj *.manifest minilua.exe buildvm.exe
|
||||
@echo.
|
||||
@echo === Successfully built LuaJIT for PS4 ===
|
||||
|
||||
@goto :END
|
||||
:BAD
|
||||
@echo.
|
||||
@echo *******************************************************
|
||||
@echo *** Build FAILED -- Please check the error messages ***
|
||||
@echo *******************************************************
|
||||
@goto :END
|
||||
:FAIL
|
||||
@echo To run this script you must open a "Visual Studio .NET Command Prompt"
|
||||
@echo (64 bit host compiler). The PS4 Orbis SDK must be installed, too.
|
||||
:END
|
||||
Reference in New Issue
Block a user