O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
thread.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
14/* ************************************************************************** */
15
16#define _GNU_SOURCE // pthread_*_np
17
18#include "o2s/thread.h"
19
20#include <pthread.h> // pthread_*
21
22#include <string.h> // strncpy
23
25thread_local char o2s_thread_name[8] = {};
26
32void o2s_thread_set_name(const char* name)
33{
34 strncpy(o2s_thread_name, name, sizeof(o2s_thread_name));
35 pthread_setname_np(pthread_self(), name);
36}
Dynamic string implementation.
thread_local char o2s_thread_name[8]
Thread name, used when logging.
Definition thread.c:25
void o2s_thread_set_name(const char *name)
Sets both the O2S thread name and the POSIX thread name (/proc/self/task/tid/comm).
Definition thread.c:32
Thread-specific global and its setter.