summaryrefslogtreecommitdiff
path: root/src/porting.h
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-04-05 15:27:33 +0200
committersapier <Sapier at GMX dot net>2014-04-09 21:32:21 +0200
commitedcad09dee6daf119f3e29b0a63837500e7b8b85 (patch)
tree892d763fd20e03d24430565a3883212ef5c1494f /src/porting.h
parentd22621efc10859ae68f51fdcb83da422668dfc91 (diff)
downloadminetest-edcad09dee6daf119f3e29b0a63837500e7b8b85.tar.gz
minetest-edcad09dee6daf119f3e29b0a63837500e7b8b85.tar.bz2
minetest-edcad09dee6daf119f3e29b0a63837500e7b8b85.zip
Add support for named threads (atm linux only)
Diffstat (limited to 'src/porting.h')
-rw-r--r--src/porting.h20
1 files changed, 20 insertions, 0 deletions
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 <sys/prctl.h>
+
+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