diff -Nru mysql-5.7-5.7.11/debian/changelog mysql-5.7-5.7.11/debian/changelog --- mysql-5.7-5.7.11/debian/changelog 2016-03-17 14:35:45.000000000 +0000 +++ mysql-5.7-5.7.11/debian/changelog 2016-03-23 07:37:18.000000000 +0000 @@ -1,3 +1,14 @@ +mysql-5.7 (5.7.11-0ubuntu2) xenial; urgency=medium + + * debian/rules: Use the system libevent, not the bundled version. + * debian/control: Limit libnuma build-dep to arches that have it. + * debian/patches/mysql-atomic.patch: Patch from upstream to add + support for __atomic builtins and prefer __sync where available. + * debian/patches/mysql-atomic-link.patch: Link atomic when needed. + * debian/patches/mysql-atomic-innodb.patch: Update innodb atomics. + + -- Adam Conrad Mon, 21 Mar 2016 18:14:50 -0600 + mysql-5.7 (5.7.11-0ubuntu1) xenial; urgency=medium * Ubuntu upload from Debian VCS 10798b9. diff -Nru mysql-5.7-5.7.11/debian/control mysql-5.7-5.7.11/debian/control --- mysql-5.7-5.7.11/debian/control 2016-03-17 14:35:45.000000000 +0000 +++ mysql-5.7-5.7.11/debian/control 2016-03-22 00:36:58.000000000 +0000 @@ -19,7 +19,7 @@ libevent-dev, liblz4-dev, libncurses5-dev (>= 5.0-6), - libnuma-dev, + libnuma-dev [amd64 arm64 i386 mips mips64el mipsel powerpc ppc64el], libwrap0-dev (>= 7.6-8.3), lsb-release, perl, diff -Nru mysql-5.7-5.7.11/debian/patches/mysql-atomic-innodb.patch mysql-5.7-5.7.11/debian/patches/mysql-atomic-innodb.patch --- mysql-5.7-5.7.11/debian/patches/mysql-atomic-innodb.patch 1970-01-01 00:00:00.000000000 +0000 +++ mysql-5.7-5.7.11/debian/patches/mysql-atomic-innodb.patch 2016-03-23 06:36:02.000000000 +0000 @@ -0,0 +1,145 @@ +commit 79977252890749571132e4654f9a4873eff722c3 +Author: Norvald H. Ryeng +Date: Wed Mar 23 01:34:52 2016 +0100 + + Add __atomic alternative to __sync in InnoDB + + Most InnoDB atomic operations have an alternative to __sync + operations, but ifdef checks are for HAVE_GCC_ATOMIC_BUILTINS + instead of HAVE_GCC_SYNC_BUILTINS. Change it to SYNC. + + Add an alternative implementation using __atomic where missing. + +diff --git a/plugin/innodb_memcached/daemon_memcached/daemon/memcached.c b/plugin/innodb_memcached/daemon_memcached/daemon/memcached.c +index 26213dd..4478238 100644 +--- a/plugin/innodb_memcached/daemon_memcached/daemon/memcached.c ++++ b/plugin/innodb_memcached/daemon_memcached/daemon/memcached.c +@@ -89,7 +89,7 @@ static inline void item_set_cas(const void *cookie, item *it, uint64_t cas) { + #define STATS_MISS(conn, op, key, nkey) \ + STATS_TWO(conn, op##_misses, cmd_##op, key, nkey) + +-#if defined(HAVE_GCC_ATOMIC_BUILTINS) ++#if defined(HAVE_GCC_SYNC_BUILTINS) + + #define STATS_NOKEY(conn, op) \ + do { \ +@@ -115,7 +115,7 @@ do { \ + + #define MEMCACHED_ATOMIC_MSG "InnoDB MEMCACHED: Memcached uses atomic increment \n" + +-#else /* HAVE_GCC_ATOMIC_BUILTINS */ ++#else /* HAVE_GCC_SYNC_BUILTINS */ + #define STATS_NOKEY(conn, op) { \ + struct thread_stats *thread_stats = \ + get_thread_stats(conn); \ +@@ -142,7 +142,7 @@ do { \ + } + + #define MEMCACHED_ATOMIC_MSG "InnoDB Memcached: Memcached DOES NOT use atomic increment" +-#endif /* HAVE_GCC_ATOMIC_BUILTINS */ ++#endif /* HAVE_GCC_SYNC_BUILTINS */ + + volatile sig_atomic_t memcached_shutdown; + volatile sig_atomic_t memcached_initialized; +diff --git a/plugin/innodb_memcached/innodb_memcache/src/innodb_api.c b/plugin/innodb_memcached/innodb_memcache/src/innodb_api.c +index a33f8d0..5b90e2b 100644 +--- a/plugin/innodb_memcached/innodb_memcache/src/innodb_api.c ++++ b/plugin/innodb_memcached/innodb_memcache/src/innodb_api.c +@@ -938,7 +938,7 @@ mci_get_cas( + { + static uint64_t cas_id = 0; + +-#if defined(HAVE_GCC_ATOMIC_BUILTINS) ++#if defined(HAVE_GCC_SYNC_BUILTINS) + return(__sync_add_and_fetch(&cas_id, 1)); + #else + pthread_mutex_lock(&eng->cas_mutex); +diff --git a/storage/innobase/include/os0atomic.h b/storage/innobase/include/os0atomic.h +index 1368176..1095789 100644 +--- a/storage/innobase/include/os0atomic.h ++++ b/storage/innobase/include/os0atomic.h +@@ -208,6 +208,8 @@ amount to decrement. There is no atomic substract function on Windows */ + Returns true if swapped, ptr is pointer to target, old_val is value to + compare to, new_val is the value to swap in. */ + ++#if defined(HAVE_GCC_SYNC_BUILTINS) ++ + # define os_compare_and_swap(ptr, old_val, new_val) \ + __sync_bool_compare_and_swap(ptr, old_val, new_val) + +@@ -220,9 +222,47 @@ compare to, new_val is the value to swap in. */ + # define os_compare_and_swap_uint32(ptr, old_val, new_val) \ + os_compare_and_swap(ptr, old_val, new_val) + ++#else ++ ++UNIV_INLINE ++bool ++os_compare_and_swap_ulint(volatile ulint* ptr, ulint old_val, ulint new_val) ++{ ++ return __atomic_compare_exchange_n(ptr, &old_val, new_val, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++ ++UNIV_INLINE ++bool ++os_compare_and_swap_lint(volatile lint* ptr, lint old_val, lint new_val) ++{ ++ return __atomic_compare_exchange_n(ptr, &old_val, new_val, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++ ++UNIV_INLINE ++bool ++os_compare_and_swap_uint32(volatile ib_uint32_t* ptr, ib_uint32_t old_val, ib_uint32_t new_val) ++{ ++ return __atomic_compare_exchange_n(ptr, &old_val, new_val, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++ ++#endif /* HAVE_GCC_SYNC_BUILTINS */ ++ + # ifdef HAVE_IB_ATOMIC_PTHREAD_T_GCC ++#if defined(HAVE_GCC_SYNC_BUILTINS) + # define os_compare_and_swap_thread_id(ptr, old_val, new_val) \ + os_compare_and_swap(ptr, old_val, new_val) ++#else ++UNIV_INLINE ++bool ++os_compare_and_swap_thread_id(volatile os_thread_id_t* ptr, os_thread_id_t old_val, os_thread_id_t new_val) ++{ ++ return __atomic_compare_exchange_n(ptr, &old_val, new_val, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++#endif /* HAVE_GCC_SYNC_BUILTINS */ + # define INNODB_RW_LOCKS_USE_ATOMICS + # define IB_ATOMICS_STARTUP_MSG \ + "Mutexes and rw_locks use GCC atomic builtins" +@@ -235,8 +275,13 @@ compare to, new_val is the value to swap in. */ + Returns the resulting value, ptr is pointer to target, amount is the + amount of increment. */ + ++#if defined(HAVE_GCC_SYNC_BUILTINS) + # define os_atomic_increment(ptr, amount) \ + __sync_add_and_fetch(ptr, amount) ++#else ++# define os_atomic_increment(ptr, amount) \ ++ __atomic_add_fetch(ptr, amount, __ATOMIC_SEQ_CST) ++#endif /* HAVE_GCC_SYNC_BUILTINS */ + + # define os_atomic_increment_lint(ptr, amount) \ + os_atomic_increment(ptr, amount) +@@ -253,8 +298,13 @@ amount of increment. */ + /* Returns the resulting value, ptr is pointer to target, amount is the + amount to decrement. */ + ++#if defined(HAVE_GCC_SYNC_BUILTINS) + # define os_atomic_decrement(ptr, amount) \ + __sync_sub_and_fetch(ptr, amount) ++#else ++# define os_atomic_decrement(ptr, amount) \ ++ __atomic_sub_fetch(ptr, amount, __ATOMIC_SEQ_CST) ++#endif /* HAVE_GCC_SYNC_BUILTINS */ + + # define os_atomic_decrement_lint(ptr, amount) \ + os_atomic_decrement(ptr, amount) diff -Nru mysql-5.7-5.7.11/debian/patches/mysql-atomic-link.patch mysql-5.7-5.7.11/debian/patches/mysql-atomic-link.patch --- mysql-5.7-5.7.11/debian/patches/mysql-atomic-link.patch 1970-01-01 00:00:00.000000000 +0000 +++ mysql-5.7-5.7.11/debian/patches/mysql-atomic-link.patch 2016-03-22 22:04:33.000000000 +0000 @@ -0,0 +1,36 @@ +commit f6b5ca72c646e60d3a370eccd7847e624aa17b26 +Author: Norvald H. Ryeng +Date: Tue Mar 22 19:49:46 2016 +0100 + + Link with libatomic when necessary + + When lock free instructions are not available, GCC will expect + them to be implemented by an atomics library. Check if __sync or + __atomic symbols are implemented by a library and link with it if + they are. + + The symbols used in the checks are chosen randomly. If some + operations are built in and others are implemented by libatomic, + it may be that just these symbols happen to be built in. In that + case, more checks should be added for symbols that aren't built + in. + +diff --git a/configure.cmake b/configure.cmake +index 32829f9..1a2df09 100644 +--- a/configure.cmake ++++ b/configure.cmake +@@ -314,9 +314,13 @@ IF(UNIX) + MY_SEARCH_LIBS(clock_gettime rt LIBRT) + ENDIF() + MY_SEARCH_LIBS(timer_create rt LIBRT) ++ MY_SEARCH_LIBS(__sync_fetch_and_add_8 atomic LIBATOMIC) ++ IF(NOT LIBATOMIC) ++ MY_SEARCH_LIBS(__atomic_load_8 atomic LIBATOMIC) ++ ENDIF() + + SET(CMAKE_REQUIRED_LIBRARIES +- ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT}) ++ ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBATOMIC}) + # Need explicit pthread for gcc -fsanitize=address + IF(CMAKE_C_FLAGS MATCHES "-fsanitize=") + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread) diff -Nru mysql-5.7-5.7.11/debian/patches/mysql-atomic.patch mysql-5.7-5.7.11/debian/patches/mysql-atomic.patch --- mysql-5.7-5.7.11/debian/patches/mysql-atomic.patch 1970-01-01 00:00:00.000000000 +0000 +++ mysql-5.7-5.7.11/debian/patches/mysql-atomic.patch 2016-03-22 22:04:20.000000000 +0000 @@ -0,0 +1,430 @@ +commit 4f9294bf74ed27eae7a2bf2eea82808c5069c374 +Author: Norvald H. Ryeng +Date: Tue Mar 22 17:58:19 2016 +0100 + + Add support for GCC __atomic builtins + + MySQL 5.7 upstream uses GCC __sync builtins, but they aren't + defined on all platforms, GCC 5.3.1 on powerpc being one + exception. GCC 4.7 introduced __atomic builtins. Add support for + GCC __atomic builtins, but prefer __sync builtins if they exist. + +diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake +index 6d594c6..ee4ef1f 100644 +--- a/cmake/os/WindowsCache.cmake ++++ b/cmake/os/WindowsCache.cmake +@@ -210,6 +210,7 @@ SET(HAVE_BUILTIN_UNREACHABLE CACHE INTERNAL "") + SET(HAVE_BUILTIN_EXPECT CACHE INTERNAL "") + SET(HAVE_BUILTIN_STPCPY CACHE INTERNAL "") + SET(HAVE_GCC_ATOMIC_BUILTINS CACHE INTERNAL "") ++SET(HAVE_GCC_SYNC_BUILTINS CACHE INTERNAL "") + # Derived result HAVE_VALGRIND + + # IPV6 +diff --git a/config.h.cmake b/config.h.cmake +index 8916660..79ed19f 100644 +--- a/config.h.cmake ++++ b/config.h.cmake +@@ -195,6 +195,7 @@ + #cmakedefine HAVE_BUILTIN_EXPECT 1 + #cmakedefine HAVE_BUILTIN_STPCPY 1 + #cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1 ++#cmakedefine HAVE_GCC_SYNC_BUILTINS 1 + #cmakedefine HAVE_VALGRIND + + /* IPV6 */ +diff --git a/configure.cmake b/configure.cmake +index 5b5ea36..32829f9 100644 +--- a/configure.cmake ++++ b/configure.cmake +@@ -719,6 +719,33 @@ CHECK_CXX_SOURCE_COMPILES(" + { + int foo= -10; int bar= 10; + long long int foo64= -10; long long int bar64= 10; ++ if (!__atomic_fetch_add(&foo, bar, __ATOMIC_SEQ_CST) || foo) ++ return -1; ++ bar= __atomic_exchange_n(&foo, bar, __ATOMIC_SEQ_CST); ++ if (bar || foo != 10) ++ return -1; ++ bar= __atomic_compare_exchange_n(&bar, &foo, 15, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++ if (bar) ++ return -1; ++ if (!__atomic_fetch_add(&foo64, bar64, __ATOMIC_SEQ_CST) || foo64) ++ return -1; ++ bar64= __atomic_exchange_n(&foo64, bar64, __ATOMIC_SEQ_CST); ++ if (bar64 || foo64 != 10) ++ return -1; ++ bar64= __atomic_compare_exchange_n(&bar64, &foo64, 15, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++ if (bar64) ++ return -1; ++ return 0; ++ }" ++ HAVE_GCC_ATOMIC_BUILTINS) ++ ++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); +@@ -737,7 +764,7 @@ CHECK_CXX_SOURCE_COMPILES(" + return -1; + return 0; + }" +- HAVE_GCC_ATOMIC_BUILTINS) ++ HAVE_GCC_SYNC_BUILTINS) + + IF(WITH_VALGRIND) + SET(VALGRIND_HEADERS "valgrind/memcheck.h;valgrind/valgrind.h") +diff --git a/include/atomic/gcc_atomic.h b/include/atomic/gcc_atomic.h +new file mode 100644 +index 0000000..73e3682 +--- /dev/null ++++ b/include/atomic/gcc_atomic.h +@@ -0,0 +1,94 @@ ++#ifndef GCC_ATOMIC_INCLUDED ++#define GCC_ATOMIC_INCLUDED ++ ++/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; version 2 of the License. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ++ ++/* New GCC __atomic builtins introduced in GCC 4.7 */ ++ ++static inline int my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set) ++{ ++ return __atomic_compare_exchange_n(a, cmp, set, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++ ++static inline int my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set) ++{ ++ return __atomic_compare_exchange_n(a, cmp, set, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++ ++static inline int my_atomic_casptr(void * volatile *a, void **cmp, void *set) ++{ ++ return __atomic_compare_exchange_n(a, cmp, set, 0, ++ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ++} ++ ++static inline int32 my_atomic_add32(int32 volatile *a, int32 v) ++{ ++ return __atomic_fetch_add(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline int64 my_atomic_add64(int64 volatile *a, int64 v) ++{ ++ return __atomic_fetch_add(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline int32 my_atomic_fas32(int32 volatile *a, int32 v) ++{ ++ return __atomic_exchange_n(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline int64 my_atomic_fas64(int64 volatile *a, int64 v) ++{ ++ return __atomic_exchange_n(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline void * my_atomic_fasptr(void * volatile *a, void * v) ++{ ++ return __atomic_exchange_n(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline int32 my_atomic_load32(int32 volatile *a) ++{ ++ return __atomic_load_n(a, __ATOMIC_SEQ_CST); ++} ++ ++static inline int64 my_atomic_load64(int64 volatile *a) ++{ ++ return __atomic_load_n(a, __ATOMIC_SEQ_CST); ++} ++ ++static inline void* my_atomic_loadptr(void * volatile *a) ++{ ++ return __atomic_load_n(a, __ATOMIC_SEQ_CST); ++} ++ ++static inline void my_atomic_store32(int32 volatile *a, int32 v) ++{ ++ __atomic_store_n(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline void my_atomic_store64(int64 volatile *a, int64 v) ++{ ++ __atomic_store_n(a, v, __ATOMIC_SEQ_CST); ++} ++ ++static inline void my_atomic_storeptr(void * volatile *a, void *v) ++{ ++ __atomic_store_n(a, v, __ATOMIC_SEQ_CST); ++} ++ ++#endif /* GCC_ATOMIC_INCLUDED */ +diff --git a/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h +deleted file mode 100644 +index 9e868f9..0000000 +--- a/include/atomic/gcc_builtins.h ++++ /dev/null +@@ -1,104 +0,0 @@ +-#ifndef ATOMIC_GCC_BUILTINS_INCLUDED +-#define ATOMIC_GCC_BUILTINS_INCLUDED +- +-/* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. +- +- This program is free software; you can redistribute it and/or modify +- it under the terms of the GNU General Public License as published by +- the Free Software Foundation; version 2 of the License. +- +- This program is distributed in the hope that it will be useful, +- but WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- GNU General Public License for more details. +- +- You should have received a copy of the GNU General Public License +- along with this program; if not, write to the Free Software +- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +- +-static inline int my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set) +-{ +- int32 cmp_val= *cmp; +- int32 sav= __sync_val_compare_and_swap(a, cmp_val, set); +- int ret= (sav == cmp_val); +- if (!ret) +- *cmp = sav; +- return ret; +-} +- +-static inline int my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set) +-{ +- int64 cmp_val= *cmp; +- int64 sav= __sync_val_compare_and_swap(a, cmp_val, set); +- int ret= (sav == cmp_val); +- if (!ret) +- *cmp = sav; +- return ret; +-} +- +-static inline int my_atomic_casptr(void * volatile *a, void **cmp, void *set) +-{ +- void *cmp_val= *cmp; +- void *sav= __sync_val_compare_and_swap(a, cmp_val, set); +- int ret= (sav == cmp_val); +- if (!ret) +- *cmp = sav; +- return ret; +-} +- +-static inline int32 my_atomic_add32(int32 volatile *a, int32 v) +-{ +- return __sync_fetch_and_add(a, v); +-} +- +-static inline int64 my_atomic_add64(int64 volatile *a, int64 v) +-{ +- return __sync_fetch_and_add(a, v); +-} +- +-static inline int32 my_atomic_fas32(int32 volatile *a, int32 v) +-{ +- return __sync_lock_test_and_set(a, v); +-} +- +-static inline int64 my_atomic_fas64(int64 volatile *a, int64 v) +-{ +- return __sync_lock_test_and_set(a, v); +-} +- +-static inline void * my_atomic_fasptr(void * volatile *a, void * v) +-{ +- return __sync_lock_test_and_set(a, v); +-} +- +-static inline int32 my_atomic_load32(int32 volatile *a) +-{ +- return __sync_fetch_and_or(a, 0); +-} +- +-static inline int64 my_atomic_load64(int64 volatile *a) +-{ +- return __sync_fetch_and_or(a, 0); +-} +- +-static inline void* my_atomic_loadptr(void * volatile *a) +-{ +- return __sync_fetch_and_or(a, 0); +-} +- +-static inline void my_atomic_store32(int32 volatile *a, int32 v) +-{ +- (void) __sync_lock_test_and_set(a, v); +-} +- +-static inline void my_atomic_store64(int64 volatile *a, int64 v) +-{ +- (void) __sync_lock_test_and_set(a, v); +-} +- +-static inline void my_atomic_storeptr(void * volatile *a, void *v) +-{ +- (void) __sync_lock_test_and_set(a, v); +-} +- +-#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */ +diff --git a/include/atomic/gcc_sync.h b/include/atomic/gcc_sync.h +new file mode 100644 +index 0000000..d71fb6b +--- /dev/null ++++ b/include/atomic/gcc_sync.h +@@ -0,0 +1,106 @@ ++#ifndef GCC_SYNC_INCLUDED ++#define GCC_SYNC_INCLUDED ++ ++/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; version 2 of the License. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ++ ++/* Old GCC __sync builtins introduced in GCC 4.1 */ ++ ++static inline int my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set) ++{ ++ int32 cmp_val= *cmp; ++ int32 sav= __sync_val_compare_and_swap(a, cmp_val, set); ++ int ret= (sav == cmp_val); ++ if (!ret) ++ *cmp = sav; ++ return ret; ++} ++ ++static inline int my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set) ++{ ++ int64 cmp_val= *cmp; ++ int64 sav= __sync_val_compare_and_swap(a, cmp_val, set); ++ int ret= (sav == cmp_val); ++ if (!ret) ++ *cmp = sav; ++ return ret; ++} ++ ++static inline int my_atomic_casptr(void * volatile *a, void **cmp, void *set) ++{ ++ void *cmp_val= *cmp; ++ void *sav= __sync_val_compare_and_swap(a, cmp_val, set); ++ int ret= (sav == cmp_val); ++ if (!ret) ++ *cmp = sav; ++ return ret; ++} ++ ++static inline int32 my_atomic_add32(int32 volatile *a, int32 v) ++{ ++ return __sync_fetch_and_add(a, v); ++} ++ ++static inline int64 my_atomic_add64(int64 volatile *a, int64 v) ++{ ++ return __sync_fetch_and_add(a, v); ++} ++ ++static inline int32 my_atomic_fas32(int32 volatile *a, int32 v) ++{ ++ return __sync_lock_test_and_set(a, v); ++} ++ ++static inline int64 my_atomic_fas64(int64 volatile *a, int64 v) ++{ ++ return __sync_lock_test_and_set(a, v); ++} ++ ++static inline void * my_atomic_fasptr(void * volatile *a, void * v) ++{ ++ return __sync_lock_test_and_set(a, v); ++} ++ ++static inline int32 my_atomic_load32(int32 volatile *a) ++{ ++ return __sync_fetch_and_or(a, 0); ++} ++ ++static inline int64 my_atomic_load64(int64 volatile *a) ++{ ++ return __sync_fetch_and_or(a, 0); ++} ++ ++static inline void* my_atomic_loadptr(void * volatile *a) ++{ ++ return __sync_fetch_and_or(a, 0); ++} ++ ++static inline void my_atomic_store32(int32 volatile *a, int32 v) ++{ ++ (void) __sync_lock_test_and_set(a, v); ++} ++ ++static inline void my_atomic_store64(int64 volatile *a, int64 v) ++{ ++ (void) __sync_lock_test_and_set(a, v); ++} ++ ++static inline void my_atomic_storeptr(void * volatile *a, void *v) ++{ ++ (void) __sync_lock_test_and_set(a, v); ++} ++ ++#endif /* GCC_SYNC_INCLUDED */ +diff --git a/include/my_atomic.h b/include/my_atomic.h +index 8cde9cb..dc74225 100644 +--- a/include/my_atomic.h ++++ b/include/my_atomic.h +@@ -1,7 +1,7 @@ + #ifndef MY_ATOMIC_INCLUDED + #define MY_ATOMIC_INCLUDED + +-/* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. ++/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +@@ -56,8 +56,10 @@ + # include "atomic/generic-msvc.h" + #elif defined(HAVE_SOLARIS_ATOMIC) + # include "atomic/solaris.h" +-#elif defined(HAVE_GCC_ATOMIC_BUILTINS) +-# include "atomic/gcc_builtins.h" ++#elif defined(HAVE_GCC_SYNC_BUILTINS) /* Upstream uses __sync */ ++# include "atomic/gcc_sync.h" ++#elif defined(HAVE_GCC_ATOMIC_BUILTINS) /* Use __atomic on powerpc */ ++# include "atomic/gcc_atomic.h" + #else + # error Native atomics support not found! + #endif diff -Nru mysql-5.7-5.7.11/debian/patches/series mysql-5.7-5.7.11/debian/patches/series --- mysql-5.7-5.7.11/debian/patches/series 2016-03-17 14:33:49.000000000 +0000 +++ mysql-5.7-5.7.11/debian/patches/series 2016-03-23 06:36:09.000000000 +0000 @@ -4,3 +4,6 @@ mips64el.patch mysql-test-run-paths removedojo.patch +mysql-atomic.patch +mysql-atomic-link.patch +mysql-atomic-innodb.patch diff -Nru mysql-5.7-5.7.11/debian/rules mysql-5.7-5.7.11/debian/rules --- mysql-5.7-5.7.11/debian/rules 2016-03-17 14:33:49.000000000 +0000 +++ mysql-5.7-5.7.11/debian/rules 2016-03-22 00:49:34.000000000 +0000 @@ -73,6 +73,7 @@ -DWITH_LIBWRAP=ON \ -DWITH_ZLIB=system \ -DWITH_EDITLINE=system \ + -DWITH_LIBEVENT=system \ -DWITH_SSL=bundled \ -DWITH_BOOST=../boost \ -DCOMPILATION_COMMENT="($(DISTRIBUTION))" \