aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-10-27 08:32:58 -0700
committerChris Robinson <[email protected]>2013-10-27 08:32:58 -0700
commitbf465eb2ebf38cc104685c475d8fb682e9db22a0 (patch)
tree09bc123ffde4225156cb8945afb30bafaa65cda9 /Alc
parent8ceb800defbf13354866cd7c6a4b676cf54aad5d (diff)
Move SetThreadName to threads.c
Diffstat (limited to 'Alc')
-rw-r--r--Alc/helpers.c38
-rw-r--r--Alc/threads.c44
2 files changed, 44 insertions, 38 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 43f03462..1eadc99c 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -269,44 +269,6 @@ void RestoreFPUMode(const FPUCtl *ctl)
}
-void SetThreadName(const char *name)
-{
-#if defined(HAVE_PTHREAD_SETNAME_NP)
-#if defined(__GNUC__)
- if(pthread_setname_np(pthread_self(), name) != 0)
-#elif defined(__APPLE__)
- if(pthread_setname_np(name) != 0)
-#endif
- ERR("Failed to set thread name to \"%s\": %s\n", name, strerror(errno));
-#elif defined(HAVE_PTHREAD_SET_NAME_NP)
- pthread_set_name_np(pthread_self(), name);
-#elif defined(_MSC_VER)
-#define MS_VC_EXCEPTION 0x406D1388
- struct {
- DWORD dwType; // Must be 0x1000.
- LPCSTR szName; // Pointer to name (in user addr space).
- DWORD dwThreadID; // Thread ID (-1=caller thread).
- DWORD dwFlags; // Reserved for future use, must be zero.
- } info;
- info.dwType = 0x1000;
- info.szName = name;
- info.dwThreadID = -1;
- info.dwFlags = 0;
-
- __try
- {
- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info);
- }
- __except(EXCEPTION_CONTINUE_EXECUTION)
- {
- }
-#undef MS_VC_EXCEPTION
-#else
- WARN("Can't set thread name to \"%s\"\n", name);
-#endif
-}
-
-
#ifdef _WIN32
void pthread_once(pthread_once_t *once, void (*callback)(void))
{
diff --git a/Alc/threads.c b/Alc/threads.c
index fd08b432..40586575 100644
--- a/Alc/threads.c
+++ b/Alc/threads.c
@@ -84,6 +84,33 @@ ALuint StopThread(althread_t thread)
return (ALuint)ret;
}
+
+void SetThreadName(const char *name)
+{
+#if defined(_MSC_VER)
+#define MS_VC_EXCEPTION 0x406D1388
+ struct {
+ DWORD dwType; // Must be 0x1000.
+ LPCSTR szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
+ } info;
+ info.dwType = 0x1000;
+ info.szName = name;
+ info.dwThreadID = -1;
+ info.dwFlags = 0;
+
+ __try {
+ RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info);
+ }
+ __except(EXCEPTION_CONTINUE_EXECUTION) {
+ }
+#undef MS_VC_EXCEPTION
+#else
+ TRACE("Can't set thread %04lx name to \"%s\"\n", GetCurrentThreadId(), name);
+#endif
+}
+
#else
#include <pthread.h>
@@ -149,4 +176,21 @@ ALuint StopThread(althread_t thread)
return ret;
}
+
+void SetThreadName(const char *name)
+{
+#if defined(HAVE_PTHREAD_SETNAME_NP)
+#if defined(__GNUC__)
+ if(pthread_setname_np(pthread_self(), name) != 0)
+#elif defined(__APPLE__)
+ if(pthread_setname_np(name) != 0)
+#endif
+ WARN("Failed to set thread name to \"%s\": %s\n", name, strerror(errno));
+#elif defined(HAVE_PTHREAD_SET_NAME_NP)
+ pthread_set_name_np(pthread_self(), name);
+#else
+ TRACE("Can't set thread name to \"%s\"\n", name);
+#endif
+}
+
#endif