summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2018-05-15 09:34:18 -0400
committerBrian Evans <grknight@gentoo.org>2018-05-15 09:34:18 -0400
commitcc2e5a0cca290d160cb91cb9fd23c2bb2444654f (patch)
treedbeafea56dfc07b72610b7c2e62bb5ab25bb5b66
parentAdd atomic detection patch from Debian (diff)
downloadmysql-extras-cc2e5a0cca290d160cb91cb9fd23c2bb2444654f.tar.gz
mysql-extras-cc2e5a0cca290d160cb91cb9fd23c2bb2444654f.tar.bz2
mysql-extras-cc2e5a0cca290d160cb91cb9fd23c2bb2444654f.zip
Respin atomic patch for mariadb 10.2 and 10.3mysql-extras-20180515-1334Z
-rw-r--r--20035_all_mariadb-10.2-atomic-detection.patch133
-rw-r--r--20035_all_mariadb-10.3-atomic-detection.patch84
2 files changed, 217 insertions, 0 deletions
diff --git a/20035_all_mariadb-10.2-atomic-detection.patch b/20035_all_mariadb-10.2-atomic-detection.patch
new file mode 100644
index 0000000..659e630
--- /dev/null
+++ b/20035_all_mariadb-10.2-atomic-detection.patch
@@ -0,0 +1,133 @@
+10.1 patch borrowed from Debian to make atomic detection easier
+
+10.2 adjustments by Brian Evans <grknight@gentoo.org>
+
+From: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
+Date: Thu, 10 Aug 2017 20:40:29 +0200
+Subject: c11_atomics
+
+---
+ configure.cmake | 23 +++++++++++++++++++++--
+ include/atomic/gcc_builtins.h | 15 +++++++++++++++
+ include/my_atomic.h | 4 ++--
+ mysys/CMakeLists.txt | 4 ++++
+ sql/CMakeLists.txt | 4 ++++
+ 5 files changed, 46 insertions(+), 4 deletions(-)
+
+diff --git a/configure.cmake b/configure.cmake
+index 0057c7f..43ad114 100644
+--- a/configure.cmake
++++ b/configure.cmake
+@@ -128,7 +128,7 @@ IF(UNIX)
+ ENDIF()
+ FIND_PACKAGE(Threads)
+
+- SET(CMAKE_REQUIRED_LIBRARIES
++ LIST(APPEND CMAKE_REQUIRED_LIBRARIES
+ ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBEXECINFO})
+ # Need explicit pthread for gcc -fsanitize=address
+ IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
+@@ -1028,7 +1028,26 @@ ELSEIF(NOT WITH_ATOMIC_OPS)
+ long long int *ptr= &var;
+ return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+ }"
+- HAVE_GCC_C11_ATOMICS)
++ HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
++ IF(HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
++ SET(HAVE_GCC_C11_ATOMICS True)
++ ELSE()
++ SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
++ LIST(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
++ 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_WITH_LIBATOMIC)
++ IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ SET(HAVE_GCC_C11_ATOMICS True)
++ ELSE()
++ SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
++ ENDIF()
++ ENDIF()
+ ELSE()
+ MESSAGE(FATAL_ERROR "${WITH_ATOMIC_OPS} is not a valid value for WITH_ATOMIC_OPS!")
+ ENDIF()
+diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h
+index 56a0323..044be2e 100644
+--- a/include/atomic/gcc_builtins.h
++++ b/include/atomic/gcc_builtins.h
+@@ -16,6 +16,7 @@
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
++#if defined (HAVE_GCC_ATOMIC_BUILTINS)
+ #define make_atomic_add_body(S) \
+ v= __sync_fetch_and_add(a, v);
+ #define make_atomic_fas_body(S) \
+@@ -26,6 +27,20 @@
+ sav= __sync_val_compare_and_swap(a, cmp_val, set);\
+ if (!(ret= (sav == cmp_val))) *cmp= sav
+
++#elif defined(HAVE_GCC_C11_ATOMICS)
++
++#define make_atomic_add_body(S) \
++ v= __atomic_fetch_add(a, v, __ATOMIC_SEQ_CST)
++#define make_atomic_fas_body(S) \
++ v= __atomic_exchange_n(a, v, __ATOMIC_SEQ_CST)
++#define make_atomic_cas_body(S) \
++ int ## S sav; \
++ ret= __atomic_compare_exchange_n(a, cmp, set, \
++ 0, \
++ __ATOMIC_SEQ_CST,\
++ __ATOMIC_SEQ_CST);
++#endif
++
+ #ifdef MY_ATOMIC_MODE_DUMMY
+ #define make_atomic_load_body(S) ret= *a
+ #define make_atomic_store_body(S) *a= v
+diff --git a/include/my_atomic.h b/include/my_atomic.h
+index 2137445..2ad7d98 100644
+--- a/include/my_atomic.h
++++ b/include/my_atomic.h
+@@ -126,7 +126,7 @@
+ #include "atomic/generic-msvc.h"
+ #elif defined(HAVE_SOLARIS_ATOMIC)
+ #include "atomic/solaris.h"
+-#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
++#elif defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_GCC_C11_ATOMICS)
+ #include "atomic/gcc_builtins.h"
+ #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+ #include "atomic/x86-gcc.h"
+diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
+index eb7f75e..a9221d7 100644
+--- a/mysys/CMakeLists.txt
++++ b/mysys/CMakeLists.txt
+@@ -78,6 +78,10 @@ IF(HAVE_BFD_H)
+ TARGET_LINK_LIBRARIES(mysys bfd)
+ ENDIF(HAVE_BFD_H)
+
++IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ TARGET_LINK_LIBRARIES(mysys atomic)
++ENDIF()
++
+ IF (WIN32)
+ TARGET_LINK_LIBRARIES(mysys IPHLPAPI)
+ ENDIF(WIN32)
+diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
+index b4acac5..8247714 100644
+--- a/sql/CMakeLists.txt
++++ b/sql/CMakeLists.txt
+@@ -165,6 +165,10 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
+ ${SSL_LIBRARIES}
+ ${LIBSYSTEMD})
+
++IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ TARGET_LINK_LIBRARIES(sql atomic)
++ENDIF()
++
+ IF(WIN32)
+ SET(MYSQLD_SOURCE main.cc nt_servc.cc message.rc)
+ TARGET_LINK_LIBRARIES(sql psapi)
diff --git a/20035_all_mariadb-10.3-atomic-detection.patch b/20035_all_mariadb-10.3-atomic-detection.patch
new file mode 100644
index 0000000..0f7d522
--- /dev/null
+++ b/20035_all_mariadb-10.3-atomic-detection.patch
@@ -0,0 +1,84 @@
+Original 10.1 patch Borrowed from Debian to make atomic detection easier
+Modified for 10.3 by Brian Evans <grknight@gentoo.org>
+
+From: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
+Date: Thu, 10 Aug 2017 20:40:29 +0200
+Subject: c11_atomics
+
+---
+ configure.cmake | 23 +++++++++++++++++++++--
+ mysys/CMakeLists.txt | 4 ++++
+ sql/CMakeLists.txt | 4 ++++
+ 5 files changed, 46 insertions(+), 4 deletions(-)
+
+diff --git a/configure.cmake b/configure.cmake
+index 0057c7f..43ad114 100644
+--- a/configure.cmake
++++ b/configure.cmake
+@@ -128,7 +128,7 @@ IF(UNIX)
+ ENDIF()
+ FIND_PACKAGE(Threads)
+
+- SET(CMAKE_REQUIRED_LIBRARIES
++ LIST(APPEND CMAKE_REQUIRED_LIBRARIES
+ ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBEXECINFO})
+ # Need explicit pthread for gcc -fsanitize=address
+ IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
+@@ -1028,7 +1028,26 @@ ELSEIF(NOT WITH_ATOMIC_OPS)
+ long long int *ptr= &var;
+ return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+ }"
+-HAVE_GCC_C11_ATOMICS)
++HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
++IF(HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
++ SET(HAVE_GCC_C11_ATOMICS True)
++ELSE()
++ SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
++ LIST(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
++ 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_WITH_LIBATOMIC)
++ IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ SET(HAVE_GCC_C11_ATOMICS True)
++ ELSE()
++ SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
++ ENDIF()
++ENDIF()
+
+ IF(WITH_VALGRIND)
+ SET(HAVE_valgrind 1)
+diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
+index eb7f75e..a9221d7 100644
+--- a/mysys/CMakeLists.txt
++++ b/mysys/CMakeLists.txt
+@@ -78,6 +78,10 @@ IF(HAVE_BFD_H)
+ TARGET_LINK_LIBRARIES(mysys bfd)
+ ENDIF(HAVE_BFD_H)
+
++IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ TARGET_LINK_LIBRARIES(mysys atomic)
++ENDIF()
++
+ IF (WIN32)
+ TARGET_LINK_LIBRARIES(mysys IPHLPAPI)
+ ENDIF(WIN32)
+diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
+index b4acac5..8247714 100644
+--- a/sql/CMakeLists.txt
++++ b/sql/CMakeLists.txt
+@@ -165,6 +165,10 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
+ ${SSL_LIBRARIES}
+ ${LIBSYSTEMD})
+
++IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
++ TARGET_LINK_LIBRARIES(sql atomic)
++ENDIF()
++
+ IF(WIN32)
+ SET(MYSQLD_SOURCE main.cc nt_servc.cc message.rc)
+ TARGET_LINK_LIBRARIES(sql psapi)