diff options
Diffstat (limited to 'threads_util.c')
-rw-r--r-- | threads_util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/threads_util.c b/threads_util.c new file mode 100644 index 0000000..d2247a2 --- /dev/null +++ b/threads_util.c @@ -0,0 +1,15 @@ +#include "threads_util.h" + +#if defined(__linux__) +#include <sys/prctl.h> +#endif + +void thread_set_name(const char *name) +{ +#if defined(__linux__) + /* Use prctl instead to prevent using _GNU_SOURCE flag and implicit declaration */ + prctl(PR_SET_NAME, name); +#elif defined(__APPLE__) && defined(__MACH__) + pthread_setname_np(name); +#endif +} |