]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix usage of __GXX_WEAK__ in TM TS support.
authorTorvald Riegel <triegel@redhat.com>
Mon, 18 Jan 2016 20:09:55 +0000 (20:09 +0000)
committerTorvald Riegel <torvald@gcc.gnu.org>
Mon, 18 Jan 2016 20:09:55 +0000 (20:09 +0000)
* include/bits/c++config (_GLIBCXX_USE_WEAK_REF): New.
(_GLIBCXX_TXN_SAFE, _GLIBCXX_TXN_SAFE_DYN): Use _GLIBCXX_USE_WEAK_REF
and move after its definition.
* config/os/aix/os_defines.h (_GLIBCXX_USE_WEAK_REF): Override.
* src/c++11/cow-stdexcept.cc: Use _GLIBCXX_USE_WEAK_REF instead of
__GXX_WEAK__, and only provide transactional clones if
_GLIBCXX_USE_WEAK_REF is true.  Don't provide stubs of libitm
functions.

From-SVN: r232539

libstdc++-v3/ChangeLog
libstdc++-v3/config/os/aix/os_defines.h
libstdc++-v3/include/bits/c++config
libstdc++-v3/src/c++11/cow-stdexcept.cc

index 0b7ca1b685253ed5351d46081033a246cc12cc1c..d68f5a529cda51886fa29ee8c70544715e5b9cb9 100644 (file)
@@ -1,3 +1,14 @@
+2016-01-18  Torvald Riegel  <triegel@redhat.com>
+
+       * include/bits/c++config (_GLIBCXX_USE_WEAK_REF): New.
+       (_GLIBCXX_TXN_SAFE, _GLIBCXX_TXN_SAFE_DYN): Use _GLIBCXX_USE_WEAK_REF
+       and move after its definition.
+       * config/os/aix/os_defines.h (_GLIBCXX_USE_WEAK_REF): Override.
+       * src/c++11/cow-stdexcept.cc: Use _GLIBCXX_USE_WEAK_REF instead of
+       __GXX_WEAK__, and only provide transactional clones if
+       _GLIBCXX_USE_WEAK_REF is true.  Don't provide stubs of libitm
+       functions.
+
 2016-01-18  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/60637
index d895471f2bb41fe64591f24679eb3ac258c01a2c..09494468768dcd7cf78b0dab1752a2ad42008907 100644 (file)
@@ -48,4 +48,7 @@
 #define __COMPATMATH__
 #endif
 
+// No support for referencing weak symbols without a definition.
+#define _GLIBCXX_USE_WEAK_REF 0
+
 #endif
index 387a7bb57fefe49425f4a018ce3459119f6285bd..57024e40ec0de20263e3d23170a03a9706df650d 100644 (file)
@@ -483,20 +483,6 @@ namespace std
 
 #define _GLIBCXX_USE_ALLOCATOR_NEW
 
-// Conditionally enable annotations for the Transactional Memory TS on C++11.
-// Most of the following conditions are due to limitations in the current
-// implementation.
-#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI                   \
-  && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L    \
-  &&  !_GLIBCXX_FULLY_DYNAMIC_STRING && __GXX_WEAK__                   \
-  && _GLIBCXX_USE_ALLOCATOR_NEW
-#define _GLIBCXX_TXN_SAFE transaction_safe
-#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
-#else
-#define _GLIBCXX_TXN_SAFE
-#define _GLIBCXX_TXN_SAFE_DYN
-#endif
-
 #else // !__cplusplus
 # define _GLIBCXX_BEGIN_EXTERN_C
 # define _GLIBCXX_END_EXTERN_C
@@ -524,6 +510,28 @@ namespace std
 # define _GLIBCXX_WEAK_DEFINITION
 #endif
 
+// By default, we assume that __GXX_WEAK__ also means that there is support
+// for declaring functions as weak while not defining such functions.  This
+// allows for referring to functions provided by other libraries (e.g.,
+// libitm) without depending on them if the respective features are not used.
+#ifndef _GLIBCXX_USE_WEAK_REF
+# define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__
+#endif
+
+// Conditionally enable annotations for the Transactional Memory TS on C++11.
+// Most of the following conditions are due to limitations in the current
+// implementation.
+#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI                   \
+  && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L    \
+  &&  !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF          \
+  && _GLIBCXX_USE_ALLOCATOR_NEW
+#define _GLIBCXX_TXN_SAFE transaction_safe
+#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic
+#else
+#define _GLIBCXX_TXN_SAFE
+#define _GLIBCXX_TXN_SAFE_DYN
+#endif
+
 
 // The remainder of the prewritten config is automatic; all the
 // user hooks are listed above.
index eddb36b48c4906fbf80eb922c4ce55164330f788..a0f505c218755ca522a6f8066a73a3e08375d3f1 100644 (file)
@@ -179,6 +179,13 @@ _GLIBCXX_END_NAMESPACE_VERSION
 // Furthermore, _Rep will always have been allocated or deallocated via
 // global new or delete, so nontransactional writes we do to _Rep cannot
 // interfere with transactional accesses.
+
+// We depend on having support for referencing functions declared weak that
+// are not defined by us.  Without such support, the exceptions will not be
+// declared transaction-safe, so we just don't provide transactional clones
+// in this case.
+#if _GLIBCXX_USE_WEAK_REF
+
 extern "C" {
 
 #ifndef _GLIBCXX_MANGLE_SIZE_T
@@ -195,7 +202,6 @@ extern "C" {
 # define ITM_REGPARM
 #endif
 
-#if __GXX_WEAK__
 // Declare all libitm symbols we rely on, but make them weak so that we do
 // not depend on libitm.
 extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
@@ -213,19 +219,6 @@ extern void _ITM_memcpyRnWt(void *, const void *, size_t)
 extern void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *)
   ITM_REGPARM __attribute__((weak));
 
-#else
-// If there is no support for weak symbols, create dummies.  The exceptions
-// will not be declared transaction_safe in this case.
-void* _ZGTtnaX (size_t) { return NULL; }
-void _ZGTtdlPv (void*) { }
-uint8_t _ITM_RU1(const uint8_t *) { return 0; }
-uint32_t _ITM_RU4(const uint32_t *) { return 0; }
-uint64_t _ITM_RU8(const uint64_t *) { return 0; }
-void _ITM_memcpyRtWn(void *, const void *, size_t) { }
-void _ITM_memcpyRnWt(void *, const void *, size_t) { }
-void _ITM_addUserCommitAction(void (*)(void *), uint64_t, void *) { };
-#endif
-
 }
 
 // A transactional version of basic_string::basic_string(const char *s)
@@ -441,3 +434,5 @@ CTORDTOR(14overflow_error, std::overflow_error, runtime_error)
 CTORDTOR(15underflow_error, std::underflow_error, runtime_error)
 
 }
+
+#endif  // _GLIBCXX_USE_WEAK_REF