OSDN Git Service

* c-cppbuiltin.c (c_cpp_builtins): Change _OPENMP value to
[pf3gnuchains/gcc-fork.git] / libgomp / sections.c
index 9ccc65e..27625ef 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@redhat.com>.
 
    This file is part of the GNU OpenMP Library (libgomp).
@@ -59,14 +59,24 @@ GOMP_sections_start (unsigned count)
   long s, e, ret;
 
   if (gomp_work_share_start (false))
-    gomp_sections_init (thr->ts.work_share, count);
+    {
+      gomp_sections_init (thr->ts.work_share, count);
+      gomp_work_share_init_done ();
+    }
 
+#ifdef HAVE_SYNC_BUILTINS
+  if (gomp_iter_dynamic_next (&s, &e))
+    ret = s;
+  else
+    ret = 0;
+#else
+  gomp_mutex_lock (&thr->ts.work_share->lock);
   if (gomp_iter_dynamic_next_locked (&s, &e))
     ret = s;
   else
     ret = 0;
-
   gomp_mutex_unlock (&thr->ts.work_share->lock);
+#endif
 
   return ret;
 }
@@ -83,15 +93,23 @@ GOMP_sections_start (unsigned count)
 unsigned
 GOMP_sections_next (void)
 {
-  struct gomp_thread *thr = gomp_thread ();
   long s, e, ret;
 
+#ifdef HAVE_SYNC_BUILTINS
+  if (gomp_iter_dynamic_next (&s, &e))
+    ret = s;
+  else
+    ret = 0;
+#else
+  struct gomp_thread *thr = gomp_thread ();
+
   gomp_mutex_lock (&thr->ts.work_share->lock);
   if (gomp_iter_dynamic_next_locked (&s, &e))
     ret = s;
   else
     ret = 0;
   gomp_mutex_unlock (&thr->ts.work_share->lock);
+#endif
 
   return ret;
 }
@@ -103,15 +121,12 @@ void
 GOMP_parallel_sections_start (void (*fn) (void *), void *data,
                              unsigned num_threads, unsigned count)
 {
-  struct gomp_work_share *ws;
-
-  num_threads = gomp_resolve_num_threads (num_threads);
-  if (gomp_dyn_var && num_threads > count)
-    num_threads = count;
+  struct gomp_team *team;
 
-  ws = gomp_new_work_share (false, num_threads);
-  gomp_sections_init (ws, count);
-  gomp_team_start (fn, data, num_threads, ws);
+  num_threads = gomp_resolve_num_threads (num_threads, count);
+  team = gomp_new_team (num_threads);
+  gomp_sections_init (&team->work_shares[0], count);
+  gomp_team_start (fn, data, num_threads, team);
 }
 
 /* The GOMP_section_end* routines are called after the thread is told