[前][次][番号順一覧][スレッド一覧]

ruby-changes:33111

From: nobu <ko1@a...>
Date: Thu, 27 Feb 2014 16:10:16 +0900 (JST)
Subject: [ruby-changes:33111] nobu:r45190 (trunk): configure.in: define SET_THREAD_NAME

nobu	2014-02-27 16:10:11 +0900 (Thu, 27 Feb 2014)

  New Revision: 45190

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45190

  Log:
    configure.in: define SET_THREAD_NAME
    
    * configure.in (SET_THREAD_NAME): define according to
      pthread_setname_np variations.

  Modified files:
    trunk/configure.in
    trunk/thread_pthread.c
Index: configure.in
===================================================================
--- configure.in	(revision 45189)
+++ configure.in	(revision 45190)
@@ -2452,6 +2452,53 @@ if test x"$enable_pthread" = xyes; then https://github.com/ruby/ruby/blob/trunk/configure.in#L2452
     else
       AC_CHECK_FUNCS(pthread_attr_init)
     fi
+    if test "$ac_cv_func_pthread_setname_np" = yes; then
+	AC_CACHE_CHECK([type of pthread_setname_np], [rb_cv_func_pthread_setname_np_type],
+	    [rb_cv_func_pthread_setname_np_type=
+	    if test "$rb_cv_func_pthread_setname_np_type" = ""; then
+		AC_TRY_COMPILE([
+		    @%:@include <pthread.h>
+		    @%:@ifdef HAVE_PTHREAD_NP_H
+		    @%:@include <pthread_np.h>
+		    @%:@endif
+		    ],
+		    [if (pthread_setname_np(pthread_self(), "")) return 1;],
+		    [rb_cv_func_pthread_setname_np_type=$rb_cv_func_pthread_setname_np_type,linux])
+	    fi
+            if test "$rb_cv_func_pthread_setname_np_type" = ""; then
+                AC_TRY_COMPILE([
+                    @%:@include <pthread.h>
+                    @%:@ifdef HAVE_PTHREAD_NP_H
+                    @%:@include <pthread_np.h>
+                    @%:@endif
+                    ],
+                    [if (pthread_setname_np(pthread_self(), "", NULL)) return 1;],
+                    [rb_cv_func_pthread_setname_np_type=$rb_cv_func_pthread_setname_np_type,bsd])
+            fi
+            if test "$rb_cv_func_pthread_setname_np_type" = ""; then
+                AC_TRY_COMPILE([
+                    @%:@include <pthread.h>
+                    @%:@ifdef HAVE_PTHREAD_NP_H
+                    @%:@include <pthread_np.h>
+                    @%:@endif
+                    ],
+                    [if (pthread_setname_np("")) return 1;],
+                    [rb_cv_func_pthread_setname_np_type=$rb_cv_func_pthread_setname_np_type,darwin])
+            fi
+	    rb_cv_func_pthread_setname_np_type=${rb_cv_func_pthread_setname_np_type@%:@,}
+	    ]
+	)
+	AS_CASE(["$rb_cv_func_pthread_setname_np_type"],
+	    [linux],
+		[AC_DEFINE_UNQUOTED(SET_THREAD_NAME(name), pthread_setname_np(pthread_self(), name))],
+	    [bsd],
+		[AC_DEFINE_UNQUOTED(SET_THREAD_NAME(name), pthread_setname_np(pthread_self(), name, NULL))],
+	    [darwin],
+		[AC_DEFINE_UNQUOTED(SET_THREAD_NAME(name), pthread_setname_np(name))],
+	    [*],
+		[AC_DEFINE_UNQUOTED(SET_THREAD_NAME(name), (void)0)],
+	)
+    fi
 fi
 if test x"$ac_cv_header_ucontext_h" = xyes; then
     if test x"$rb_with_pthread" = xyes; then
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 45189)
+++ thread_pthread.c	(revision 45190)
@@ -1422,11 +1422,9 @@ timer_thread_sleep(rb_global_vm_lock_t* https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1422
 #endif /* USE_SLEEPY_TIMER_THREAD */
 
 #if defined(__linux__) && defined(PR_SET_NAME)
+# undef SET_THREAD_NAME
 # define SET_THREAD_NAME(name) prctl(PR_SET_NAME, name)
-#elif defined(HAVE_PTHREAD_SETNAME_NP)
-/* pthread_setname_np() on Darwin does not have target thread argument */
-# define SET_THREAD_NAME(name) pthread_setname_np(name)
-#else
+#elif !defined(SET_THREAD_NAME)
 # define SET_THREAD_NAME(name) (void)0
 #endif
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]