From d077d066fd323130ed5b46c9871d5aa76abdefca Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 16 Dec 2019 15:21:05 +0100 Subject: [PATCH] darwin: assume pthread_setname_np() is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop dlsym-ing the symbol name at run-time, that was only necessary to support macOS and iOS versions that were already near-obsolete when this feature was introduced in August 2013. This reapplies commit bee1bf5dd7 from October. PR-URL: https://github.com/libuv/libuv/pull/2568 Reviewed-By: Michael Dawson Reviewed-By: Richard Lau Reviewed-By: Saúl Ibarra Corretgé --- src/unix/darwin-proctitle.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/unix/darwin-proctitle.c b/src/unix/darwin-proctitle.c index dabde223..97eaa053 100644 --- a/src/unix/darwin-proctitle.c +++ b/src/unix/darwin-proctitle.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -35,21 +36,13 @@ static int uv__pthread_setname_np(const char* name) { - int (*dynamic_pthread_setname_np)(const char* name); char namebuf[64]; /* MAXTHREADNAMESIZE */ int err; - /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */ - *(void **)(&dynamic_pthread_setname_np) = - dlsym(RTLD_DEFAULT, "pthread_setname_np"); - - if (dynamic_pthread_setname_np == NULL) - return UV_ENOSYS; - strncpy(namebuf, name, sizeof(namebuf) - 1); namebuf[sizeof(namebuf) - 1] = '\0'; - err = dynamic_pthread_setname_np(namebuf); + err = pthread_setname_np(namebuf); if (err) return UV__ERR(err);