summaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-31 16:57:09 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-31 16:57:09 +0000
commit29416343179a978767229f20f32f5c7835c41c99 (patch)
tree511384c5028ea479fc37eda7be114e6ad0972088 /libgomp
parent7046891f7f7d911a22e17ace4706124123488835 (diff)
downloadgcc-29416343179a978767229f20f32f5c7835c41c99.tar.gz
PR libgomp/55561
* config/linux/wait.h (do_spin): Use atomic load for addr. * config/linux/ptrlock.c (gomp_ptrlock_get_slow): Use atomic for intptr and ptrlock. * config/linux/ptrlock.h (gomp_ptrlock_get): Use atomic load for ptrlock. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195618 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog10
-rw-r--r--libgomp/config/linux/ptrlock.c4
-rw-r--r--libgomp/config/linux/ptrlock.h5
-rw-r--r--libgomp/config/linux/wait.h2
4 files changed, 16 insertions, 5 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 266a66e7b8f..d765f8a25ae 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-31 Dmitry Vyukov <dvyukov@gcc.gnu.org>
+ Joost VandeVondele <Joost.VandeVondele@mat.ethz.ch>
+
+ PR libgomp/55561
+ * config/linux/wait.h (do_spin): Use atomic load for addr.
+ * config/linux/ptrlock.c (gomp_ptrlock_get_slow): Use atomic
+ for intptr and ptrlock.
+ * config/linux/ptrlock.h (gomp_ptrlock_get): Use atomic load
+ for ptrlock.
+
2013-01-22 Alan Modra <amodra@gmail.com>
PR libgomp/51376
diff --git a/libgomp/config/linux/ptrlock.c b/libgomp/config/linux/ptrlock.c
index 6a9ac477f13..fa51111eb23 100644
--- a/libgomp/config/linux/ptrlock.c
+++ b/libgomp/config/linux/ptrlock.c
@@ -50,9 +50,9 @@ gomp_ptrlock_get_slow (gomp_ptrlock_t *ptrlock)
#endif
do
do_wait (intptr, 2);
- while (*intptr == 2);
+ while (__atomic_load_n (intptr, MEMMODEL_RELAXED) == 2);
__asm volatile ("" : : : "memory");
- return *ptrlock;
+ return (void *) __atomic_load_n (ptrlock, MEMMODEL_ACQUIRE);
}
void
diff --git a/libgomp/config/linux/ptrlock.h b/libgomp/config/linux/ptrlock.h
index ef23af71a15..8de1101afd1 100644
--- a/libgomp/config/linux/ptrlock.h
+++ b/libgomp/config/linux/ptrlock.h
@@ -48,8 +48,9 @@ static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock)
{
uintptr_t oldval;
- if ((uintptr_t) *ptrlock > 2)
- return *ptrlock;
+ uintptr_t v = (uintptr_t) __atomic_load_n (ptrlock, MEMMODEL_ACQUIRE);
+ if (v > 2)
+ return (void *) v;
oldval = 0;
if (__atomic_compare_exchange_n (ptrlock, &oldval, 1, false,
diff --git a/libgomp/config/linux/wait.h b/libgomp/config/linux/wait.h
index 8799042bfb9..e60f527bc24 100644
--- a/libgomp/config/linux/wait.h
+++ b/libgomp/config/linux/wait.h
@@ -51,7 +51,7 @@ static inline int do_spin (int *addr, int val)
if (__builtin_expect (gomp_managed_threads > gomp_available_cpus, 0))
count = gomp_throttled_spin_count_var;
for (i = 0; i < count; i++)
- if (__builtin_expect (*addr != val, 0))
+ if (__builtin_expect (__atomic_load_n (addr, MEMMODEL_RELAXED) != val, 0))
return 0;
else
cpu_relax ();