diff options
author | sb <sb@openoffice.org> | 2011-01-28 11:58:57 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2011-01-28 11:58:57 +0100 |
commit | 6875a4b2aad35aaa07906dfd7386cc519d0fd933 (patch) | |
tree | 6872f34e5504d5a177101b4c37c2cd1872a5bc2b /sal/osl | |
parent | 138ab06ecc2c288963dac707ebc94b69ce92f39d (diff) |
sb138: #i115619# osl_setThreadName
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/os2/thread.c | 4 | ||||
-rw-r--r-- | sal/osl/unx/thread.c | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | sal/osl/w32/thread.c | 21 |
3 files changed, 41 insertions, 0 deletions
diff --git a/sal/osl/os2/thread.c b/sal/osl/os2/thread.c index 313e67c0f925..0f0c396a407c 100644 --- a/sal/osl/os2/thread.c +++ b/sal/osl/os2/thread.c @@ -549,6 +549,10 @@ void SAL_CALL osl_yieldThread() DosSleep(0); } +void osl_setThreadName(char const * name) { + (void) name; +} + typedef struct _TLS { PULONG pulPtr; diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c index fe53915b792f..18c4b033daf7 100644 --- a/sal/osl/unx/thread.c +++ b/sal/osl/unx/thread.c @@ -34,6 +34,10 @@ #include <rtl/textenc.h> #endif +#if defined LINUX +#include <sys/prctl.h> +#endif + /**************************************************************************** * @@@ TODO @@@ * @@ -566,6 +570,18 @@ void SAL_CALL osl_yieldThread() sched_yield(); } +void SAL_CALL osl_setThreadName(char const * name) { +#if defined LINUX + if (prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0) != 0) { + OSL_TRACE( + "%s prctl(PR_SET_NAME) failed with errno %d", OSL_LOG_PREFIX, + errno); + } +#else + (void) name; +#endif +} + /*****************************************************************************/ /* osl_getThreadIdentifier @@@ see TODO @@@ */ /*****************************************************************************/ diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c index 88ce87cdf175..7506c078c536 100644..100755 --- a/sal/osl/w32/thread.c +++ b/sal/osl/w32/thread.c @@ -394,6 +394,27 @@ void SAL_CALL osl_yieldThread(void) Sleep(0); } +void SAL_CALL osl_setThreadName(char const * name) { + /* 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) {} +} + typedef struct _TLS { DWORD dwIndex; |