summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-02 09:17:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-02 09:17:49 +0000
commitafd564ee3f7f2c42359e20d5083a214f82744812 (patch)
tree229cc06266e858e6e7b69d8cd33ac6d2917991e1
parentbc6e31eebfdec73a8a2eca14d5072d9d096799a0 (diff)
thread.c: rb_thread_setname on OS X
* thread.c (rb_thread_setname): pthread_setname_np() on OS X takes the name only and sets the current thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--thread.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 7ab3cea..a149022 100644
--- a/thread.c
+++ b/thread.c
@@ -2774,13 +2774,17 @@ 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)
const char *s = "";
+#endif
rb_thread_t *th;
GetThreadPtr(thread, th);
if (!NIL_P(name)) {
StringValueCStr(name);
name = rb_str_new_frozen(name);
+#if defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP)
s = RSTRING_PTR(name);
+#endif
}
th->name = name;
#if defined(HAVE_PTHREAD_SETNAME_NP)
@@ -2788,6 +2792,8 @@ rb_thread_setname(VALUE thread, VALUE name)
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);