mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-11212 - Clean-up MariaDB atomic operations
Removed MY_ATOMIC_MODE_DUMMY and WITH_ATOMIC_OPS: MariaDB is not functional without atomic operations anymore.
This commit is contained in:
parent
bb9928160f
commit
8ff3b892ae
6 changed files with 33 additions and 74 deletions
|
@ -388,7 +388,6 @@
|
|||
|
||||
#cmakedefine HAVE_SOLARIS_STYLE_GETHOST 1
|
||||
|
||||
#cmakedefine MY_ATOMIC_MODE_DUMMY 1
|
||||
#cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1
|
||||
#cmakedefine HAVE_GCC_C11_ATOMICS 1
|
||||
#cmakedefine HAVE_SOLARIS_ATOMIC 1
|
||||
|
|
|
@ -908,48 +908,38 @@ SET(SIGNAL_WITH_VIO_CLOSE 1)
|
|||
MARK_AS_ADVANCED(NO_ALARM)
|
||||
|
||||
|
||||
IF(WITH_ATOMIC_OPS STREQUAL "up")
|
||||
SET(MY_ATOMIC_MODE_DUMMY 1 CACHE BOOL "Assume single-CPU mode, no concurrency")
|
||||
ELSEIF(WITH_ATOMIC_OPS STREQUAL "smp")
|
||||
ELSEIF(NOT WITH_ATOMIC_OPS)
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main()
|
||||
{
|
||||
int foo= -10; int bar= 10;
|
||||
long long int foo64= -10; long long int bar64= 10;
|
||||
if (!__sync_fetch_and_add(&foo, bar) || foo)
|
||||
return -1;
|
||||
bar= __sync_lock_test_and_set(&foo, bar);
|
||||
if (bar || foo != 10)
|
||||
return -1;
|
||||
bar= __sync_val_compare_and_swap(&bar, foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
|
||||
return -1;
|
||||
bar64= __sync_lock_test_and_set(&foo64, bar64);
|
||||
if (bar64 || foo64 != 10)
|
||||
return -1;
|
||||
bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
|
||||
if (bar64)
|
||||
return -1;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_GCC_ATOMIC_BUILTINS)
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main()
|
||||
{
|
||||
long long int var= 1;
|
||||
long long int *ptr= &var;
|
||||
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
||||
}"
|
||||
HAVE_GCC_C11_ATOMICS)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "${WITH_ATOMIC_OPS} is not a valid value for WITH_ATOMIC_OPS!")
|
||||
ENDIF()
|
||||
|
||||
SET(WITH_ATOMIC_OPS "${WITH_ATOMIC_OPS}" CACHE STRING "Implement atomic operations using atomic CPU instructions for multi-processor (smp) or uniprocessor (up) configuration. By default gcc built-in sync functions are used, if available and 'smp' configuration otherwise.")
|
||||
MARK_AS_ADVANCED(WITH_ATOMIC_OPS MY_ATOMIC_MODE_DUMMY)
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main()
|
||||
{
|
||||
int foo= -10; int bar= 10;
|
||||
long long int foo64= -10; long long int bar64= 10;
|
||||
if (!__sync_fetch_and_add(&foo, bar) || foo)
|
||||
return -1;
|
||||
bar= __sync_lock_test_and_set(&foo, bar);
|
||||
if (bar || foo != 10)
|
||||
return -1;
|
||||
bar= __sync_val_compare_and_swap(&bar, foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
|
||||
return -1;
|
||||
bar64= __sync_lock_test_and_set(&foo64, bar64);
|
||||
if (bar64 || foo64 != 10)
|
||||
return -1;
|
||||
bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
|
||||
if (bar64)
|
||||
return -1;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_GCC_ATOMIC_BUILTINS)
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main()
|
||||
{
|
||||
long long int var= 1;
|
||||
long long int *ptr= &var;
|
||||
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
||||
}"
|
||||
HAVE_GCC_C11_ATOMICS)
|
||||
|
||||
IF(WITH_VALGRIND)
|
||||
SET(HAVE_valgrind 1)
|
||||
|
|
|
@ -26,12 +26,7 @@
|
|||
sav= __sync_val_compare_and_swap(a, cmp_val, set);\
|
||||
if (!(ret= (sav == cmp_val))) *cmp= sav
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_DUMMY
|
||||
#define make_atomic_load_body(S) ret= *a
|
||||
#define make_atomic_store_body(S) *a= v
|
||||
#define MY_ATOMIC_MODE "gcc-builtins-up"
|
||||
|
||||
#elif defined(HAVE_GCC_C11_ATOMICS)
|
||||
#if defined(HAVE_GCC_C11_ATOMICS)
|
||||
#define MY_ATOMIC_MODE "gcc-atomics-smp"
|
||||
#define make_atomic_load_body(S) \
|
||||
ret= __atomic_load_n(a, __ATOMIC_SEQ_CST)
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
#ifndef _atomic_h_cleanup_
|
||||
#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
|
||||
|
||||
/*
|
||||
We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
|
||||
intrinsics.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
/*
|
||||
x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
|
||||
|
|
|
@ -45,21 +45,12 @@
|
|||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_DUMMY
|
||||
|
||||
#define make_atomic_load_body(S) ret= *a
|
||||
#define make_atomic_store_body(S) *a= v
|
||||
|
||||
#else /* MY_ATOMIC_MODE_DUMMY */
|
||||
|
||||
#define make_atomic_load_body(S) \
|
||||
ret= atomic_or_ ## S ## _nv((volatile uint ## S ## _t *)a, 0)
|
||||
|
||||
#define make_atomic_store_body(S) \
|
||||
(void) atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
|
||||
|
||||
#endif
|
||||
|
||||
#define make_atomic_fas_body(S) \
|
||||
v= atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
|
||||
|
||||
|
|
|
@ -31,17 +31,6 @@
|
|||
#include "pfs_user.h"
|
||||
#include "pfs_account.h"
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_DUMMY
|
||||
/*
|
||||
The performance schema can can not function with MY_ATOMIC_MODE_DUMMY,
|
||||
a fully functional implementation of MY_ATOMIC should be used instead.
|
||||
If the build fails with this error message:
|
||||
- either use a different ./configure --with-atomic-ops option
|
||||
- or do not build with the performance schema.
|
||||
*/
|
||||
#error "The performance schema needs a functional MY_ATOMIC implementation."
|
||||
#endif
|
||||
|
||||
handlerton *pfs_hton= NULL;
|
||||
|
||||
static handler* pfs_create_handler(handlerton *hton,
|
||||
|
|
Loading…
Reference in a new issue