aboutsummaryrefslogtreecommitdiff
path: root/include/atomic.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-02-08 23:50:23 +0000
committerUlrich Drepper <drepper@redhat.com>2009-02-08 23:50:23 +0000
commit6c03cd11e9c253211c831a70dfece6f5bd07e12c (patch)
treeb934f05fab05e9ab7e65859d400ce8b28847cc01 /include/atomic.h
parent6dd6a580dff2b88b3bf6a37f59068bbfeb51c97d (diff)
downloadglibc-6c03cd11e9c253211c831a70dfece6f5bd07e12c.zip
glibc-6c03cd11e9c253211c831a70dfece6f5bd07e12c.tar.gz
glibc-6c03cd11e9c253211c831a70dfece6f5bd07e12c.tar.bz2
* include/atomic.h: Define catomic_and if not already defined.
* sysdeps/x86_64/bits/atomic.h: Define catomic_and. * sysdeps/i386/i486/bits/atomic.h: Likewise.
Diffstat (limited to 'include/atomic.h')
-rw-r--r--include/atomic.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/atomic.h b/include/atomic.h
index 2ad8b5f..7c0548b 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -1,5 +1,5 @@
/* Internal macros for atomic operations for GNU C Library.
- Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -415,6 +415,22 @@
} while (0)
#endif
+#ifndef catomic_and
+# define catomic_and(mem, mask) \
+ do { \
+ __typeof (*(mem)) __atg20_old; \
+ __typeof (mem) __atg20_memp = (mem); \
+ __typeof (*(mem)) __atg20_mask = (mask); \
+ \
+ do \
+ __atg20_old = (*__atg20_memp); \
+ while (__builtin_expect \
+ (catomic_compare_and_exchange_bool_acq (__atg20_memp, \
+ __atg20_old & __atg20_mask,\
+ __atg20_old), 0)); \
+ } while (0)
+#endif
+
/* Atomically *mem &= mask and return the old value of *mem. */
#ifndef atomic_and_val
# define atomic_and_val(mem, mask) \