#At file:///home/mikael/mysql_clones/intel_atomics/
2847 Mikael Ronstrom 2009-05-08
Introduce atomics for Intel compiler
modified:
configure.in
storage/innobase/include/os0sync.ic
storage/innobase/include/univ.i
=== modified file 'configure.in'
--- a/configure.in 2009-02-23 23:37:08 +0000
+++ b/configure.in 2009-05-08 13:44:08 +0000
@@ -1805,6 +1805,32 @@ if test "x$mysql_cv_solaris_atomic" = xy
[Define to 1 if OS provides atomic_* functions like Solaris.])
fi
+AC_CACHE_CHECK([whether the compiler provides atomic builtins],
+ [mysql_cv_icc_atomic_builtins], [AC_TRY_RUN([
+ int main()
+ {
+ long var32 = 0;
+ long add32 = 1;
+ long old32 = 0;
+ long exch32 = 1;
+ long ret_value1, ret_value2;
+
+ ret_value1 = _InterlockedExchangeAdd(&var32, add32);
+ ret_value2 = _InterlockedCompareExchange(&var32, exch32, old32);
+
+ __memory_barrier();
+
+ return (ret_value1 + ret_value2 - 1);
+ }
+], [mysql_cv_icc_atomic_builtins=yes],
+ [mysql_cv_icc_atomic_builtins=no],
+ [mysql_cv_icc_atomic_builtins=no])])
+
+if test "x$mysql_cv_icc_atomic_builtins" = xyes; then
+ AC_DEFINE(HAVE_ICC_ATOMIC_BUILTINS, 1,
+ [Define to 1 if compiler provides Intel compiler atomic builtins.])
+fi
+
# Force static compilation to avoid linking problems/get more speed
AC_ARG_WITH(mysqld-ldflags,
[ --with-mysqld-ldflags Extra linking arguments for mysqld],
=== modified file 'storage/innobase/include/os0sync.ic'
--- a/storage/innobase/include/os0sync.ic 2009-03-06 18:25:38 +0000
+++ b/storage/innobase/include/os0sync.ic 2009-05-08 13:44:08 +0000
@@ -70,6 +70,10 @@ os_compare_and_swap(
#elif WIN_ATOMICS64
lint retVal = (lint)InterlockedCompareExchange64(ptr, newVal, oldVal);
return (retVal == oldVal);
+#elif HAVE_ICC_ATOMIC_BUILTINS
+ lint retVal = (lint)_Interlocked_CompareExchange((void*)ptr,
+ newVal, oldVal);
+ return (retVal == oldVal);
#else
#error "Need support for atomic ops"
#endif
@@ -89,6 +93,8 @@ os_memory_barrier_load()
MemoryBarrier();
#elif WIN_ATOMICS64
MemoryBarrier();
+#elif HAVE_ICC_ATOMIC_BUILTINS
+ __memory_barrier();
#endif
}
@@ -106,6 +112,8 @@ os_memory_barrier_store()
MemoryBarrier();
#elif WIN_ATOMICS64
MemoryBarrier();
+#elif HAVE_ICC_ATOMIC_BUILTINS
+ __memory_barrier();
#endif
}
@@ -123,6 +131,8 @@ os_memory_barrier()
MemoryBarrier();
#elif WIN_ATOMICS64
MemoryBarrier();
+#elif HAVE_ICC_ATOMIC_BUILTINS
+ __memory_barrier();
#endif
}
@@ -145,6 +155,8 @@ os_atomic_increment(
return ((lint)InterlockedExchangeAdd(ptr, amount));
#elif WIN_ATOMICS64
return ((lint)InterlockedExchangeAdd64(ptr, amount));
+#elif HAVE_ICC_ATOMIC_BUILTINS
+ return ((lint)_InterlockedExchangeAdd((void*)ptr, amount));
#else
#error "Need support for atomic ops"
#endif
=== modified file 'storage/innobase/include/univ.i'
--- a/storage/innobase/include/univ.i 2009-03-06 18:25:38 +0000
+++ b/storage/innobase/include/univ.i 2009-05-08 13:44:08 +0000
@@ -137,7 +137,7 @@ by one. */
/* Use malloc instead of innodb additional memory pool (great with tcmalloc) */
#define UNIV_DISABLE_MEM_POOL
-#if defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_SOLARIS_ATOMIC)
+#if defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_SOLARIS_ATOMIC) ||
defined(HAVE_ICC_ATOMIC_BUILTINS)
/*
* We have a full set of atomic ops available - we will use them
*/
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (mikael:2847) | Mikael Ronstrom | 11 May 2009 |