xref: /netbsd-src/external/gpl3/gcc.old/dist/libgomp/barrier.c (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1*8feb0f0bSmrg /* Copyright (C) 2005-2020 Free Software Foundation, Inc.
21debfc3dSmrg    Contributed by Richard Henderson <rth@redhat.com>.
31debfc3dSmrg 
41debfc3dSmrg    This file is part of the GNU Offloading and Multi Processing Library
51debfc3dSmrg    (libgomp).
61debfc3dSmrg 
71debfc3dSmrg    Libgomp is free software; you can redistribute it and/or modify it
81debfc3dSmrg    under the terms of the GNU General Public License as published by
91debfc3dSmrg    the Free Software Foundation; either version 3, or (at your option)
101debfc3dSmrg    any later version.
111debfc3dSmrg 
121debfc3dSmrg    Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
131debfc3dSmrg    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
141debfc3dSmrg    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
151debfc3dSmrg    more details.
161debfc3dSmrg 
171debfc3dSmrg    Under Section 7 of GPL version 3, you are granted additional
181debfc3dSmrg    permissions described in the GCC Runtime Library Exception, version
191debfc3dSmrg    3.1, as published by the Free Software Foundation.
201debfc3dSmrg 
211debfc3dSmrg    You should have received a copy of the GNU General Public License and
221debfc3dSmrg    a copy of the GCC Runtime Library Exception along with this program;
231debfc3dSmrg    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
241debfc3dSmrg    <http://www.gnu.org/licenses/>.  */
251debfc3dSmrg 
261debfc3dSmrg /* This file handles the BARRIER construct.  */
271debfc3dSmrg 
281debfc3dSmrg #include "libgomp.h"
291debfc3dSmrg 
301debfc3dSmrg 
311debfc3dSmrg void
GOMP_barrier(void)321debfc3dSmrg GOMP_barrier (void)
331debfc3dSmrg {
341debfc3dSmrg   struct gomp_thread *thr = gomp_thread ();
351debfc3dSmrg   struct gomp_team *team = thr->ts.team;
361debfc3dSmrg 
371debfc3dSmrg   /* It is legal to have orphaned barriers.  */
381debfc3dSmrg   if (team == NULL)
391debfc3dSmrg     return;
401debfc3dSmrg 
411debfc3dSmrg   gomp_team_barrier_wait (&team->barrier);
421debfc3dSmrg }
431debfc3dSmrg 
441debfc3dSmrg bool
GOMP_barrier_cancel(void)451debfc3dSmrg GOMP_barrier_cancel (void)
461debfc3dSmrg {
471debfc3dSmrg   struct gomp_thread *thr = gomp_thread ();
481debfc3dSmrg   struct gomp_team *team = thr->ts.team;
491debfc3dSmrg 
501debfc3dSmrg   /* The compiler transforms to barrier_cancel when it sees that the
511debfc3dSmrg      barrier is within a construct that can cancel.  Thus we should
521debfc3dSmrg      never have an orphaned cancellable barrier.  */
531debfc3dSmrg   return gomp_team_barrier_wait_cancel (&team->barrier);
541debfc3dSmrg }
55