]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgomp/icv.c
Daily bump.
[thirdparty/gcc.git] / libgomp / icv.c
index 8df15e385e705a799f4b82027d306a47df6e64cd..c4a4d68edd2dcf058e96680005623221c0cee1f5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2024 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@redhat.com>.
 
    This file is part of the GNU Offloading and Multi Processing Library
@@ -30,6 +30,8 @@
 #include "gomp-constants.h"
 #include <limits.h>
 
+ialias_redirect (omp_get_active_level)
+
 void
 omp_set_num_threads (int n)
 {
@@ -57,14 +59,18 @@ void
 omp_set_nested (int val)
 {
   struct gomp_task_icv *icv = gomp_icv (true);
-  icv->nest_var = val;
+  if (val)
+    icv->max_active_levels_var = gomp_supported_active_levels;
+  else if (icv->max_active_levels_var > 1)
+    icv->max_active_levels_var = 1;
 }
 
 int
 omp_get_nested (void)
 {
   struct gomp_task_icv *icv = gomp_icv (false);
-  return icv->nest_var;
+  return (icv->max_active_levels_var > 1
+         && icv->max_active_levels_var > omp_get_active_level ());
 }
 #pragma GCC diagnostic pop
 
@@ -120,17 +126,20 @@ omp_set_max_active_levels (int max_levels)
 {
   if (max_levels >= 0)
     {
+      struct gomp_task_icv *icv = gomp_icv (true);
+
       if (max_levels <= gomp_supported_active_levels)
-       gomp_max_active_levels_var = max_levels;
+       icv->max_active_levels_var = max_levels;
       else
-       gomp_max_active_levels_var = gomp_supported_active_levels;
+       icv->max_active_levels_var = gomp_supported_active_levels;
     }
 }
 
 int
 omp_get_max_active_levels (void)
 {
-  return gomp_max_active_levels_var;
+  struct gomp_task_icv *icv = gomp_icv (false);
+  return icv->max_active_levels_var;
 }
 
 int