]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgomp/work.c
Update copyright years.
[thirdparty/gcc.git] / libgomp / work.c
index 22adb8b9fcd14481be19cadbf42980445301658f..6817da8b4dee53bf16f4c3b23bcbae86a7f77ba6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@redhat.com>.
 
    This file is part of the GNU Offloading and Multi Processing Library
@@ -110,14 +110,17 @@ gomp_init_work_share (struct gomp_work_share *ws, size_t ordered,
 
       if (__builtin_expect (ordered != 1, 0))
        {
-         ordered += nthreads * sizeof (*ws->ordered_team_ids) - 1;
-         ordered = ordered + __alignof__ (long long) - 1;
-         ordered &= ~(__alignof__ (long long) - 1);
+         size_t o = nthreads * sizeof (*ws->ordered_team_ids);
+         o += __alignof__ (long long) - 1;
+         if ((offsetof (struct gomp_work_share, inline_ordered_team_ids)
+              & (__alignof__ (long long) - 1)) == 0)
+           o &= ~(__alignof__ (long long) - 1);
+         ordered += o - 1;
        }
       else
        ordered = nthreads * sizeof (*ws->ordered_team_ids);
       if (ordered > INLINE_ORDERED_TEAM_IDS_SIZE)
-       ws->ordered_team_ids = gomp_malloc (ordered);
+       ws->ordered_team_ids = team_malloc (ordered);
       else
        ws->ordered_team_ids = ws->inline_ordered_team_ids;
       memset (ws->ordered_team_ids, '\0', ordered);
@@ -139,7 +142,7 @@ gomp_fini_work_share (struct gomp_work_share *ws)
 {
   gomp_mutex_destroy (&ws->lock);
   if (ws->ordered_team_ids != ws->inline_ordered_team_ids)
-    free (ws->ordered_team_ids);
+    team_free (ws->ordered_team_ids);
   gomp_ptrlock_destroy (&ws->next_ws);
 }