Revert "darwin: assume pthread_setname_np() is available"
This reverts commitbee1bf5dd7. This is necessary in order to be able to revert commit038eacfbf4("darwin: speed up uv_set_process_title()") from October. PR-URL: https://github.com/libuv/libuv/pull/2568 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
f0923d0251
commit
56f8366873
@ -23,7 +23,6 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -37,6 +36,7 @@
|
||||
#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,9 +77,13 @@ 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",
|
||||
@ -177,8 +181,6 @@ out:
|
||||
|
||||
|
||||
void uv__set_process_title(const char* title) {
|
||||
char namebuf[64 /* MAXTHREADNAMESIZE */];
|
||||
|
||||
#if !TARGET_OS_IPHONE
|
||||
if (core_foundation_handle != NULL) {
|
||||
CFTypeRef asn;
|
||||
@ -191,6 +193,9 @@ void uv__set_process_title(const char* title) {
|
||||
}
|
||||
#endif /* !TARGET_OS_IPHONE */
|
||||
|
||||
uv__strscpy(namebuf, title, sizeof(namebuf));
|
||||
pthread_setname_np(namebuf);
|
||||
if (dynamic_pthread_setname_np != NULL) {
|
||||
char namebuf[64]; /* MAXTHREADNAMESIZE */
|
||||
uv__strscpy(namebuf, title, sizeof(namebuf));
|
||||
dynamic_pthread_setname_np(namebuf);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user