From edcad09dee6daf119f3e29b0a63837500e7b8b85 Mon Sep 17 00:00:00 2001 From: sapier Date: Sat, 5 Apr 2014 15:27:33 +0200 Subject: Add support for named threads (atm linux only) --- src/porting.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/porting.h') diff --git a/src/porting.h b/src/porting.h index c03ae40aa..5739b6876 100644 --- a/src/porting.h +++ b/src/porting.h @@ -266,6 +266,26 @@ inline u32 getTime(TimePrecision prec) return 0; } +#if (defined(linux) || defined(__linux)) + +#include + +inline void setThreadName(const char* name) { + prctl(PR_SET_NAME,name); +} +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +/* BSD doesn't seem to support thread names. If you know about a way + * to add this feature please create a pull request. + * "setproctitle" doesn't work for threadnames. + */ +#define setThreadName(a) +#elif defined(_WIN32) +// threadnames are not supported on windows +#define setThreadName(a) +#else +#warning "Unknown platform for setThreadName support, you wont have threadname support." +#define setThreadName(a) +#endif } // namespace porting -- cgit v1.2.3