diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-06-20 13:57:45 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-10-06 17:11:59 +0200 |
commit | 5a455acbecc0d56f9086de79fb3557de41711368 (patch) | |
tree | 510050a6ed1e1b1000b650fa03a7c1b3f6b8a20f | |
parent | i#101283 Fix collapsed bookmark handling (diff) | |
download | core-5a455acbecc0d56f9086de79fb3557de41711368.tar.gz core-5a455acbecc0d56f9086de79fb3557de41711368.zip |
Clean up declaration of __cxa_get_globals
At least Clang trunk towards 3.4 now rejects incompatible declarations of the
same extern "C" function in different namespaces, so that trick of getting at
the function that is exported by libstdc++ but only rudimentarily if at all
exposed in cxxabi.h no longer worked.
TODO: This change should be reflected in any other bridges where it is relevant,
too.
Conflicts:
configure.ac
Change-Id: Ie3ccbdb7d75cc98636d02c0435958532620724f2
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx | 5 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx | 22 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx | 7 | ||||
-rw-r--r-- | config_host/config_gcc.h.in | 17 | ||||
-rw-r--r-- | configure.ac | 12 |
5 files changed, 54 insertions, 9 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx index ea38f2973e92..8229ce8f1e61 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx @@ -22,11 +22,6 @@ #include <string.h> #include <dlfcn.h> -#include <cxxabi.h> -#ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h -#define _GLIBCXX_CDTOR_CALLABI -#endif - #include <boost/unordered_map.hpp> #include <rtl/strbuf.hxx> diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx index c305197e1655..f3f43e5719ea 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx @@ -17,12 +17,20 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "uno/mapping.h" +#include "sal/config.h" #include <typeinfo> #include <exception> #include <cstddef> +#include <cxxabi.h> +#ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h +#define _GLIBCXX_CDTOR_CALLABI +#endif + +#include "config_gcc.h" +#include "uno/mapping.h" + namespace CPPU_CURRENT_NAMESPACE { @@ -65,7 +73,17 @@ struct __cxa_eh_globals } -extern "C" CPPU_CURRENT_NAMESPACE::__cxa_eh_globals *__cxa_get_globals () throw(); +// __cxa_get_globals is exported from libstdc++ since GCC 3.4.0 (CXXABI_1.3), +// but it is only declared in cxxabi.h (in namespace __cxxabiv1) since +// GCC 4.7.0. It returns a pointer to a struct __cxa_eh_globals, but that +// struct is only incompletely declared even in the GCC 4.7.0 cxxabi.h. +// Therefore, provide a declaration here for old GCC (libstdc++, really) version +// that returns a void pointer, and in the code calling it always cast to the +// above fake definition of CPPU_CURRENT_NAMESPACE::__cxa_eh_globals (which +// hopefully keeps matching the real definition in libstdc++): +#if !HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS +namespace __cxxabiv1 { extern "C" void * __cxa_get_globals () throw(); } +#endif namespace CPPU_CURRENT_NAMESPACE { diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index cbf45bb094d2..08c797c8bd02 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -289,8 +289,11 @@ static void cpp_call( } catch (...) { - // fill uno exception - fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); + // fill uno exception + fillUnoException( + reinterpret_cast< CPPU_CURRENT_NAMESPACE::__cxa_eh_globals * >( + __cxxabiv1::__cxa_get_globals())->caughtExceptions, + *ppUnoExc, pThis->getBridge()->getCpp2Uno()); // temporary params for ( ; nTempIndizes--; ) diff --git a/config_host/config_gcc.h.in b/config_host/config_gcc.h.in new file mode 100644 index 000000000000..4376877e2b1d --- /dev/null +++ b/config_host/config_gcc.h.in @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef CONFIG_GCC_H +#define CONFIG_GCC_H + +#define HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS 0 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configure.ac b/configure.ac index 4fae69b2c94a..e636b695b581 100644 --- a/configure.ac +++ b/configure.ac @@ -5569,6 +5569,17 @@ if test "$GCC" = "yes"; then ], [AC_MSG_RESULT([no])]) CFLAGS=$save_CFLAGS + AC_MSG_CHECKING([whether $CXX declares __cxa_get_globals in cxxabi.h]) + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include <cxxabi.h> + void * f() { return __cxxabiv1::__cxa_get_globals(); } + ])], [ + AC_DEFINE([HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS],[1]) + AC_MSG_RESULT([yes]) + ], [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if __GNUC__ == 4 && __GNUC_MINOR__ == 7 && (__GNUC_PATCHLEVEL__ == 0 || __GNUC_PATCHLEVEL__ == 1) #else @@ -12034,6 +12045,7 @@ AC_CONFIG_FILES([config_host.mk Makefile lo.xcent instsetoo_native/util/openoffi AC_CONFIG_HEADERS([config_host/config_buildid.h]) AC_CONFIG_HEADERS([config_host/config_clang.h]) AC_CONFIG_HEADERS([config_host/config_features.h]) +AC_CONFIG_HEADERS([config_host/config_gcc.h]) AC_CONFIG_HEADERS([config_host/config_global.h]) AC_CONFIG_HEADERS([config_host/config_graphite.h]) AC_CONFIG_HEADERS([config_host/config_lgpl.h]) |