From: Sebastian Huber Date: Fri, 2 Dec 2016 14:10:33 +0000 (+0000) Subject: [RTEMS] Fix libgomp for nthreads == 1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d313d52cd5fff9374f01967fb7964b6633df219c;p=gcc.git [RTEMS] Fix libgomp for nthreads == 1 libgomp/ * config/rtems/pool.h (gomp_get_thread_pool): Return proper thread pool in case nthreads == 1. From-SVN: r243179 --- diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 9e2a3001b86..f072ce49711 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2016-12-02 Sebastian Huber + + * config/rtems/pool.h (gomp_get_thread_pool): Return proper + thread pool in case nthreads == 1. + 2016-11-30 Alexander Monakov * config/nvptx/env.c: Delete. diff --git a/libgomp/config/rtems/pool.h b/libgomp/config/rtems/pool.h index 7520c071c17..e69eca45dda 100644 --- a/libgomp/config/rtems/pool.h +++ b/libgomp/config/rtems/pool.h @@ -87,28 +87,24 @@ static inline struct gomp_thread_pool * gomp_get_thread_pool (struct gomp_thread *thr, unsigned nthreads) { struct gomp_thread_pool *pool; + struct gomp_thread_pool_reservoir *res; if (__builtin_expect (thr->thread_pool == NULL, 0)) pthread_setspecific (gomp_thread_destructor, thr); - if (nthreads != 1) + res = gomp_get_thread_pool_reservoir (); + if (res != NULL) { - struct gomp_thread_pool_reservoir *res = - gomp_get_thread_pool_reservoir (); - if (res != NULL) - { - gomp_sem_wait (&res->available); - gomp_mutex_lock (&res->lock); - pool = res->pools[--res->index]; - gomp_mutex_unlock (&res->lock); - pool->threads_busy = nthreads; - thr->thread_pool = pool; - } - else - pool = gomp_get_own_thread_pool (thr, nthreads); + gomp_sem_wait (&res->available); + gomp_mutex_lock (&res->lock); + pool = res->pools[--res->index]; + gomp_mutex_unlock (&res->lock); + pool->threads_busy = nthreads; + thr->thread_pool = pool; } else - pool = NULL; + pool = gomp_get_own_thread_pool (thr, nthreads); + return pool; }