summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-10-03 12:22:08 +0200
committerGitHub <noreply@github.com>2020-10-03 12:22:08 +0200
commita8c19dfed810ccc85108c51f6a540849289eea6d (patch)
tree66ed794b99e79c98e2f6bd27c5280a522c233562
parentMerge pull request #736 from Krutonium/master (diff)
parentCdStreamPosix: fix type issues (diff)
downloadre3-a8c19dfed810ccc85108c51f6a540849289eea6d.tar
re3-a8c19dfed810ccc85108c51f6a540849289eea6d.tar.gz
re3-a8c19dfed810ccc85108c51f6a540849289eea6d.tar.bz2
re3-a8c19dfed810ccc85108c51f6a540849289eea6d.tar.lz
re3-a8c19dfed810ccc85108c51f6a540849289eea6d.tar.xz
re3-a8c19dfed810ccc85108c51f6a540849289eea6d.tar.zst
re3-a8c19dfed810ccc85108c51f6a540849289eea6d.zip
-rw-r--r--.travis.yml43
-rw-r--r--premake5.lua35
-rw-r--r--src/core/CdStreamPosix.cpp48
-rw-r--r--src/skel/glfw/glfw.cpp25
4 files changed, 118 insertions, 33 deletions
diff --git a/.travis.yml b/.travis.yml
index 51ef58eb..c124a9f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,15 +1,44 @@
language: cpp
-os: linux
dist: focal
-matrix:
+os: linux
+jobs:
include:
- env: TARGET=release_linux-amd64-librw_gl3_glfw-oal
+ os: linux
- env: TARGET=debug_linux-amd64-librw_gl3_glfw-oal
+ os: linux
+ - env: TARGET=release_macosx-amd64-librw_gl3_glfw-oal PREMAKE5=premake-5.0.0-alpha15
+ compiler: clang
+ os: osx
+ osx_image: xcode12u
+ - env: TARGET=debug_macosx-amd64-librw_gl3_glfw-oal PREMAKE5=premake-5.0.0-alpha15
+ compiler: clang
+ os: osx
+ osx_image: xcode12u
+addons:
+ apt:
+ update: true
+ packages:
+ - linux-libc-dev
+ - libopenal-dev
+ - libglew-dev
+ - libglfw3-dev
+ - libsndfile1-dev
+ - libmpg123-dev
+ - gcc-8-multilib
+ - g++-8-multilib
+ homebrew:
+ packages:
+ - libsndfile
+ - mpg123
+ - glew
+ - glfw
+ - openal-soft
script:
- - sudo apt-get update
- - sudo apt-get -y install linux-libc-dev libopenal-dev libglew-dev libglfw3-dev libsndfile1-dev libmpg123-dev gcc-8-multilib g++-8-multilib
- mkdir -p "$TRAVIS_BUILD_DIR/build"
- cd "$TRAVIS_BUILD_DIR"
- - ./premake5Linux --with-librw gmake2
- - cd build
- - CC=gcc-8 CXX=g++-8 make config=$TARGET -j4 verbose=1
+ - if [ "$TRAVIS_OS_NAME" = linux ]; then ./premake5Linux --with-librw gmake2; fi
+ - if [ "$TRAVIS_OS_NAME" = osx ]; then curl -L -o "${PREMAKE5}.zip" "https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/${PREMAKE5}-src.zip" && unzip -q "${PREMAKE5}.zip" && cd "$PREMAKE5" && make -f Bootstrap.mak osx && cd .. && "./${PREMAKE5}/bin/release/premake5" --with-librw gmake2; fi
+ - cd build
+ - if [ "$TRAVIS_OS_NAME" = linux ]; then env CC=gcc-8 CXX=g++-8 make config=$TARGET -j4 verbose=1; fi
+ - if [ "$TRAVIS_OS_NAME" = osx ]; then make config=$TARGET -j4 verbose=1; fi
diff --git a/premake5.lua b/premake5.lua
index 881035ef..49be07c3 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -85,6 +85,12 @@ workspace "re3"
"bsd-amd64-librw_gl3_glfw-oal"
}
+ filter { "system:macosx" }
+ platforms {
+ "macosx-arm64-librw_gl3_glfw-oal",
+ "macosx-amd64-librw_gl3_glfw-oal",
+ }
+
filter "configurations:Debug"
defines { "DEBUG" }
@@ -100,6 +106,9 @@ workspace "re3"
filter { "platforms:bsd*" }
system "bsd"
+
+ filter { "platforms:macosx*" }
+ system "macosx"
filter { "platforms:*x86*" }
architecture "x86"
@@ -110,6 +119,12 @@ workspace "re3"
filter { "platforms:*arm*" }
architecture "ARM"
+ filter { "platforms:macosx-arm64-*" }
+ buildoptions { "-target", "arm64-apple-macos11", "-std=gnu++14" }
+
+ filter { "platforms:macosx-amd64-*" }
+ buildoptions { "-target", "x86_64-apple-macos10.12", "-std=gnu++14" }
+
filter { "platforms:*librw_d3d9*" }
defines { "RW_D3D9" }
if(not _OPTIONS["with-librw"]) then
@@ -162,6 +177,13 @@ project "librw"
filter "platforms:bsd*"
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
+
+ filter "platforms:macosx*"
+ -- Support MacPorts and Homebrew
+ includedirs { "/opt/local/include" }
+ includedirs {"/usr/local/include" }
+ libdirs { "/opt/local/lib" }
+ libdirs { "/usr/local/lib" }
filter "platforms:*RW33*"
flags { "ExcludeFromBuild" }
@@ -276,6 +298,11 @@ project "re3"
filter "platforms:bsd*oal"
links { "openal", "mpg123", "sndfile", "pthread" }
+
+ filter "platforms:macosx*oal"
+ links { "openal", "mpg123", "sndfile", "pthread" }
+ includedirs { "/usr/local/opt/openal-soft/include" }
+ libdirs { "/usr/local/opt/openal-soft/lib" }
if _OPTIONS["with-opus"] then
filter {}
@@ -329,3 +356,11 @@ project "re3"
links { "GL", "GLEW", "glfw", "sysinfo" }
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }
+
+ filter "platforms:macosx*gl3_glfw*"
+ links { "GLEW", "glfw" }
+ linkoptions { "-framework OpenGL" }
+ includedirs { "/opt/local/include" }
+ includedirs { "/usr/local/include" }
+ libdirs { "/opt/local/lib" }
+ libdirs { "/usr/local/lib" }
diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp
index e114a29a..40000f03 100644
--- a/src/core/CdStreamPosix.cpp
+++ b/src/core/CdStreamPosix.cpp
@@ -36,9 +36,9 @@ struct CdReadInfo
#ifdef ONE_THREAD_PER_CHANNEL
int8 nThreadStatus; // 0: created 1:initalized 2:abort now
pthread_t pChannelThread;
- sem_t pStartSemaphore;
+ sem_t *pStartSemaphore;
#endif
- sem_t pDoneSemaphore; // used for CdStreamSync
+ sem_t *pDoneSemaphore; // used for CdStreamSync
int32 hFile;
};
@@ -51,7 +51,7 @@ char *gImgNames[MAX_CDIMAGES];
#ifndef ONE_THREAD_PER_CHANNEL
pthread_t _gCdStreamThread;
-sem_t gCdStreamSema; // released when we have new thing to read(so channel is set)
+sem_t *gCdStreamSema; // released when we have new thing to read(so channel is set)
int8 gCdStreamThreadStatus; // 0: created 1:initalized 2:abort now
Queue gChannelRequestQ;
bool _gbCdStreamOverlapped;
@@ -76,11 +76,11 @@ CdStreamInitThread(void)
gChannelRequestQ.tail = 0;
gChannelRequestQ.size = gNumChannels + 1;
ASSERT(gChannelRequestQ.items != nil );
- status = sem_init(&gCdStreamSema, 0, 0);
+ gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 1);
#endif
- if (status == -1) {
+ if (gCdStreamSema == SEM_FAILED) {
CDTRACE("failed to create stream semaphore");
ASSERT(0);
return;
@@ -91,18 +91,18 @@ CdStreamInitThread(void)
{
for ( int32 i = 0; i < gNumChannels; i++ )
{
- status = sem_init(&gpReadInfo[i].pDoneSemaphore, 0, 0);
+ gpReadInfo[i].pDoneSemaphore = sem_open("/semaphore_done", O_CREAT, 0644, 1);
- if (status == -1)
+ if (gpReadInfo[i].pDoneSemaphore == SEM_FAILED)
{
CDTRACE("failed to create sync semaphore");
ASSERT(0);
return;
}
#ifdef ONE_THREAD_PER_CHANNEL
- status = sem_init(&gpReadInfo[i].pStartSemaphore, 0, 0);
+ gpReadInfo[i].pStartSemaphore = sem_open("/semaphore_start", O_CREAT, 0644, 1);
- if (status == -1)
+ if (gpReadInfo[i].pStartSemaphore == SEM_FAILED)
{
CDTRACE("failed to create start semaphore");
ASSERT(0);
@@ -135,7 +135,7 @@ CdStreamInitThread(void)
return;
}
#else
- debug("Using seperate streaming threads for each channel\n");
+ debug("Using separate streaming threads for each channel\n");
#endif
}
@@ -163,7 +163,7 @@ CdStreamInit(int32 numChannels)
debug("Using no buffered loading for streaming\n");
}
*/
- void *pBuffer = (void *)RwMallocAlign(CDSTREAM_SECTOR_SIZE, fsInfo.f_bsize);
+ void *pBuffer = (void *)RwMallocAlign(CDSTREAM_SECTOR_SIZE, (RwUInt32)fsInfo.f_bsize);
ASSERT( pBuffer != nil );
gNumImages = 0;
@@ -205,7 +205,7 @@ GetGTA3ImgSize(void)
return 0;
}
ok:
- return statbuf.st_size;
+ return (uint32)statbuf.st_size;
}
void
@@ -214,7 +214,7 @@ CdStreamShutdown(void)
// Destroying semaphores and free(gpReadInfo) will be done at threads
#ifndef ONE_THREAD_PER_CHANNEL
gCdStreamThreadStatus = 2;
- sem_post(&gCdStreamSema);
+ sem_post(gCdStreamSema);
#endif
#ifdef ONE_THREAD_PER_CHANNEL
@@ -254,7 +254,7 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size)
#ifndef ONE_THREAD_PER_CHANNEL
AddToQueue(&gChannelRequestQ, channel);
- if ( sem_post(&gCdStreamSema) != 0 )
+ if ( sem_post(gCdStreamSema) != 0 )
printf("Signal Sema Error\n");
#else
if ( sem_post(&gpReadInfo[channel].pStartSemaphore) != 0 )
@@ -332,7 +332,7 @@ CdStreamSync(int32 channel)
{
pChannel->bLocked = true;
- sem_wait(&pChannel->pDoneSemaphore);
+ sem_wait(pChannel->pDoneSemaphore);
}
pChannel->bReading = false;
@@ -383,7 +383,7 @@ void *CdStreamThread(void *param)
#ifndef ONE_THREAD_PER_CHANNEL
while (gCdStreamThreadStatus != 2) {
- sem_wait(&gCdStreamSema);
+ sem_wait(gCdStreamSema);
int32 channel = GetFirstInQueue(&gChannelRequestQ);
#else
int channel = *((int*)param);
@@ -437,20 +437,24 @@ void *CdStreamThread(void *param)
if ( pChannel->bLocked )
{
- sem_post(&pChannel->pDoneSemaphore);
+ sem_post(pChannel->pDoneSemaphore);
}
pChannel->bReading = false;
}
#ifndef ONE_THREAD_PER_CHANNEL
for ( int32 i = 0; i < gNumChannels; i++ )
{
- sem_destroy(&gpReadInfo[i].pDoneSemaphore);
+ sem_close(gpReadInfo[i].pDoneSemaphore);
+ sem_unlink("/semaphore_done");
}
- sem_destroy(&gCdStreamSema);
- free(gChannelRequestQ.items);
+ sem_close(gCdStreamSema);
+ sem_unlink("/semaphore_cd_stream");
+ free(gChannelRequestQ.items);
#else
- sem_destroy(&gpReadInfo[channel].pStartSemaphore);
- sem_destroy(&gpReadInfo[channel].pDoneSemaphore);
+ sem_close(gpReadInfo[channel].pStartSemaphore);
+ sem_unlink("/semaphore_start");
+ sem_close(gpReadInfo[channel].pDoneSemaphore);
+ sem_unlink("/semaphore_done");
#endif
free(gpReadInfo);
pthread_exit(nil);
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index b9dbf5ac..48701921 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -81,7 +81,12 @@ DWORD _dwOperatingSystemVersion;
#include "resource.h"
#else
long _dwOperatingSystemVersion;
+#ifndef __APPLE__
#include <sys/sysinfo.h>
+#else
+#include <mach/mach_host.h>
+#include <sys/sysctl.h>
+#endif
#include <stddef.h>
#include <locale.h>
#include <signal.h>
@@ -445,15 +450,27 @@ psInitialize(void)
#endif
#endif
+#ifndef __APPLE__
struct sysinfo systemInfo;
sysinfo(&systemInfo);
-
_dwMemAvailPhys = systemInfo.freeram;
- _dwOperatingSystemVersion = OS_WINXP; // To fool other classes
-
debug("Physical memory size %u\n", systemInfo.totalram);
debug("Available physical memory %u\n", systemInfo.freeram);
-
+#else
+ uint64_t size = 0;
+ uint64_t page_size = 0;
+ size_t uint64_len = sizeof(uint64_t);
+ size_t ull_len = sizeof(unsigned long long);
+ sysctl((int[]){CTL_HW, HW_PAGESIZE}, 2, &page_size, &ull_len, NULL, 0);
+ sysctl((int[]){CTL_HW, HW_MEMSIZE}, 2, &size, &uint64_len, NULL, 0);
+ vm_statistics_data_t vm_stat;
+ mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
+ host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vm_stat, &count);
+ _dwMemAvailPhys = (uint64_t)(vm_stat.free_count * page_size);
+ debug("Physical memory size %llu\n", _dwMemAvailPhys);
+ debug("Available physical memory %llu\n", size);
+#endif
+ _dwOperatingSystemVersion = OS_WINXP; // To fool other classes
#endif
TheText.Unload();