aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-03 02:57:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-03 02:57:14 +0000
commitdfe27428f10723ceba099934ddcb0f07e9f3790b (patch)
treeb94c80436228816673beda30e099769541ffe5b4 /thread.c
parent2962b6e063e4e6e8bd4b8be5c45166972caf41c2 (diff)
downloadruby-dfe27428f10723ceba099934ddcb0f07e9f3790b.tar.gz
configure.in: split SET_THREAD_NAME
* configure.in: separate SET_CURRENT_THREAD_NAME, which can set the name of current thread only, and SET_ANOTHER_THREAD_NAME, which can set the name of other threads. * thread.c (rb_thread_setname): use SET_ANOTHER_THREAD_NAME. OS X is not possible to set another thread name. * thread_pthread.c (native_set_thread_name, thread_timer): use SET_CURRENT_THREAD_NAME. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/thread.c b/thread.c
index a14902235e..1444383aa7 100644
--- a/thread.c
+++ b/thread.c
@@ -2774,7 +2774,7 @@ rb_thread_getname(VALUE thread)
static VALUE
rb_thread_setname(VALUE thread, VALUE name)
{
-#if defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP)
+#ifdef SET_ANOTHER_THREAD_NAME
const char *s = "";
#endif
rb_thread_t *th;
@@ -2782,21 +2782,13 @@ rb_thread_setname(VALUE thread, VALUE name)
if (!NIL_P(name)) {
StringValueCStr(name);
name = rb_str_new_frozen(name);
-#if defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP)
+#ifdef SET_ANOTHER_THREAD_NAME
s = RSTRING_PTR(name);
#endif
}
th->name = name;
-#if defined(HAVE_PTHREAD_SETNAME_NP)
-# if defined(__linux__)
- pthread_setname_np(th->thread_id, s);
-# elif defined(__NetBSD__)
- pthread_setname_np(th->thread_id, s, "%s");
-# elif defined(__APPLE__)
- pthread_setname_np(s);
-# endif
-#elif defined(HAVE_PTHREAD_SET_NAME_NP) /* FreeBSD */
- pthread_set_name_np(th->thread_id, s);
+#if defined(SET_ANOTHER_THREAD_NAME)
+ SET_ANOTHER_THREAD_NAME(th->thread_id, s);
#endif
return name;
}