Kaydet (Commit) 6517fd21 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

HAVE_THREADSAFE_STATICS sould always be true

...(for LIBO_INTERNAL_ONLY), now that the status of Android has been clarified,
see <https://lists.freedesktop.org/archives/libreoffice/2017-June/077827.html>
"Re: Some baseline thoughts"

Change-Id: Ie9d5444df84c23d48c24b68d9d2ab5322c619858
üst 6e433e05
......@@ -246,7 +246,6 @@ export HAVE_GNUMAKE_FILE_FUNC=@HAVE_GNUMAKE_FILE_FUNC@
export HAVE_LD_BSYMBOLIC_FUNCTIONS=@HAVE_LD_BSYMBOLIC_FUNCTIONS@
export HAVE_LD_HASH_STYLE=@HAVE_LD_HASH_STYLE@
export HAVE_POSIX_FALLOCATE=@HAVE_POSIX_FALLOCATE@
export HAVE_THREADSAFE_STATICS=@HAVE_THREADSAFE_STATICS@
export HELP_COMMON_ONLY=@HELP_COMMON_ONLY@
export HOST_PLATFORM=@host@
export HSQLDB_JAR=@HSQLDB_JAR@
......
......@@ -18,7 +18,6 @@ Any change in this header will cause a rebuild of almost everything.
/* _Pragma */
#define HAVE_GCC_PRAGMA_OPERATOR 0
#define HAVE_GCC_DEPRECATED_MESSAGE 0
#define HAVE_THREADSAFE_STATICS 0
#define HAVE_BROKEN_CONST_ITERATORS 0
#define HAVE_SYSLOG_H 0
/* Compiler supports __attribute__((warn_unused)). */
......
......@@ -5831,84 +5831,6 @@ if test "$SDT_H_FOUND" = "TRUE"; then
fi
AC_CONFIG_HEADERS([config_host/config_probes.h])
dnl ===================================================================
dnl thread-safe statics
dnl ===================================================================
AC_MSG_CHECKING([whether $CXX supports thread safe statics])
unset HAVE_THREADSAFE_STATICS
if test "$GCC" = "yes"; then
dnl -fthreadsafe-statics is available since GCC 4, so always available for
dnl us. However, some C++ runtimes use a single lock for all static
dnl variables, which can cause deadlock in multi-threaded applications.
dnl This is not easily tested here; for POSIX-based systems, if executing
dnl the following C++ program does not terminate then the tool chain
dnl apparently has this problem:
dnl
dnl #include <pthread.h>
dnl int h() { return 0; }
dnl void * g(void * unused) {
dnl static int n = h();
dnl return &n;
dnl }
dnl int f() {
dnl pthread_t t;
dnl pthread_create(&t, 0, g, 0);
dnl pthread_join(t, 0);
dnl return 0;
dnl }
dnl int main() {
dnl static int n = f();
dnl return n;
dnl }
dnl
dnl Mac OS X up to at least 10.7.1 is known to have this problem, as is at
dnl least one instance of GCC 4.2.4 (used on a "Linux ooobuild1.osuosl.org
dnl 2.6.9-101.plus.c4smp #1 SMP Thu Jul 21 19:08:15 EDT 2011 i686 i686 i386
dnl GNU/Linux" machine); see the definition of __cxa_guard_acquire in GCC's
dnl libstdc++-v3/libsupc++/guard.cc for what #ifdefs actually make a
dnl difference there. Conservative advice from Jakub Jelinek is to assume
dnl it working in GCC >= 4.3, so conservative way to check here is to use
dnl GCC_VERSION for GCC but resort to __GLIBCXX__ corresponding to libstdc++
dnl shipped with GCC 4.3.0 (cf. <http://gcc.gnu.org/onlinedocs/libstdc++/
dnl manual/abi.html#abi.versioning.history>; 4.3.0 is 20080306, 4.2.4 is
dnl 20080519, 4.3.1 is 20080606) for Clang (for which GCC_VERSION is notoriously
dnl "too old"):
if test "$_os" = Darwin; then
HAVE_THREADSAFE_STATICS=TRUE
elif test "$_os" != Android; then
if test "$COM_IS_CLANG" = TRUE; then
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <list>
#if defined __GLIBCXX__
#if __GLIBCXX__ < 20080606 && __GLIBCXX__ != 20080306
#error
#endif
#endif
]])],[HAVE_THREADSAFE_STATICS=TRUE],[])
AC_LANG_POP([C++])
else # known to work in GCC since version 4.3
HAVE_THREADSAFE_STATICS=TRUE
fi
fi
if test "$HAVE_THREADSAFE_STATICS" = TRUE; then
AC_DEFINE(HAVE_THREADSAFE_STATICS)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([broken (i.e., no)])
fi
else
# MSVC has sprouted C++11 thread-safe statics in 2015
# http://blogs.msdn.com/b/vcblog/archive/2015/06/19/c-11-14-17-features-in-vs-2015-rtm.aspx
if test "$COM" = "MSC"; then
AC_DEFINE(HAVE_THREADSAFE_STATICS)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
AC_SUBST(HAVE_THREADSAFE_STATICS)
dnl ===================================================================
dnl GCC features
dnl ===================================================================
......
......@@ -25,9 +25,7 @@
#include <cstddef>
#include <osl/doublecheckedlocking.h>
#if ! HAVE_THREADSAFE_STATICS
#include <osl/getglobalmutex.hxx>
#endif
namespace {
......@@ -383,7 +381,7 @@ namespace rtl {
using the outer class
(the one that derives from this base class)
*/
#if HAVE_THREADSAFE_STATICS
#if defined LIBO_INTERNAL_ONLY
template<typename T, typename Unique>
class Static {
public:
......@@ -443,7 +441,7 @@ private:
using the outer class
(the one that derives from this base class)
*/
#if HAVE_THREADSAFE_STATICS
#if defined LIBO_INTERNAL_ONLY
template<typename T, typename Data, typename Unique>
class StaticWithArg {
public:
......@@ -525,7 +523,7 @@ private:
@tparam InitAggregate
initializer functor class
*/
#if HAVE_THREADSAFE_STATICS
#if defined LIBO_INTERNAL_ONLY
template<typename T, typename InitAggregate>
class StaticAggregate {
public:
......@@ -590,7 +588,7 @@ public:
Initializer functor's return type.
Default is T (common practice).
*/
#if HAVE_THREADSAFE_STATICS
#if defined LIBO_INTERNAL_ONLY
template<typename T, typename InitData,
typename Unique = InitData, typename Data = T>
class StaticWithInit {
......
......@@ -73,10 +73,6 @@ gb_CXXFLAGS_COMMON := \
gb_CXXFLAGS_Wundef = -Wno-undef
ifneq ($(HAVE_THREADSAFE_STATICS),TRUE)
gb_CXXFLAGS_COMMON += -fno-threadsafe-statics
endif
ifeq ($(strip $(gb_GCOV)),YES)
gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage
gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment