From 6c03cd11e9c253211c831a70dfece6f5bd07e12c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 8 Feb 2009 23:50:23 +0000 Subject: * 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. --- include/atomic.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include/atomic.h') 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 , 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) \ -- cgit v1.1