1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-18 21:44:02 +03:00

MCOL-5881 set/getThreadName use FreeBSD API (#3383)

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-01-16 09:02:20 +11:00 committed by GitHub
parent f99c24b47d
commit 7dcc6a251a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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