diff --git a/ChangeLog b/ChangeLog index 663451d07..dc25152a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ with software expecting to validate using that dtd. Stefan Bidigaray pointed out that the heading we currently write is very out of date. + * Source/NSThread.m: On premature thread exist, log native thread ID. 2015-07-09 Richard Frith-Macdonald diff --git a/Source/NSThread.m b/Source/NSThread.m index 767611f53..00cdc799c 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -119,7 +119,7 @@ GSPrivateThreadID() #elif defined(HAVE_GETTID) return (NSUInteger)syscall(SYS_gettid); #elif defined(HAVE_PTHREAD_GETTHREADID_NP) - return pthread_getthreadid_np(); + return (NSUInteger)pthread_getthreadid_np(); #else return (NSUInteger)GSCurrentThread(); #endif @@ -412,8 +412,20 @@ static void exitedThread(void *thread) { if (thread != defaultThread) { - fprintf(stderr, "WARNING thread %p terminated without calling +exit!\n", - thread); + NSUInteger tid; + +#if defined(__MINGW__) + tid = (NSUInteger)GetCurrentThreadId(); +#elif defined(HAVE_GETTID) + tid = (NSUInteger)syscall(SYS_gettid); +#elif defined(HAVE_PTHREAD_GETTHREADID_NP) + tid = (NSUInteger)pthread_getthreadid_np(); +#else + tid = (NSUInteger)thread; +#endif + + fprintf(stderr, "WARNING thread %"PRIuPTR + " terminated without calling +exit!\n", tid); } } @@ -796,8 +808,8 @@ unregisterActiveThread(NSThread *thread) - (NSString*) description { - return [NSString stringWithFormat: @"%@{name = %@, num = %llu}", - [super description], _name, (unsigned long long)GSPrivateThreadID()]; + return [NSString stringWithFormat: @"%@{name = %@, num = %"PRIuPTR"}", + [super description], _name, GSPrivateThreadID()]; } - (id) init