From 22295b6527e780a577d2756bb68eb4673e745a6c Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 31 Oct 2022 12:17:53 +0800 Subject: [PATCH] util.cpp: do not use pthread_setname_np on unsupported macOS versions --- libi2pd/util.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libi2pd/util.cpp b/libi2pd/util.cpp index 422c97ff..b8234b39 100644 --- a/libi2pd/util.cpp +++ b/libi2pd/util.cpp @@ -22,6 +22,9 @@ #include #endif +#if defined(__APPLE__) +# include +#endif #ifdef _WIN32 #include @@ -143,8 +146,15 @@ namespace util } void SetThreadName (const char *name) { -#if defined(__APPLE__) && !defined(__POWERPC__) +#if defined(__APPLE__) +# if (!defined(MAC_OS_X_VERSION_10_6) || \ + (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || \ + defined(__POWERPC__)) + /* pthread_setname_np is not there on <10.6 and all PPC. + So do nothing. */ +# else pthread_setname_np((char*)name); +# endif #elif defined(__FreeBSD__) || defined(__OpenBSD__) pthread_set_name_np(pthread_self(), name); #elif defined(__NetBSD__)