From bee1bf5dd7de8da316821c32411425f7cf7ab49c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 8 Oct 2019 12:47:16 +0200 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. PR-URL: https://github.com/libuv/libuv/pull/2480 Reviewed-By: Saúl Ibarra Corretgé --- src/unix/darwin-proctitle.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/unix/darwin-proctitle.c b/src/unix/darwin-proctitle.c index 8d074b349..eced23c2d 100644 --- a/src/unix/darwin-proctitle.c +++ b/src/unix/darwin-proctitle.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -36,7 +37,6 @@ #define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8) -static int (*dynamic_pthread_setname_np)(const char* name); #if !TARGET_OS_IPHONE static CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef, const char*, @@ -77,13 +77,9 @@ UV_DESTRUCTOR(static void uv__set_process_title_platform_fini(void)) { void uv__set_process_title_platform_init(void) { +#if !TARGET_OS_IPHONE OSStatus (*pSetApplicationIsDaemon)(int); - /* 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 !TARGET_OS_IPHONE application_services_handle = dlopen("/System/Library/Frameworks/" "ApplicationServices.framework/" "Versions/A/ApplicationServices", @@ -181,6 +177,8 @@ out: void uv__set_process_title(const char* title) { + char namebuf[64 /* MAXTHREADNAMESIZE */]; + #if !TARGET_OS_IPHONE if (core_foundation_handle != NULL) { CFTypeRef asn; @@ -193,9 +191,6 @@ void uv__set_process_title(const char* title) { } #endif /* !TARGET_OS_IPHONE */ - if (dynamic_pthread_setname_np != NULL) { - char namebuf[64]; /* MAXTHREADNAMESIZE */ - uv__strscpy(namebuf, title, sizeof(namebuf)); - dynamic_pthread_setname_np(namebuf); - } + uv__strscpy(namebuf, title, sizeof(namebuf)); + pthread_setname_np(namebuf); }