[RTEMS] Fix libgomp for nthreads == 1
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Fri, 2 Dec 2016 14:10:33 +0000 (14:10 +0000)
committerSebastian Huber <sh@gcc.gnu.org>
Fri, 2 Dec 2016 14:10:33 +0000 (14:10 +0000)
libgomp/

        * config/rtems/pool.h (gomp_get_thread_pool): Return proper
        thread pool in case nthreads == 1.

From-SVN: r243179

libgomp/ChangeLog
libgomp/config/rtems/pool.h

index 9e2a3001b8640fcacb76e8ef5f8af69ff1bdc094..f072ce4971175c6cfa8629584f52c7a2e9665f3e 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-02  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * config/rtems/pool.h (gomp_get_thread_pool): Return proper
+       thread pool in case nthreads == 1.
+
 2016-11-30  Alexander Monakov  <amonakov@ispras.ru>
 
        * config/nvptx/env.c: Delete.
index 7520c071c172bc2ba9ca2a96b7d5830d59e6aec3..e69eca45dda615539ed1e64821fa3d7f2a22112a 100644 (file)
@@ -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;
 }