diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-15 19:46:11 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-07-15 19:46:11 +0000 |
commit | 4dcd09ad839fb64979ea50967f9a4995700d4f7c (patch) | |
tree | 3db1d5696a3515cfad06bdd05a17d82acd4e5ab8 /libgomp/config/linux/ia64/mutex.h | |
parent | 9736d0ec9e0384939f72ba048c7411e1e547f729 (diff) | |
download | gcc-4dcd09ad839fb64979ea50967f9a4995700d4f7c.tar.gz |
* config/linux/wait.h (do_spin): New inline, largely copied
from do_wait, just don't do futex_wait here, instead return true if
it should be done.
(do_wait): Implement using do_spin.
* config/linux/mutex.h (gomp_mutex_lock_slow): Add an int argument
to prototype.
(gomp_mutex_lock): Use __sync_val_compare_and_swap instead of
__sync_bool_compare_and_swap, pass the oldval to
gomp_mutex_lock_slow.
* config/linux/mutex.c (gomp_mutex_lock_slow): Add oldval argument.
If all mutex contenders are just spinning and not sleeping, don't
change state to 2 unnecessarily. Optimize the loop when state has
already become 2 to use just one atomic operation per loop instead
of two.
* config/linux/ia64/mutex.h (gomp_mutex_lock_slow): Add an int argument
to prototype.
(gomp_mutex_lock): Use __sync_val_compare_and_swap instead of
__sync_bool_compare_and_swap, pass the oldval to
gomp_mutex_lock_slow.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176326 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/config/linux/ia64/mutex.h')
-rw-r--r-- | libgomp/config/linux/ia64/mutex.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libgomp/config/linux/ia64/mutex.h b/libgomp/config/linux/ia64/mutex.h index 6e294059b23..8a67673df40 100644 --- a/libgomp/config/linux/ia64/mutex.h +++ b/libgomp/config/linux/ia64/mutex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2008, 2009, 2011 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. This file is part of the GNU OpenMP Library (libgomp). @@ -38,11 +38,12 @@ static inline void gomp_mutex_init (gomp_mutex_t *mutex) *mutex = 0; } -extern void gomp_mutex_lock_slow (gomp_mutex_t *mutex); +extern void gomp_mutex_lock_slow (gomp_mutex_t *mutex, int); static inline void gomp_mutex_lock (gomp_mutex_t *mutex) { - if (!__sync_bool_compare_and_swap (mutex, 0, 1)) - gomp_mutex_lock_slow (mutex); + int oldval = __sync_val_compare_and_swap (mutex, 0, 1); + if (__builtin_expect (oldval, 0)) + gomp_mutex_lock_slow (mutex, oldval); } extern void gomp_mutex_unlock_slow (gomp_mutex_t *mutex); |