aboutsummaryrefslogtreecommitdiff
path: root/src/threading.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/threading.c')
-rw-r--r--src/threading.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/threading.c b/src/threading.c
index 3014136..5a3e64b 100644
--- a/src/threading.c
+++ b/src/threading.c
@@ -87,11 +87,13 @@ THE SOFTWARE.
87#if defined( PLATFORM_XBOX) || defined( PLATFORM_WIN32) || defined( PLATFORM_POCKETPC) 87#if defined( PLATFORM_XBOX) || defined( PLATFORM_WIN32) || defined( PLATFORM_POCKETPC)
88static void FAIL( char const* funcname, int rc) 88static void FAIL( char const* funcname, int rc)
89{ 89{
90 fprintf( stderr, "%s() failed! (%d)\n", funcname, rc ); 90 char buf[256];
91 FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 256, NULL);
92 fprintf( stderr, "%s() failed! [GetLastError() -> %d] '%s'", funcname, rc, buf);
91#ifdef _MSC_VER 93#ifdef _MSC_VER
92 __debugbreak(); // give a chance to the debugger! 94 __debugbreak(); // give a chance to the debugger!
93#endif // _MSC_VER 95#endif // _MSC_VER
94 abort(); 96 abort();
95} 97}
96#endif // win32 build 98#endif // win32 build
97 99
@@ -296,11 +298,15 @@ void THREAD_CREATE( THREAD_T* ref, THREAD_RETURN_T (__stdcall *func)( void*), vo
296 NULL // thread id (not used) 298 NULL // thread id (not used)
297 ); 299 );
298 300
299 if( h == INVALID_HANDLE_VALUE) 301 if( h == NULL) // _beginthreadex returns 0L on failure instead of -1L (like _beginthread)
302 {
300 FAIL( "CreateThread", GetLastError()); 303 FAIL( "CreateThread", GetLastError());
304 }
301 305
302 if (!SetThreadPriority( h, gs_prio_remap[prio + 3])) 306 if (!SetThreadPriority( h, gs_prio_remap[prio + 3]))
307 {
303 FAIL( "SetThreadPriority", GetLastError()); 308 FAIL( "SetThreadPriority", GetLastError());
309 }
304 310
305 *ref = h; 311 *ref = h;
306} 312}