]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++/69945 Add __gnu_cxx::__freeres hook
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Mar 2016 18:13:40 +0000 (18:13 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Mar 2016 18:13:40 +0000 (18:13 +0000)
PR libstdc++/69945
* config/abi/pre/gnu.ver: Add new symbol.
* libsupc++/eh_alloc.cc (__gnu_cxx::__freeres): Define.
* testsuite/18_support/free_eh_pool.cc: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234465 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/libsupc++/eh_alloc.cc
libstdc++-v3/testsuite/18_support/free_eh_pool.cc [new file with mode: 0644]

index a2cb3d70008d327873b58bc357f1bcd014e2f01b..4e6db2ab3db8bc3238ddfdb2cfad03b9a38b7d3d 100644 (file)
@@ -1,3 +1,10 @@
+2016-03-24  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/69945
+       * config/abi/pre/gnu.ver: Add new symbol.
+       * libsupc++/eh_alloc.cc (__gnu_cxx::__freeres): Define.
+       * testsuite/18_support/free_eh_pool.cc: New test.
+
 2016-03-23  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * include/Makefile.am (install-freestanding-headers): Add
index 41069d156a3367ebdf5c4491589f0e22d0e1b390..5c6b0feb2b3efd57613980ac1842e01f44025a93 100644 (file)
@@ -2148,6 +2148,8 @@ CXXABI_1.3.10 {
     _ZGTtNKSt13bad_exceptionD1Ev;
     _ZGTtNKSt13bad_exception4whatEv;
 
+    _ZN9__gnu_cxx9__freeresEv;
+
 } CXXABI_1.3.9;
 
 # Symbols in the support library (libsupc++) supporting transactional memory.
index 6973af3d96c41ca5a28fc3f4c83c9350022efa2a..d362e406ccac572fc8a6628e5020b512692f7429 100644 (file)
@@ -73,6 +73,10 @@ using namespace __cxxabiv1;
 # define EMERGENCY_OBJ_COUNT   4
 #endif
 
+namespace __gnu_cxx
+{
+  void __freeres();
+}
 
 namespace
 {
@@ -106,6 +110,8 @@ namespace
       // to implement in_pool.
       char *arena;
       std::size_t arena_size;
+
+      friend void __gnu_cxx::__freeres();
     };
 
   pool::pool()
@@ -244,6 +250,19 @@ namespace
   pool emergency_pool;
 }
 
+namespace __gnu_cxx
+{
+  void
+  __freeres()
+  {
+    if (emergency_pool.arena)
+      {
+       ::free(emergency_pool.arena);
+       emergency_pool.arena = 0;
+      }
+  }
+}
+
 extern "C" void *
 __cxxabiv1::__cxa_allocate_exception(std::size_t thrown_size) _GLIBCXX_NOTHROW
 {
diff --git a/libstdc++-v3/testsuite/18_support/free_eh_pool.cc b/libstdc++-v3/testsuite/18_support/free_eh_pool.cc
new file mode 100644 (file)
index 0000000..9712d3d
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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; either version 3, or (at your option)
+// any later version.
+
+// This library 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 library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run }
+
+namespace __gnu_cxx {
+  void __freeres();
+}
+
+struct X {
+  ~X() {
+    __gnu_cxx::__freeres();
+  }
+};
+
+X x;
+
+int
+main()
+{
+}