From 2152c230e8a1fad6a8fddc7f9ad2a973518461b4 Mon Sep 17 00:00:00 2001 From: Ilya Orlov Date: Sat, 18 Aug 2018 23:46:44 +0300 Subject: [PATCH] xrCore: add run-time replacement for linux-specific path separator --- src/Common/FSMacros.hpp | 8 ++++++++ src/Common/PlatformLinux.inl | 18 +++++++++++++++++- src/xrCore/LocatorAPI_defs.cpp | 11 +++++++++-- src/xrCore/_math.cpp | 4 +++- src/xrCore/log.cpp | 2 +- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/Common/FSMacros.hpp b/src/Common/FSMacros.hpp index f74d4a3f504..7a1eb6b0bb3 100644 --- a/src/Common/FSMacros.hpp +++ b/src/Common/FSMacros.hpp @@ -1,5 +1,13 @@ #pragma once +#if defined(LINUX) +#define _DELIMITER '/' //for looking +#define DELIMITER "/" // for insert +#elif defined(WINDOWS) +#define _DELIMITER '\\' //for looking +#define DELIMITER "\\" // for insert +#endif + // game path definition #define _game_data_ "$game_data$" #define _game_textures_ "$game_textures$" diff --git a/src/Common/PlatformLinux.inl b/src/Common/PlatformLinux.inl index 837e7abfbeb..7ab87c271a0 100644 --- a/src/Common/PlatformLinux.inl +++ b/src/Common/PlatformLinux.inl @@ -87,13 +87,29 @@ inline void Sleep(int ms) usleep(ms * 1000); } + #include inline void _splitpath ( const char* path, // Path Input char* drive, // Drive : Output char* dir, // Directory : Output char* fname, // Filename : Output char* ext // Extension : Output -){} +){ + if(drive) + strcpy(drive, ""); + + if(dir) + strcpy(dir, dirname(path)); + + if(fname) + strcpy(fname, basename(path)); +} + +#include +inline void OutputDebugString(char *str) // for linux debugger +{ + std::cerr << str; +} inline unsigned long GetLastError() { diff --git a/src/xrCore/LocatorAPI_defs.cpp b/src/xrCore/LocatorAPI_defs.cpp index bff9048fc87..24ce60de912 100644 --- a/src/xrCore/LocatorAPI_defs.cpp +++ b/src/xrCore/LocatorAPI_defs.cpp @@ -48,8 +48,15 @@ FS_Path::FS_Path(LPCSTR _Root, LPCSTR _Add, LPCSTR _DefExt, LPCSTR _FilterCaptio xr_strcpy(temp, sizeof(temp), _Root); if (_Add) xr_strcat(temp, _Add); - if (temp[0] && temp[xr_strlen(temp) - 1] != '\\') - xr_strcat(temp, "\\"); +#if defined(LINUX) + char *ptr = strchr(temp, '\\'); + while (ptr) { + *ptr = '/'; + ptr = strchr(ptr, '\\'); + } +#endif + if (temp[0] && temp[xr_strlen(temp) - 1] != _DELIMITER) + xr_strcat(temp, DELIMITER); m_Path = xr_strlwr(xr_strdup(temp)); m_DefExt = _DefExt ? xr_strlwr(xr_strdup(_DefExt)) : 0; m_FilterCaption = _FilterCaption ? xr_strlwr(xr_strdup(_FilterCaption)) : 0; diff --git a/src/xrCore/_math.cpp b/src/xrCore/_math.cpp index 7a584b697d8..e320e1952ac 100644 --- a/src/xrCore/_math.cpp +++ b/src/xrCore/_math.cpp @@ -326,14 +326,16 @@ void _initialize_cpu() string256 features; xr_strcpy(features, sizeof(features), "RDTSC"); + if (SDL_HasAltiVec()) xr_strcat(features, ", AltiVec"); if (SDL_HasMMX()) xr_strcat(features, ", MMX"); if (SDL_Has3DNow()) xr_strcat(features, ", 3DNow!"); if (SDL_HasSSE()) xr_strcat(features, ", SSE"); if (SDL_HasSSE2()) xr_strcat(features, ", SSE2"); if (SDL_HasSSE3()) xr_strcat(features, ", SSE3"); - if (SDL_HasRDTSC()) xr_strcat(features, ", RDTSC"); if (SDL_HasSSE41()) xr_strcat(features, ", SSE4.1"); if (SDL_HasSSE42()) xr_strcat(features, ", SSE4.2"); + if (SDL_HasAVX()) xr_strcat(features, ", AVX"); + if (SDL_HasAVX2()) xr_strcat(features, ", AVX2"); Msg("* CPU features: %s", features); Msg("* CPU cores/threads: %d/%d", std::thread::hardware_concurrency(), SDL_GetCPUCount()); diff --git a/src/xrCore/log.cpp b/src/xrCore/log.cpp index 444c1b2222b..8904296265c 100644 --- a/src/xrCore/log.cpp +++ b/src/xrCore/log.cpp @@ -44,7 +44,7 @@ void AddOne(const char* split) { logCS.Enter(); -#ifdef DEBUG +#if defined(DEBUG) || defined(LINUX) OutputDebugString(split); OutputDebugString("\n"); #endif