From 71e11bce34339a69576321d6c40838fa65208dc7 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 28 Oct 2016 12:29:37 +0400 Subject: [PATCH] MDEV-8791 - AIX: Unresolved Symbols during linking Clean-up nolock.h: it doesn't serve any purpose anymore. Appropriate code moved to x86-gcc.h and my_atomic.h. If gcc sync bultins were detected, we want to make use of them independently of __GNUC__ definition. E.g. XLC simulates those, but doesn't define __GNUC__. HS/Spider: According to AIX manual alloca() returns char*, which cannot be casted to any type with static_cast. Use explicit cast instead. MDL: Removed namemangling pragma, which didn't let MariaDB build with XLC. WSREP: _int64 seem to be conflicting name with XLC, replaced with _integer64. CONNECT: RTLD_NOLOAD is GNU extention. Removed rather meaningless check if library is loaded. Multiple dlopen()'s of the same library are permitted, and it never gets closed anyway. Except for error, which was a bug: it may close library, which can still be referenced by other subsystems. InnoDB: __ppc_get_timebase() is GNU extention. Only use it when __GLIBC__ is defined. Based on contribution by flynn1973. --- include/atomic/nolock.h | 54 ------------------- include/atomic/x86-gcc.h | 6 +++ include/my_atomic.h | 23 ++++++-- .../handler_socket/libhsclient/allocator.hpp | 2 +- sql/mdl.h | 9 ---- sql/wsrep_var.cc | 2 +- storage/connect/reldef.cpp | 2 +- storage/innobase/include/ut0ut.h | 2 +- storage/spider/hs_client/allocator.hpp | 2 +- storage/xtradb/include/ut0ut.h | 2 +- wsrep/wsrep_api.h | 2 +- 11 files changed, 33 insertions(+), 73 deletions(-) delete mode 100644 include/atomic/nolock.h diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h deleted file mode 100644 index 2137445a075..00000000000 --- a/include/atomic/nolock.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef ATOMIC_NOLOCK_INCLUDED -#define ATOMIC_NOLOCK_INCLUDED - -/* Copyright (c) 2006, 2010, 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 */ - -#if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__) \ - || defined(HAVE_GCC_ATOMIC_BUILTINS) \ - || defined(HAVE_SOLARIS_ATOMIC) - -# ifdef MY_ATOMIC_MODE_DUMMY -# define LOCK_prefix "" -# else -# define LOCK_prefix "lock" -# endif -/* - We choose implementation as follows: - ------------------------------------ - On Windows using Visual C++ the native implementation should be - preferrable. When using gcc we prefer the Solaris implementation - before the gcc because of stability preference, we choose gcc - builtins if available, otherwise we choose the somewhat broken - native x86 implementation. If neither Visual C++ or gcc we still - choose the Solaris implementation on Solaris (mainly for SunStudio - compilers). -*/ -# if defined(_MSC_VER) -# include "generic-msvc.h" -# elif __GNUC__ -# if defined(HAVE_SOLARIS_ATOMIC) -# include "solaris.h" -# elif defined(HAVE_GCC_ATOMIC_BUILTINS) -# include "gcc_builtins.h" -# elif defined(__i386__) || defined(__x86_64__) -# include "x86-gcc.h" -# endif -# elif defined(HAVE_SOLARIS_ATOMIC) -# include "solaris.h" -# endif -#endif - -#endif /* ATOMIC_NOLOCK_INCLUDED */ diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index 173e32e790c..3a081d9bbc5 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -28,6 +28,12 @@ */ #undef MY_ATOMIC_HAS_8_AND_16 +#ifdef MY_ATOMIC_MODE_DUMMY +#define LOCK_prefix "" +#else +#define LOCK_prefix "lock" +#endif + #ifdef __x86_64__ # ifdef MY_ATOMIC_NO_XADD # define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd" diff --git a/include/my_atomic.h b/include/my_atomic.h index 9f416208013..8f13a0ab89b 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -112,9 +112,26 @@ #undef MY_ATOMIC_HAS_8_16 /* - * Attempt to do atomic ops without locks - */ -#include "atomic/nolock.h" + We choose implementation as follows: + ------------------------------------ + On Windows using Visual C++ the native implementation should be + preferrable. When using gcc we prefer the Solaris implementation + before the gcc because of stability preference, we choose gcc + builtins if available, otherwise we choose the somewhat broken + native x86 implementation. If neither Visual C++ or gcc we still + choose the Solaris implementation on Solaris (mainly for SunStudio + compilers). +*/ +#if defined(_MSC_VER) +#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(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +#include "atomic/x86-gcc.h" +#endif + #ifndef make_atomic_cas_body /* nolock.h was not able to generate even a CAS function, fall back */ diff --git a/plugin/handler_socket/libhsclient/allocator.hpp b/plugin/handler_socket/libhsclient/allocator.hpp index 82ff51f00e7..dd3a28ba7bd 100644 --- a/plugin/handler_socket/libhsclient/allocator.hpp +++ b/plugin/handler_socket/libhsclient/allocator.hpp @@ -35,7 +35,7 @@ typedef std::allocator allocator_type; #if 1 #define DENA_ALLOCA_ALLOCATE(typ, len) \ - static_cast(alloca((len) * sizeof(typ))) + (typ *) alloca((len) * sizeof(typ)) #define DENA_ALLOCA_FREE(x) #else #define DENA_ALLOCA_ALLOCATE(typ, len) \ diff --git a/sql/mdl.h b/sql/mdl.h index 7961f1f24b2..7d659af86bc 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -15,15 +15,6 @@ along with this program; if not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ -#if defined(__IBMC__) || defined(__IBMCPP__) -/* Further down, "next_in_lock" and "next_in_context" have the same type, - and in "sql_plist.h" this leads to an identical signature, which causes - problems in function overloading. -*/ -#pragma namemangling(v5) -#endif - - #include "sql_plist.h" #include #include diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index bb5ee7baa57..e6d4bbbc303 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -670,7 +670,7 @@ int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff, v->name = thd->strdup(sv->name); switch (sv->type) { case WSREP_VAR_INT64: - v->value = (char*)thd->memdup(&sv->value._int64, sizeof(longlong)); + v->value = (char*)thd->memdup(&sv->value._integer64, sizeof(longlong)); v->type = SHOW_LONGLONG; break; case WSREP_VAR_STRING: diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 2c8ada52e6f..8a6174ea53b 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -534,7 +534,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) #endif // 0 // Is the library already loaded? - if (!Hdll && !(Hdll = dlopen(soname, RTLD_NOLOAD))) + if (!Hdll) // Load the desired shared library if (!(Hdll = dlopen(soname, RTLD_LAZY))) { error = dlerror(); diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 69216d213fd..470d21edce2 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -70,7 +70,7 @@ typedef time_t ib_time_t; the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() -# elif defined(__powerpc__) +# elif defined(__powerpc__) && defined __GLIBC__ #include # define UT_RELAX_CPU() do { \ volatile lint volatile_var = __ppc_get_timebase(); \ diff --git a/storage/spider/hs_client/allocator.hpp b/storage/spider/hs_client/allocator.hpp index b54c7430d30..a29015e6886 100644 --- a/storage/spider/hs_client/allocator.hpp +++ b/storage/spider/hs_client/allocator.hpp @@ -31,7 +31,7 @@ extern "C" { #if 1 #define DENA_ALLOCA_ALLOCATE(typ, len) \ - static_cast(alloca((len) * sizeof(typ))) + (typ *) alloca((len) * sizeof(typ)) #define DENA_ALLOCA_FREE(x) #else #define DENA_ALLOCA_ALLOCATE(typ, len) \ diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index 2df6bf58e6a..c5944bb0547 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -85,7 +85,7 @@ private: the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() -# elif defined(__powerpc__) +# elif defined(__powerpc__) && defined __GLIBC__ #include # define UT_RELAX_CPU() do { \ volatile lint volatile_var = __ppc_get_timebase(); \ diff --git a/wsrep/wsrep_api.h b/wsrep/wsrep_api.h index e713be094df..1d6bc059d3d 100644 --- a/wsrep/wsrep_api.h +++ b/wsrep/wsrep_api.h @@ -502,7 +502,7 @@ struct wsrep_stats_var const char* name; //!< variable name wsrep_var_type_t type; //!< variable value type union { - int64_t _int64; + int64_t _integer64; double _double; const char* _string; } value; //!< variable value