diff options
Diffstat (limited to 'include/atomic.h')
-rw-r--r-- | include/atomic.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/atomic.h b/include/atomic.h index 2ad8b5fcb7..7c0548b004 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) \ |