From b59b1b9bd9ceb7e83e4de44859ad2b1a1c3103a0 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 30 Aug 2013 13:37:51 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++++- thread_pthread.c | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index be866048be..a727d9b632 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Fri Aug 30 22:37:40 2013 Nobuyoshi Nakada +Fri Aug 30 22:37:49 2013 Nobuyoshi Nakada + + * 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. diff --git a/thread_pthread.c b/thread_pthread.c index 19b3fb790f..c08ad02ffc 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -901,7 +901,12 @@ native_thread_create(rb_thread_t *th) 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) 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)); -- cgit v1.2.3