diff --git a/src/Core.h b/src/Core.h index b9e2e9591..bf2886760 100644 --- a/src/Core.h +++ b/src/Core.h @@ -86,9 +86,9 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec; #define CC_BUILD_WIN #endif #ifdef __linux__ -#define CC_BUILD_NIX -#define CC_BUILD_POSIX +#define CC_BUILD_LINUX #define CC_BUILD_X11 +#define CC_BUILD_POSIX #endif #ifdef __APPLE__ #define CC_BUILD_OSX @@ -96,8 +96,8 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec; #endif #ifdef __sun__ #define CC_BUILD_SOLARIS -#define CC_BUILD_POSIX #define CC_BUILD_X11 +#define CC_BUILD_POSIX #endif #endif diff --git a/src/LWeb.c b/src/LWeb.c index c45845719..a2803df3b 100644 --- a/src/LWeb.c +++ b/src/LWeb.c @@ -498,19 +498,27 @@ static void FetchUpdateTask_Handle(uint8_t* data, uint32_t len) { } void FetchUpdateTask_Run(bool release, bool d3d9) { -#ifdef CC_BUILD_WIN -#ifdef _WIN64 +#if defined CC_BUILD_WIN +#if _M_IX86 const char* exe_d3d9 = "ClassiCube.64.exe"; const char* exe_ogl = "ClassiCube.64-opengl.exe"; -#else +#elif _M_X64 const char* exe_d3d9 = "ClassiCube.exe"; const char* exe_ogl = "ClassiCube.opengl.exe"; #endif -#else - /* TODO: OSX, 32 bit linux */ +#elif defined CC_BUILD_LINUX +#if __i386__ + const char* exe_d3d9 = "ClassiCube.32"; + const char* exe_ogl = "ClassiCube.32"; +#elif __x86_64__ const char* exe_d3d9 = "ClassiCube"; const char* exe_ogl = "ClassiCube"; #endif +#elif defined CC_BUILD_OSX + const char* exe_d3d9 = "ClassiCube.osx"; + const char* exe_ogl = "ClassiCube.osx"; +#endif + const static String id = String_FromConst("CC update fetch"); String url; char urlBuffer[STRING_SIZE]; String_InitArray(url, urlBuffer); diff --git a/src/Logger.c b/src/Logger.c index 93b4980bb..96dc0aa32 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -345,7 +345,7 @@ void Logger_Abort2(ReturnCode result, const char* raw_msg) { /*########################################################################################################################* *-------------------------------------------------------Info dumping------------------------------------------------------* *#########################################################################################################################*/ -#if defined CC_BUILD_NIX || defined CC_BUILD_SOLARIS +#if defined CC_BUILD_LINUX || defined CC_BUILD_SOLARIS static void Logger_DumpRegisters(void* ctx) { String str; char strBuffer[STRING_SIZE * 8]; mcontext_t r; diff --git a/src/Platform.c b/src/Platform.c index 7f88823c5..838441c38 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -85,7 +85,7 @@ const ReturnCode ReturnCode_InvalidArg = EINVAL; const ReturnCode ReturnCode_SocketInProgess = EINPROGRESS; const ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK; #endif -#ifdef CC_BUILD_NIX +#ifdef CC_BUILD_LINUX #include #include #include @@ -347,7 +347,7 @@ void DateTime_CurrentLocal(struct DateTime* time_) { #define NS_PER_SEC 1000000000ULL #endif -#ifdef CC_BUILD_NIX +#ifdef CC_BUILD_LINUX uint64_t Stopwatch_Measure(void) { struct timespec t; /* TODO: CLOCK_MONOTONIC_RAW ?? */ @@ -691,15 +691,16 @@ void Thread_Join(void* handle) { Thread_Detach(handle); } -static CRITICAL_SECTION mutexList[3]; int mutexIndex; void* Mutex_Create(void) { - if (mutexIndex == Array_Elems(mutexList)) Logger_Abort("Cannot allocate mutex"); - CRITICAL_SECTION* ptr = &mutexList[mutexIndex]; - InitializeCriticalSection(ptr); mutexIndex++; + CRITICAL_SECTION* ptr = Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex"); + InitializeCriticalSection(ptr); return ptr; } -void Mutex_Free(void* handle) { DeleteCriticalSection((CRITICAL_SECTION*)handle); } +void Mutex_Free(void* handle) { + DeleteCriticalSection((CRITICAL_SECTION*)handle); + Mem_Free(handle); +} void Mutex_Lock(void* handle) { EnterCriticalSection((CRITICAL_SECTION*)handle); } void Mutex_Unlock(void* handle) { LeaveCriticalSection((CRITICAL_SECTION*)handle); } @@ -1236,7 +1237,7 @@ static void Font_Init(void) { #ifdef CC_BUILD_WIN const static String dir = String_FromConst("C:\\Windows\\Fonts"); #endif -#ifdef CC_BUILD_NIX +#ifdef CC_BUILD_LINUX const static String dir = String_FromConst("/usr/share/fonts"); #endif #ifdef CC_BUILD_SOLARIS @@ -2058,7 +2059,7 @@ static void Platform_InitDisplay(void) { DisplayDevice_Default.BitsPerPixel = DefaultDepth(display, screen); } #endif -#ifdef CC_BUILD_NIX +#ifdef CC_BUILD_LINUX ReturnCode Platform_StartOpen(const String* args) { const static String path = String_FromConst("xdg-open"); return Platform_StartProcess(&path, args);