Skip to content

Commit b19d2a4

Browse files
authored
Merge pull request #254 from q4a/linux
Update from linux branch
2 parents 43ef63a + a8d2bea commit b19d2a4

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/Layers/xrRenderGL/glSH_Texture.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ void CTexture::Load()
174174

175175
// Check for OGM
176176
string_path fn;
177+
#ifdef LINUX
178+
while (char* sep = strchr(*cName, '\\')) *sep = '/';
179+
#endif
177180
if (FS.exist(fn, "$game_textures$", *cName, ".ogm"))
178181
{
179182
// AVI

src/xrCore/_math.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <pthread.h>
2222
#include <sys/time.h>
2323
#include <sys/resource.h>
24+
#include <sys/prctl.h>
2425
#include <chrono>
2526
#endif
2627
#include <thread>
@@ -333,19 +334,23 @@ struct THREAD_NAME
333334

334335
void thread_name(const char* name)
335336
{
337+
Msg("start new thread [%s]", name);
338+
#if defined(WINDOWS)
336339
THREAD_NAME tn;
337340
tn.dwType = 0x1000;
338341
tn.szName = name;
339342
tn.dwThreadID = DWORD(-1);
340343
tn.dwFlags = 0;
341-
#if defined(WINDOWS)
344+
342345
__try
343346
{
344347
RaiseException(0x406D1388, 0, sizeof(tn) / sizeof(DWORD), (ULONG_PTR*)&tn);
345348
}
346349
__except (EXCEPTION_CONTINUE_EXECUTION)
347350
{
348351
}
352+
#else
353+
prctl(PR_SET_NAME, name, 0, 0, 0);
349354
#endif
350355
}
351356
#pragma pack(pop)
@@ -385,7 +390,7 @@ void thread_spawn(thread_t* entry, const char* name, unsigned stack, void* argli
385390
#if defined(WINDOWS)
386391
_beginthread(thread_entry, stack, startup);
387392
#elif defined(LINUX)
388-
pthread_t handle;
393+
pthread_t handle = 0;
389394
pthread_attr_t attr;
390395
pthread_attr_init(&attr);
391396
pthread_attr_setstacksize(&attr, stack);

src/xrCore/xrDebug.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ static void unexpected_handler() { handler_base("unexpected program termination"
817817
static void abort_handler(int signal) { handler_base("application is aborting"); }
818818
static void floating_point_handler(int signal) { handler_base("floating point error"); }
819819
static void illegal_instruction_handler(int signal) { handler_base("illegal instruction"); }
820+
static void segmentation_fault_handler(int signal) { handler_base("segmentation fault"); }
820821
static void termination_handler(int signal) { handler_base("termination with exit code 3"); }
821822

822823
void xrDebug::OnThreadSpawn()
@@ -841,6 +842,13 @@ void xrDebug::OnThreadSpawn()
841842
#if 0 // should be if we use exceptions
842843
std::set_unexpected(_terminate);
843844
#endif
845+
#else //WINDOWS
846+
signal(SIGABRT, abort_handler);
847+
signal(SIGFPE, floating_point_handler);
848+
signal(SIGILL, illegal_instruction_handler);
849+
signal(SIGINT, 0);
850+
signal(SIGTERM, termination_handler);
851+
signal(SIGSEGV, segmentation_fault_handler);
844852
#endif
845853
}
846854

0 commit comments

Comments
 (0)