mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Handle pthread_setname_np on FreeBSD
For some reason, the function has a slightly different name and signature
This commit is contained in:
@@ -12,17 +12,25 @@
|
|||||||
// I cant figure out how to get pthread.h to include this definition on macOS. MACOSX_DEPLOYMENT_TARGET does not work.
|
// I cant figure out how to get pthread.h to include this definition on macOS. MACOSX_DEPLOYMENT_TARGET does not work.
|
||||||
extern int pthread_setname_np(const char *name);
|
extern int pthread_setname_np(const char *name);
|
||||||
#else
|
#else
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
void pthread_set_name_np(pthread_t tid, const char *name);
|
||||||
|
#else
|
||||||
// Need _GNU_SOURCE for pthread_setname_np on linux and that causes other issues on systems with old glibc
|
// Need _GNU_SOURCE for pthread_setname_np on linux and that causes other issues on systems with old glibc
|
||||||
extern int pthread_setname_np(pthread_t, const char *name);
|
extern int pthread_setname_np(pthread_t, const char *name);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
set_thread_name(const char *name) {
|
set_thread_name(const char *name) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
ret = pthread_setname_np(name);
|
ret = pthreadset_name_np(name);
|
||||||
|
#else
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
pthread_set_name_np(pthread_self(), name);
|
||||||
#else
|
#else
|
||||||
ret = pthread_setname_np(pthread_self(), name);
|
ret = pthread_setname_np(pthread_self(), name);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (ret != 0) perror("Failed to set thread name");
|
if (ret != 0) perror("Failed to set thread name");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user