diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-01-18 07:18:46 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-01-18 07:18:46 +0100 |
commit | d3b41bde961713ff4af7e18011126434c497edba (patch) | |
tree | 72a909a9aa158d38893c15a79b86ac0649849b27 /libgomp/task.c | |
parent | 994fb69ac1b7d52348e84a021c07b24e285294d0 (diff) | |
download | gcc-d3b41bde961713ff4af7e18011126434c497edba.zip gcc-d3b41bde961713ff4af7e18011126434c497edba.tar.gz gcc-d3b41bde961713ff4af7e18011126434c497edba.tar.bz2 |
libgomp: Don't access gomp_sem_t as int using atomics unconditionally
This patch introduces gomp_sem_getcount wrapper, which uses sem_getvalue
for POSIX and atomic loads for linux futex and accel. rtems for now
remains broken.
2021-01-18 Jakub Jelinek <jakub@redhat.com>
* config/linux/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.c (gomp_sem_getcount): New function.
* config/accel/sem.h (gomp_sem_getcount): New function.
* task.c (task_fulfilled_p): Use gomp_sem_getcount.
(omp_fulfill_event): Likewise.
Diffstat (limited to 'libgomp/task.c')
-rw-r--r-- | libgomp/task.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libgomp/task.c b/libgomp/task.c index 5ece878..8db031c 100644 --- a/libgomp/task.c +++ b/libgomp/task.c @@ -330,7 +330,7 @@ gomp_task_handle_depend (struct gomp_task *task, struct gomp_task *parent, static bool task_fulfilled_p (struct gomp_task *task) { - return __atomic_load_n (&task->completion_sem, __ATOMIC_RELAXED); + return gomp_sem_getcount (&task->completion_sem) > 0; } /* Called when encountering an explicit task directive. If IF_CLAUSE is @@ -2406,7 +2406,7 @@ omp_fulfill_event (omp_event_handle_t event) struct gomp_thread *thr = gomp_thread (); struct gomp_team *team = thr ? thr->ts.team : NULL; - if (__atomic_load_n (sem, __ATOMIC_RELAXED)) + if (gomp_sem_getcount (sem) > 0) gomp_fatal ("omp_fulfill_event: %p event already fulfilled!\n", sem); gomp_debug (0, "omp_fulfill_event: %p\n", sem); |