diff options
author | unknown <serg@serg.mylan> | 2006-06-17 16:20:39 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2006-06-17 16:20:39 +0200 |
commit | d1fb292251fc6ba5a455e39d59dad5f7d0d0023f (patch) | |
tree | 1ed4d5cf639665eb2901d57998183b18637eab1a /include/my_atomic.h | |
parent | 0d8d39c8c6ff44e54e0b7869c7497e79ff4d697f (diff) | |
download | mariadb-git-d1fb292251fc6ba5a455e39d59dad5f7d0d0023f.tar.gz |
atomic ops:
my_atomic_XX_t -> intXX, no implicit locking anymore
simplified framework, support for requested cleanups
dbug/dbug.c:
compiler warning
include/atomic/nolock.h:
my_atomic_XX_t -> intXX
include/atomic/rwlock.h:
my_atomic_XX_t -> intXX, no implicit locking anymore
include/atomic/x86-gcc.h:
my_atomic_XX_t -> intXX, no implicit locking anymore
include/atomic/x86-msvc.h:
my_atomic_XX_t -> intXX
simplified defines
support for cleanups
include/my_atomic.h:
my_atomic_XX_t -> intXX, no implicit locking anymore
simplified framework, support for requested cleanups
unittest/examples/no_plan-t.c:
compiler warning
unittest/mysys/Makefile.am:
fix for dependencies
unittest/mysys/my_atomic-t.c:
my_atomic_XX_t -> intXX, no implicit locking anymore
unittest/mytap/tap.c:
cosmetic fix
Diffstat (limited to 'include/my_atomic.h')
-rw-r--r-- | include/my_atomic.h | 113 |
1 files changed, 99 insertions, 14 deletions
diff --git a/include/my_atomic.h b/include/my_atomic.h index 091edc0f57b..877443fe705 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -14,21 +14,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef atomic_rwlock_init - -#ifdef MY_ATOMIC_EXTRA_DEBUG -#ifndef MY_ATOMIC_MODE_RWLOCKS -#error MY_ATOMIC_EXTRA_DEBUG can be only used with MY_ATOMIC_MODE_RWLOCKS -#endif -#define LOCK_PTR void *rw; -#else -#define LOCK_PTR -#endif +#ifndef my_atomic_rwlock_init -typedef volatile struct {uint8 val; LOCK_PTR} my_atomic_8_t; -typedef volatile struct {uint16 val; LOCK_PTR} my_atomic_16_t; -typedef volatile struct {uint32 val; LOCK_PTR} my_atomic_32_t; -typedef volatile struct {uint64 val; LOCK_PTR} my_atomic_64_t; +#define intptr void * #ifndef MY_ATOMIC_MODE_RWLOCKS #include "atomic/nolock.h" @@ -38,6 +26,103 @@ typedef volatile struct {uint64 val; LOCK_PTR} my_atomic_64_t; #include "atomic/rwlock.h" #endif +#ifdef HAVE_INLINE + +#define make_atomic_add(S) \ +static inline int ## S my_atomic_add ## S( \ + int ## S volatile *a, int ## S v) \ +{ \ + make_atomic_add_body(S); \ + return v; \ +} + +#define make_atomic_swap(S) \ +static inline int ## S my_atomic_swap ## S( \ + int ## S volatile *a, int ## S v) \ +{ \ + make_atomic_swap_body(S); \ + return v; \ +} + +#define make_atomic_cas(S) \ +static inline int my_atomic_cas ## S(int ## S volatile *a, \ + int ## S *cmp, int ## S set) \ +{ \ + int8 ret; \ + make_atomic_cas_body(S); \ + return ret; \ +} + +#define make_atomic_load(S) \ +static inline int ## S my_atomic_load ## S(int ## S volatile *a) \ +{ \ + int ## S ret; \ + make_atomic_load_body(S); \ + return ret; \ +} + +#define make_atomic_store(S) \ +static inline void my_atomic_store ## S( \ + int ## S volatile *a, int ## S v) \ +{ \ + make_atomic_store_body(S); \ +} + +#else /* no inline functions */ + +#define make_atomic_add(S) \ +extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v); + +#define make_atomic_swap(S) \ +extern int ## S my_atomic_swap ## S(int ## S volatile *a, int ## S v); + +#define make_atomic_cas(S) \ +extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set); + +#define make_atomic_load(S) \ +extern int ## S my_atomic_load ## S(int ## S volatile *a); + +#define make_atomic_store(S) \ +extern void my_atomic_store ## S(int ## S volatile *a, int ## S v); + +#endif + +make_atomic_add( 8) +make_atomic_add(16) +make_atomic_add(32) + +make_atomic_cas( 8) +make_atomic_cas(16) +make_atomic_cas(32) +make_atomic_cas(ptr) + +make_atomic_load( 8) +make_atomic_load(16) +make_atomic_load(32) +make_atomic_load(ptr) + +make_atomic_store( 8) +make_atomic_store(16) +make_atomic_store(32) +make_atomic_store(ptr) + +make_atomic_swap( 8) +make_atomic_swap(16) +make_atomic_swap(32) +make_atomic_swap(ptr) + +#undef make_atomic_add +#undef make_atomic_cas +#undef make_atomic_load +#undef make_atomic_store +#undef make_atomic_swap +#undef intaptr + +#ifdef _atomic_h_cleanup_ +#include _atomic_h_cleanup_ +#undef _atomic_h_cleanup_ +#endif + #define MY_ATOMIC_OK 0 #define MY_ATOMIC_NOT_1CPU 1 extern int my_atomic_initialize(); |