mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-13728 - Import MySQL 5.7 atomic operations for MSVC and Solaris
gcc_sync.h, solaris.h, generic-msvc.h copied verbatim.
This commit is contained in:
@@ -110,119 +110,13 @@
|
||||
#include "atomic/generic-msvc.h"
|
||||
#elif defined(HAVE_SOLARIS_ATOMIC)
|
||||
#include "atomic/solaris.h"
|
||||
#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_C11_ATOMICS)
|
||||
#elif defined(HAVE_GCC_C11_ATOMICS)
|
||||
#include "atomic/gcc_builtins.h"
|
||||
#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
|
||||
#include "atomic/gcc_sync.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_GCC_C11_ATOMICS
|
||||
#ifndef make_atomic_cas_body
|
||||
/* nolock.h was not able to generate even a CAS function, fall back */
|
||||
#error atomic ops for this platform are not implemented
|
||||
#endif
|
||||
|
||||
#define intptr void *
|
||||
|
||||
/* define missing functions by using the already generated ones */
|
||||
#ifndef make_atomic_add_body
|
||||
#define make_atomic_add_body(S) \
|
||||
int ## S tmp=*a; \
|
||||
while (!my_atomic_cas ## S(a, &tmp, tmp+v)) ; \
|
||||
v=tmp;
|
||||
#endif
|
||||
#ifndef make_atomic_fas_body
|
||||
#define make_atomic_fas_body(S) \
|
||||
int ## S tmp=*a; \
|
||||
while (!my_atomic_cas ## S(a, &tmp, v)) ; \
|
||||
v=tmp;
|
||||
#endif
|
||||
#ifndef make_atomic_load_body
|
||||
#define make_atomic_load_body(S) \
|
||||
ret= 0; /* avoid compiler warning */ \
|
||||
(void)(my_atomic_cas ## S(a, &ret, ret));
|
||||
#endif
|
||||
#ifndef make_atomic_store_body
|
||||
#define make_atomic_store_body(S) \
|
||||
(void)(my_atomic_fas ## S (a, v));
|
||||
#endif
|
||||
|
||||
#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_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_fas(S) \
|
||||
static inline int ## S my_atomic_fas ## S( \
|
||||
int ## S volatile *a, int ## S v) \
|
||||
{ \
|
||||
make_atomic_fas_body(S); \
|
||||
return v; \
|
||||
}
|
||||
|
||||
#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); \
|
||||
}
|
||||
|
||||
make_atomic_cas(32)
|
||||
make_atomic_cas(64)
|
||||
make_atomic_cas(ptr)
|
||||
|
||||
make_atomic_add(32)
|
||||
make_atomic_add(64)
|
||||
|
||||
make_atomic_load(32)
|
||||
make_atomic_load(64)
|
||||
make_atomic_load(ptr)
|
||||
|
||||
make_atomic_fas(32)
|
||||
make_atomic_fas(64)
|
||||
make_atomic_fas(ptr)
|
||||
|
||||
make_atomic_store(32)
|
||||
make_atomic_store(64)
|
||||
make_atomic_store(ptr)
|
||||
|
||||
#ifdef _atomic_h_cleanup_
|
||||
#include _atomic_h_cleanup_
|
||||
#undef _atomic_h_cleanup_
|
||||
#endif
|
||||
|
||||
#undef make_atomic_add
|
||||
#undef make_atomic_cas
|
||||
#undef make_atomic_load
|
||||
#undef make_atomic_store
|
||||
#undef make_atomic_fas
|
||||
#undef make_atomic_add_body
|
||||
#undef make_atomic_cas_body
|
||||
#undef make_atomic_load_body
|
||||
#undef make_atomic_store_body
|
||||
#undef make_atomic_fas_body
|
||||
#undef intptr
|
||||
#endif
|
||||
|
||||
/*
|
||||
the macro below defines (as an expression) the code that
|
||||
will be run in spin-loops. Intel manuals recummend to have PAUSE there.
|
||||
|
Reference in New Issue
Block a user