summaryrefslogtreecommitdiff
path: root/sal/osl/w32/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'sal/osl/w32/thread.c')
-rwxr-xr-x[-rw-r--r--]sal/osl/w32/thread.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c
index 90ff0d2dc..64297864f 100644..100755
--- a/sal/osl/w32/thread.c
+++ b/sal/osl/w32/thread.c
@@ -394,6 +394,31 @@ void SAL_CALL osl_yieldThread(void)
Sleep(0);
}
+void SAL_CALL osl_setThreadName(char const * name) {
+#ifdef _MSC_VER
+ /* See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>: */
+#pragma pack(push, 8)
+ struct {
+ DWORD dwType;
+ LPCSTR szName;
+ DWORD dwThreadID;
+ DWORD dwFlags;
+ } info;
+#pragma pack(pop)
+ info.dwType = 0x1000;
+ info.szName = name;
+ info.dwThreadID = (DWORD) -1;
+ info.dwFlags = 0;
+ __try {
+ RaiseException(
+ 0x406D1388, 0, sizeof info / sizeof (ULONG_PTR),
+ (ULONG_PTR *) &info);
+ } __except (EXCEPTION_EXECUTE_HANDLER) {}
+#else
+ (void) name;
+#endif
+}
+
typedef struct _TLS
{
DWORD dwIndex;