diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2013-02-28 22:38:25 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2013-02-28 22:38:25 +0400 |
commit | 713e8cdf7de39d3a6383c9b311daf57fe21e73e8 (patch) | |
tree | c9bbd7bab63c88985febe9083f97365dd00d2dbc | |
parent | dc117fd3dd5e93d1f50a5ec66b68aac7a240c08c (diff) |
Minimize gcc/generic-arithm template by factoring out barriers
(code refactoring)
* src/Makefile.am (atomic_ops/sysdeps/gcc/generic-arithm.h): Iterate
over XBAR/XGCCBAR (in addition to XSIZE/XCTYPE).
* src/atomic_ops/sysdeps/gcc/generic-arithm.template: Parametrize all
primitives with XBAR (replacing AO none/acquire/release/full barriers)
and with XGCCBAR (replacing GCC atomic RELAXED/ACQUIRE/RELEASE/SEQ_CST
barriers, respectively).
* src/atomic_ops/sysdeps/gcc/generic-arithm.h: Regenerate.
-rw-r--r-- | src/Makefile.am | 36 | ||||
-rw-r--r-- | src/atomic_ops/sysdeps/gcc/generic-arithm.h | 606 | ||||
-rw-r--r-- | src/atomic_ops/sysdeps/gcc/generic-arithm.template | 108 |
3 files changed, 443 insertions, 307 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f611ac4..7d586e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -124,10 +124,38 @@ atomic_ops/sysdeps/ao_t_is_int.h: atomic_ops/sysdeps/ao_t_is_int.template atomic_ops/sysdeps/gcc/generic-arithm.h: \ atomic_ops/sysdeps/gcc/generic-arithm.template - sed -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? > $@ - sed -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ - sed -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ - sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ + sed -e s:_XBAR::g -e s:XGCCBAR:RELAXED:g \ + -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? > $@ + sed -e s:_XBAR::g -e s:XGCCBAR:RELAXED:g \ + -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ + sed -e s:_XBAR::g -e s:XGCCBAR:RELAXED:g \ + -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ + sed -e s:_XBAR::g -e s:XGCCBAR:RELAXED:g \ + -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ + sed -e s:XBAR:acquire:g -e s:XGCCBAR:ACQUIRE:g \ + -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? >> $@ + sed -e s:XBAR:acquire:g -e s:XGCCBAR:ACQUIRE:g \ + -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ + sed -e s:XBAR:acquire:g -e s:XGCCBAR:ACQUIRE:g \ + -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ + sed -e s:XBAR:acquire:g -e s:XGCCBAR:ACQUIRE:g \ + -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ + sed -e s:XBAR:release:g -e s:XGCCBAR:RELEASE:g \ + -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? >> $@ + sed -e s:XBAR:release:g -e s:XGCCBAR:RELEASE:g \ + -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ + sed -e s:XBAR:release:g -e s:XGCCBAR:RELEASE:g \ + -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ + sed -e s:XBAR:release:g -e s:XGCCBAR:RELEASE:g \ + -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ + sed -e s:XBAR:full:g -e s:XGCCBAR:SEQ_CST:g \ + -e s:XSIZE:char:g -e s:XCTYPE:unsigned/**/char:g $? >> $@ + sed -e s:XBAR:full:g -e s:XGCCBAR:SEQ_CST:g \ + -e s:XSIZE:short:g -e s:XCTYPE:unsigned/**/short:g $? >> $@ + sed -e s:XBAR:full:g -e s:XGCCBAR:SEQ_CST:g \ + -e s:XSIZE:int:g -e s:XCTYPE:unsigned:g $? >> $@ + sed -e s:XBAR:full:g -e s:XGCCBAR:SEQ_CST:g \ + -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? >> $@ atomic_ops/sysdeps/gcc/generic-small.h: \ atomic_ops/sysdeps/gcc/generic-small.template diff --git a/src/atomic_ops/sysdeps/gcc/generic-arithm.h b/src/atomic_ops/sysdeps/gcc/generic-arithm.h index 00b58b9..65e7767 100644 --- a/src/atomic_ops/sysdeps/gcc/generic-arithm.h +++ b/src/atomic_ops/sysdeps/gcc/generic-arithm.h @@ -22,110 +22,158 @@ AO_char_fetch_and_add(volatile unsigned/**/char *addr, unsigned/**/char incr) } #define AO_HAVE_char_fetch_and_add -AO_INLINE unsigned/**/char -AO_char_fetch_and_add_acquire(volatile unsigned/**/char *addr, unsigned/**/char incr) +AO_INLINE void +AO_char_and(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_fetch_and_add_acquire +#define AO_HAVE_char_and -AO_INLINE unsigned/**/char -AO_char_fetch_and_add_release(volatile unsigned/**/char *addr, unsigned/**/char incr) +AO_INLINE void +AO_char_or(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_fetch_and_add_release +#define AO_HAVE_char_or -AO_INLINE unsigned/**/char -AO_char_fetch_and_add_full(volatile unsigned/**/char *addr, unsigned/**/char incr) +AO_INLINE void +AO_char_xor(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_fetch_and_add_full +#define AO_HAVE_char_xor +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_char_and(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_INLINE unsigned/**/short +AO_short_fetch_and_add(volatile unsigned/**/short *addr, unsigned/**/short incr) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); } -#define AO_HAVE_char_and +#define AO_HAVE_short_fetch_and_add AO_INLINE void -AO_char_and_acquire(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_short_and(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_and_acquire +#define AO_HAVE_short_and AO_INLINE void -AO_char_and_release(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_short_or(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_and_release +#define AO_HAVE_short_or AO_INLINE void -AO_char_and_full(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_short_xor(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_and_full +#define AO_HAVE_short_xor +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_char_or(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_INLINE unsigned +AO_int_fetch_and_add(volatile unsigned *addr, unsigned incr) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); } -#define AO_HAVE_char_or +#define AO_HAVE_int_fetch_and_add AO_INLINE void -AO_char_or_acquire(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_int_and(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_or_acquire +#define AO_HAVE_int_and AO_INLINE void -AO_char_or_release(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_int_or(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_or_release +#define AO_HAVE_int_or AO_INLINE void -AO_char_or_full(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_int_xor(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_or_full +#define AO_HAVE_int_xor +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_char_xor(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_INLINE AO_t +AO_fetch_and_add(volatile AO_t *addr, AO_t incr) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); } -#define AO_HAVE_char_xor +#define AO_HAVE_fetch_and_add AO_INLINE void -AO_char_xor_acquire(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_and(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_xor_acquire +#define AO_HAVE_and AO_INLINE void -AO_char_xor_release(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_or(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_xor_release +#define AO_HAVE_or AO_INLINE void -AO_char_xor_full(volatile unsigned/**/char *addr, unsigned/**/char value) +AO_xor(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); } -#define AO_HAVE_char_xor_full +#define AO_HAVE_xor /* * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. @@ -143,40 +191,56 @@ AO_char_xor_full(volatile unsigned/**/char *addr, unsigned/**/char value) * */ -AO_INLINE unsigned/**/short -AO_short_fetch_and_add(volatile unsigned/**/short *addr, unsigned/**/short incr) +AO_INLINE unsigned/**/char +AO_char_fetch_and_add_acquire(volatile unsigned/**/char *addr, unsigned/**/char incr) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_fetch_and_add +#define AO_HAVE_char_fetch_and_add_acquire -AO_INLINE unsigned/**/short -AO_short_fetch_and_add_acquire(volatile unsigned/**/short *addr, unsigned/**/short incr) +AO_INLINE void +AO_char_and_acquire(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_fetch_and_add_acquire +#define AO_HAVE_char_and_acquire -AO_INLINE unsigned/**/short -AO_short_fetch_and_add_release(volatile unsigned/**/short *addr, unsigned/**/short incr) +AO_INLINE void +AO_char_or_acquire(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_fetch_and_add_release +#define AO_HAVE_char_or_acquire -AO_INLINE unsigned/**/short -AO_short_fetch_and_add_full(volatile unsigned/**/short *addr, unsigned/**/short incr) +AO_INLINE void +AO_char_xor_acquire(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_fetch_and_add_full +#define AO_HAVE_char_xor_acquire +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_short_and(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_INLINE unsigned/**/short +AO_short_fetch_and_add_acquire(volatile unsigned/**/short *addr, unsigned/**/short incr) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_and +#define AO_HAVE_short_fetch_and_add_acquire AO_INLINE void AO_short_and_acquire(volatile unsigned/**/short *addr, unsigned/**/short value) @@ -186,74 +250,106 @@ AO_short_and_acquire(volatile unsigned/**/short *addr, unsigned/**/short value) #define AO_HAVE_short_and_acquire AO_INLINE void -AO_short_and_release(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_short_or_acquire(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_and_release +#define AO_HAVE_short_or_acquire AO_INLINE void -AO_short_and_full(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_short_xor_acquire(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_and_full +#define AO_HAVE_short_xor_acquire +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_short_or(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_INLINE unsigned +AO_int_fetch_and_add_acquire(volatile unsigned *addr, unsigned incr) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_or +#define AO_HAVE_int_fetch_and_add_acquire AO_INLINE void -AO_short_or_acquire(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_int_and_acquire(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_or_acquire +#define AO_HAVE_int_and_acquire AO_INLINE void -AO_short_or_release(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_int_or_acquire(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_or_release +#define AO_HAVE_int_or_acquire AO_INLINE void -AO_short_or_full(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_int_xor_acquire(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_or_full +#define AO_HAVE_int_xor_acquire +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_short_xor(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_INLINE AO_t +AO_fetch_and_add_acquire(volatile AO_t *addr, AO_t incr) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_xor +#define AO_HAVE_fetch_and_add_acquire AO_INLINE void -AO_short_xor_acquire(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_and_acquire(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_xor_acquire +#define AO_HAVE_and_acquire AO_INLINE void -AO_short_xor_release(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_or_acquire(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_xor_release +#define AO_HAVE_or_acquire AO_INLINE void -AO_short_xor_full(volatile unsigned/**/short *addr, unsigned/**/short value) +AO_xor_acquire(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); } -#define AO_HAVE_short_xor_full +#define AO_HAVE_xor_acquire /* * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. @@ -271,75 +367,107 @@ AO_short_xor_full(volatile unsigned/**/short *addr, unsigned/**/short value) * */ -AO_INLINE unsigned -AO_int_fetch_and_add(volatile unsigned *addr, unsigned incr) +AO_INLINE unsigned/**/char +AO_char_fetch_and_add_release(volatile unsigned/**/char *addr, unsigned/**/char incr) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); } -#define AO_HAVE_int_fetch_and_add +#define AO_HAVE_char_fetch_and_add_release -AO_INLINE unsigned -AO_int_fetch_and_add_acquire(volatile unsigned *addr, unsigned incr) +AO_INLINE void +AO_char_and_release(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_fetch_and_add_acquire +#define AO_HAVE_char_and_release -AO_INLINE unsigned -AO_int_fetch_and_add_release(volatile unsigned *addr, unsigned incr) +AO_INLINE void +AO_char_or_release(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_fetch_and_add_release +#define AO_HAVE_char_or_release -AO_INLINE unsigned -AO_int_fetch_and_add_full(volatile unsigned *addr, unsigned incr) +AO_INLINE void +AO_char_xor_release(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_fetch_and_add_full +#define AO_HAVE_char_xor_release +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_int_and(volatile unsigned *addr, unsigned value) +AO_INLINE unsigned/**/short +AO_short_fetch_and_add_release(volatile unsigned/**/short *addr, unsigned/**/short incr) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); } -#define AO_HAVE_int_and +#define AO_HAVE_short_fetch_and_add_release AO_INLINE void -AO_int_and_acquire(volatile unsigned *addr, unsigned value) +AO_short_and_release(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_and_acquire +#define AO_HAVE_short_and_release AO_INLINE void -AO_int_and_release(volatile unsigned *addr, unsigned value) +AO_short_or_release(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_and_release +#define AO_HAVE_short_or_release AO_INLINE void -AO_int_and_full(volatile unsigned *addr, unsigned value) +AO_short_xor_release(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_and_full +#define AO_HAVE_short_xor_release +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_int_or(volatile unsigned *addr, unsigned value) +AO_INLINE unsigned +AO_int_fetch_and_add_release(volatile unsigned *addr, unsigned incr) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); } -#define AO_HAVE_int_or +#define AO_HAVE_int_fetch_and_add_release AO_INLINE void -AO_int_or_acquire(volatile unsigned *addr, unsigned value) +AO_int_and_release(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_or_acquire +#define AO_HAVE_int_and_release AO_INLINE void AO_int_or_release(volatile unsigned *addr, unsigned value) @@ -349,39 +477,55 @@ AO_int_or_release(volatile unsigned *addr, unsigned value) #define AO_HAVE_int_or_release AO_INLINE void -AO_int_or_full(volatile unsigned *addr, unsigned value) +AO_int_xor_release(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_or_full +#define AO_HAVE_int_xor_release +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_int_xor(volatile unsigned *addr, unsigned value) +AO_INLINE AO_t +AO_fetch_and_add_release(volatile AO_t *addr, AO_t incr) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); } -#define AO_HAVE_int_xor +#define AO_HAVE_fetch_and_add_release AO_INLINE void -AO_int_xor_acquire(volatile unsigned *addr, unsigned value) +AO_and_release(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_xor_acquire +#define AO_HAVE_and_release AO_INLINE void -AO_int_xor_release(volatile unsigned *addr, unsigned value) +AO_or_release(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_xor_release +#define AO_HAVE_or_release AO_INLINE void -AO_int_xor_full(volatile unsigned *addr, unsigned value) +AO_xor_release(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); } -#define AO_HAVE_int_xor_full +#define AO_HAVE_xor_release /* * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. @@ -399,110 +543,158 @@ AO_int_xor_full(volatile unsigned *addr, unsigned value) * */ -AO_INLINE AO_t -AO_fetch_and_add(volatile AO_t *addr, AO_t incr) +AO_INLINE unsigned/**/char +AO_char_fetch_and_add_full(volatile unsigned/**/char *addr, unsigned/**/char incr) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); } -#define AO_HAVE_fetch_and_add +#define AO_HAVE_char_fetch_and_add_full -AO_INLINE AO_t -AO_fetch_and_add_acquire(volatile AO_t *addr, AO_t incr) +AO_INLINE void +AO_char_and_full(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_fetch_and_add_acquire +#define AO_HAVE_char_and_full -AO_INLINE AO_t -AO_fetch_and_add_release(volatile AO_t *addr, AO_t incr) +AO_INLINE void +AO_char_or_full(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_fetch_and_add_release +#define AO_HAVE_char_or_full -AO_INLINE AO_t -AO_fetch_and_add_full(volatile AO_t *addr, AO_t incr) +AO_INLINE void +AO_char_xor_full(volatile unsigned/**/char *addr, unsigned/**/char value) { - return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_fetch_and_add_full +#define AO_HAVE_char_xor_full +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_and(volatile AO_t *addr, AO_t value) +AO_INLINE unsigned/**/short +AO_short_fetch_and_add_full(volatile unsigned/**/short *addr, unsigned/**/short incr) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); } -#define AO_HAVE_and +#define AO_HAVE_short_fetch_and_add_full AO_INLINE void -AO_and_acquire(volatile AO_t *addr, AO_t value) +AO_short_and_full(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_and_acquire +#define AO_HAVE_short_and_full AO_INLINE void -AO_and_release(volatile AO_t *addr, AO_t value) +AO_short_or_full(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_and_release +#define AO_HAVE_short_or_full AO_INLINE void -AO_and_full(volatile AO_t *addr, AO_t value) +AO_short_xor_full(volatile unsigned/**/short *addr, unsigned/**/short value) { - (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_and_full +#define AO_HAVE_short_xor_full +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_or(volatile AO_t *addr, AO_t value) +AO_INLINE unsigned +AO_int_fetch_and_add_full(volatile unsigned *addr, unsigned incr) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); } -#define AO_HAVE_or +#define AO_HAVE_int_fetch_and_add_full AO_INLINE void -AO_or_acquire(volatile AO_t *addr, AO_t value) +AO_int_and_full(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_or_acquire +#define AO_HAVE_int_and_full AO_INLINE void -AO_or_release(volatile AO_t *addr, AO_t value) +AO_int_or_full(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_or_release +#define AO_HAVE_int_or_full AO_INLINE void -AO_or_full(volatile AO_t *addr, AO_t value) +AO_int_xor_full(volatile unsigned *addr, unsigned value) { - (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_or_full +#define AO_HAVE_int_xor_full +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ -AO_INLINE void -AO_xor(volatile AO_t *addr, AO_t value) +AO_INLINE AO_t +AO_fetch_and_add_full(volatile AO_t *addr, AO_t incr) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); } -#define AO_HAVE_xor +#define AO_HAVE_fetch_and_add_full AO_INLINE void -AO_xor_acquire(volatile AO_t *addr, AO_t value) +AO_and_full(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_xor_acquire +#define AO_HAVE_and_full AO_INLINE void -AO_xor_release(volatile AO_t *addr, AO_t value) +AO_or_full(volatile AO_t *addr, AO_t value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); } -#define AO_HAVE_xor_release +#define AO_HAVE_or_full AO_INLINE void AO_xor_full(volatile AO_t *addr, AO_t value) diff --git a/src/atomic_ops/sysdeps/gcc/generic-arithm.template b/src/atomic_ops/sysdeps/gcc/generic-arithm.template index fb7b818..2067d55 100644 --- a/src/atomic_ops/sysdeps/gcc/generic-arithm.template +++ b/src/atomic_ops/sysdeps/gcc/generic-arithm.template @@ -16,113 +16,29 @@ */ AO_INLINE XCTYPE -AO_XSIZE_fetch_and_add(volatile XCTYPE *addr, XCTYPE incr) +AO_XSIZE_fetch_and_add_XBAR(volatile XCTYPE *addr, XCTYPE incr) { - return __atomic_fetch_add(addr, incr, __ATOMIC_RELAXED); + return __atomic_fetch_add(addr, incr, __ATOMIC_XGCCBAR); } -#define AO_HAVE_XSIZE_fetch_and_add - -AO_INLINE XCTYPE -AO_XSIZE_fetch_and_add_acquire(volatile XCTYPE *addr, XCTYPE incr) -{ - return __atomic_fetch_add(addr, incr, __ATOMIC_ACQUIRE); -} -#define AO_HAVE_XSIZE_fetch_and_add_acquire - -AO_INLINE XCTYPE -AO_XSIZE_fetch_and_add_release(volatile XCTYPE *addr, XCTYPE incr) -{ - return __atomic_fetch_add(addr, incr, __ATOMIC_RELEASE); -} -#define AO_HAVE_XSIZE_fetch_and_add_release - -AO_INLINE XCTYPE -AO_XSIZE_fetch_and_add_full(volatile XCTYPE *addr, XCTYPE incr) -{ - return __atomic_fetch_add(addr, incr, __ATOMIC_SEQ_CST); -} -#define AO_HAVE_XSIZE_fetch_and_add_full - -AO_INLINE void -AO_XSIZE_and(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELAXED); -} -#define AO_HAVE_XSIZE_and - -AO_INLINE void -AO_XSIZE_and_acquire(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_and_fetch(addr, value, __ATOMIC_ACQUIRE); -} -#define AO_HAVE_XSIZE_and_acquire - -AO_INLINE void -AO_XSIZE_and_release(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_and_fetch(addr, value, __ATOMIC_RELEASE); -} -#define AO_HAVE_XSIZE_and_release - -AO_INLINE void -AO_XSIZE_and_full(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_and_fetch(addr, value, __ATOMIC_SEQ_CST); -} -#define AO_HAVE_XSIZE_and_full - -AO_INLINE void -AO_XSIZE_or(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELAXED); -} -#define AO_HAVE_XSIZE_or - -AO_INLINE void -AO_XSIZE_or_acquire(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_or_fetch(addr, value, __ATOMIC_ACQUIRE); -} -#define AO_HAVE_XSIZE_or_acquire - -AO_INLINE void -AO_XSIZE_or_release(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_or_fetch(addr, value, __ATOMIC_RELEASE); -} -#define AO_HAVE_XSIZE_or_release - -AO_INLINE void -AO_XSIZE_or_full(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_or_fetch(addr, value, __ATOMIC_SEQ_CST); -} -#define AO_HAVE_XSIZE_or_full - -AO_INLINE void -AO_XSIZE_xor(volatile XCTYPE *addr, XCTYPE value) -{ - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELAXED); -} -#define AO_HAVE_XSIZE_xor +#define AO_HAVE_XSIZE_fetch_and_add_XBAR AO_INLINE void -AO_XSIZE_xor_acquire(volatile XCTYPE *addr, XCTYPE value) +AO_XSIZE_and_XBAR(volatile XCTYPE *addr, XCTYPE value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_ACQUIRE); + (void)__atomic_and_fetch(addr, value, __ATOMIC_XGCCBAR); } -#define AO_HAVE_XSIZE_xor_acquire +#define AO_HAVE_XSIZE_and_XBAR AO_INLINE void -AO_XSIZE_xor_release(volatile XCTYPE *addr, XCTYPE value) +AO_XSIZE_or_XBAR(volatile XCTYPE *addr, XCTYPE value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_RELEASE); + (void)__atomic_or_fetch(addr, value, __ATOMIC_XGCCBAR); } -#define AO_HAVE_XSIZE_xor_release +#define AO_HAVE_XSIZE_or_XBAR AO_INLINE void -AO_XSIZE_xor_full(volatile XCTYPE *addr, XCTYPE value) +AO_XSIZE_xor_XBAR(volatile XCTYPE *addr, XCTYPE value) { - (void)__atomic_xor_fetch(addr, value, __ATOMIC_SEQ_CST); + (void)__atomic_xor_fetch(addr, value, __ATOMIC_XGCCBAR); } -#define AO_HAVE_XSIZE_xor_full +#define AO_HAVE_XSIZE_xor_XBAR |