mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-06 17:20:42 +08:00
[svn-r15128] Purpose: Make Windows threadsafe debug message more useful
Description: On Linux-like systems, we can get the ID of the current thread through a pthread_self. However on Windows, the return cannot be cast as a threadID, so we simply couldn't get the ID. Previously we simply gave up and printed a message that we couldn't get an ID. Instead, though, we can use the Windows-specific call to GetCurrentThreadId(), which achieves the same goal. This way we can provide better debug output with threadsafe features. Tested: VS2005 on WinXP VS.NET on WinXP (other platforms not tested because change is within _WIN32 ifdef)
This commit is contained in:
parent
cfb75e1f7f
commit
d83709c4e6
@ -276,7 +276,9 @@ H5E_walk1_cb(int n, H5E_error1_t *err_desc, void *client_data)
|
||||
} /* end block */
|
||||
#elif defined(H5_HAVE_THREADSAFE)
|
||||
#ifdef _WIN32
|
||||
fprintf(stream, "some thread: no way to know the thread number from pthread on windows");
|
||||
/* use GetCurrentThreadId because pthread_self return cannot be cast */
|
||||
/* as an unsigned long on Windows */
|
||||
fprintf(stream, "thread %lu", (unsigned long)GetCurrentThreadId());
|
||||
#else
|
||||
fprintf(stream, "thread %lu", (unsigned long)pthread_self());
|
||||
#endif
|
||||
@ -396,7 +398,9 @@ H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)
|
||||
} /* end block */
|
||||
#elif defined(H5_HAVE_THREADSAFE)
|
||||
#ifdef _WIN32
|
||||
fprintf(stream, "some thread: no way to know the thread number from pthread on windows");
|
||||
/* use GetCurrentThreadId because pthread_self return cannot be cast */
|
||||
/* as an unsigned long on Windows */
|
||||
fprintf(stream, "thread %lu", (unsigned long)GetCurrentThreadId());
|
||||
#else
|
||||
fprintf(stream, "thread %lu", (unsigned long)pthread_self());
|
||||
#endif
|
||||
|
@ -668,7 +668,9 @@ h5_show_hostname(void)
|
||||
}
|
||||
#elif defined(H5_HAVE_THREADSAFE)
|
||||
#ifdef _WIN32
|
||||
printf("some thread: no way to know the thread number from pthread on windows.");
|
||||
/* use GetCurrentThreadId because pthread_self return cannot be cast */
|
||||
/* as an int on Windows */
|
||||
fprintf("thread %d.", (int)GetCurrentThreadId());
|
||||
#else
|
||||
printf("thread %d.", (int)pthread_self());
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user