Commit 1e9d7900 authored by Mikael Ronstrom's avatar Mikael Ronstrom

merge my-atomic patch

parents 1401d2e8 52795226
......@@ -1753,6 +1753,32 @@ if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
[Define to 1 if compiler provides atomic builtins.])
fi
AC_CACHE_CHECK([whether the OS provides atomic_* functions like Solaris],
[mysql_cv_solaris_atomic], [AC_TRY_RUN([
#include <atomic.h>
int
main()
{
int foo = -10; int bar = 10;
if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
return -1;
bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
if (bar || foo != 10)
return -1;
bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
if (bar)
return -1;
return 0;
}
], [mysql_cv_solaris_atomic=yes],
[mysql_cv_solaris_atomic=no],
[mysql_cv_solaris_atomic=no])])
if test "x$mysql_cv_solaris_atomic" = xyes; then
AC_DEFINE(HAVE_SOLARIS_ATOMIC, 1,
[Define to 1 if OS provides atomic_* functions like Solaris.])
fi
# Force static compilation to avoid linking problems/get more speed
AC_ARG_WITH(mysqld-ldflags,
[ --with-mysqld-ldflags Extra linking arguments for mysqld],
......
......@@ -28,11 +28,28 @@
#elif defined(_MSC_VER)
#include "x86-msvc.h"
#endif
#endif
#ifdef make_atomic_cas_body
#elif defined(HAVE_SOLARIS_ATOMIC)
#include "solaris.h"
#endif /* __i386__ || _M_IX86 || HAVE_GCC_ATOMIC_BUILTINS */
#if defined(make_atomic_cas_body) || defined(MY_ATOMICS_MADE)
/*
* We have atomics that require no locking
*/
#define MY_ATOMIC_NOLOCK
#ifdef __SUNPRO_C
/*
* Sun Studio 12 (and likely earlier) does not accept a typedef struct {}
*/
typedef char my_atomic_rwlock_t;
#else
typedef struct { } my_atomic_rwlock_t;
#endif
#define my_atomic_rwlock_destroy(name)
#define my_atomic_rwlock_init(name)
#define my_atomic_rwlock_rdlock(name)
......
......@@ -18,13 +18,21 @@
#define intptr void *
#ifndef MY_ATOMIC_MODE_RWLOCKS
/*
* Attempt to do atomic ops without locks
*/
#include "atomic/nolock.h"
#endif
#ifndef make_atomic_cas_body
#ifndef MY_ATOMIC_NOLOCK
/*
* Have to use rw-locks for atomic ops
*/
#include "atomic/rwlock.h"
#endif
#ifndef MY_ATOMICS_MADE
#ifndef make_atomic_add_body
#define make_atomic_add_body(S) \
int ## S tmp=*a; \
......@@ -91,7 +99,7 @@ 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
#endif /* HAVE_INLINE */
make_atomic_cas( 8)
make_atomic_cas(16)
......@@ -129,6 +137,8 @@ make_atomic_swap(ptr)
#undef make_atomic_swap_body
#undef intptr
#endif /* MY_ATOMICS_MADE */
#ifdef _atomic_h_cleanup_
#include _atomic_h_cleanup_
#undef _atomic_h_cleanup_
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment