1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

fix(utils): MCOL-5881 set/getThreadName use FreeBSD API (#3384)

Taken from FreeBSD ports, this uses the FreeBSD
APIs rather than the Linux specific prctl to change
and retreive the thread names.

Co-authored-by: Bernard Spil <brnrd@FreeBSD.org>
This commit is contained in:
Daniel Black
2025-02-21 03:32:59 +11:00
committed by GitHub
parent 6e539b8336
commit 88e80c1542

View File

@ -22,13 +22,21 @@ namespace utils
{
void setThreadName(const char* threadName)
{
#ifdef __FreeBSD__
pthread_set_name_np(pthread_self(), threadName);
#else
prctl(PR_SET_NAME, threadName, 0, 0, 0);
#endif
}
std::string getThreadName()
{
char buf[32];
#ifdef __FreeBSD__
pthread_get_name_np(pthread_self(), buf, sizeof(buf));
#else
prctl(PR_GET_NAME, buf, 0, 0, 0);
#endif
return std::string(buf);
}
} // namespace utils