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

ruby-changes:30652

From: nobu <ko1@a...>
Date: Fri, 30 Aug 2013 22:37:57 +0900 (JST)
Subject: [ruby-changes:30652] nobu:r42731 (trunk): thread_pthread.c: define attr only if used

nobu	2013-08-30 22:37:51 +0900 (Fri, 30 Aug 2013)

  New Revision: 42731

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

  Log:
    thread_pthread.c: define attr only if used
    
    * thread_pthread.c (native_thread_create): define attr only if it is
      used, and merge pthread_create() calls.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42730)
+++ ChangeLog	(revision 42731)
@@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Fri Aug 30 22:37:40 2013  Nobuyoshi Nakada  <nobu@r...>
+Fri Aug 30 22:37:49 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (native_thread_create): define attr only if it is
+	  used, and merge pthread_create() calls.
 
 	* thread_pthread.c (get_main_stack): separate function to get stack of
 	  main thread.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 42730)
+++ thread_pthread.c	(revision 42731)
@@ -901,7 +901,12 @@ native_thread_create(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L901
 	thread_debug("create (use cached thread): %p\n", (void *)th);
     }
     else {
+#ifdef HAVE_PTHREAD_ATTR_INIT
 	pthread_attr_t attr;
+	pthread_attr_t *const attrp = &attr;
+#else
+	pthread_attr_t *const attrp = NULL;
+#endif
 	const size_t stack_size = th->vm->default_params.thread_machine_stack_size;
 	const size_t space = space_size(stack_size);
 
@@ -923,11 +928,8 @@ native_thread_create(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L928
 	CHECK_ERR(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED));
 # endif
 	CHECK_ERR(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED));
-
-	err = pthread_create(&th->thread_id, &attr, thread_start_func_1, th);
-#else
-	err = pthread_create(&th->thread_id, NULL, thread_start_func_1, th);
 #endif
+	err = pthread_create(&th->thread_id, attrp, thread_start_func_1, th);
 	thread_debug("create: %p (%d)\n", (void *)th, err);
 #ifdef HAVE_PTHREAD_ATTR_INIT
 	CHECK_ERR(pthread_attr_destroy(&attr));

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

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