]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
acconfig.h: Add _GLIBCXX_USE___CXA_ATEXIT.
authorBenjamin Kosnik <bkoz@redhat.com>
Sat, 9 Oct 2004 02:30:10 +0000 (02:30 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Sat, 9 Oct 2004 02:30:10 +0000 (02:30 +0000)
2004-10-08  Benjamin Kosnik  <bkoz@redhat.com>

* acconfig.h: Add _GLIBCXX_USE___CXA_ATEXIT.
* acinclude.m4 (GLIBCXX_ENABLE_CXA_ATEXIT): New.
* configure.ac: Call GLIBCXX_ENABLE_CXA_EXIT.
* configure: Regenerate.
* src/mt_allocator.cc (__pool::~__pool): Make conditional on
_GLIBCXX_USE___CXA_ATEXIT macro.
* docs/html/ext/mt_allocator.html: Add note about deallocation.
* testsuite/ext/mt_allocator/deallocate_local-2.cc: Guard checks
with _GLIBCXX_USE___CXA_ATEXIT.
* testsuite/ext/mt_allocator/deallocate_global_thread-3.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global_thread-1.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global-4.cc: Same.
* testsuite/ext/mt_allocator/deallocate_global-2.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local_thread-3.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local_thread-1.cc: Same.
* testsuite/ext/mt_allocator/deallocate_local-4.cc: Same.

From-SVN: r88809

16 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/acconfig.h
libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/configure
libstdc++-v3/configure.ac
libstdc++-v3/docs/html/ext/mt_allocator.html
libstdc++-v3/src/mt_allocator.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-2.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global-4.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-1.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_global_thread-3.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-2.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local-4.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-1.cc
libstdc++-v3/testsuite/ext/mt_allocator/deallocate_local_thread-3.cc

index f434a830483bbdd5ec5e01fe9ab05ba660ec8f0b..615d83f51d7a1a0901397a9f38bb17bb5d5d348c 100644 (file)
@@ -1,3 +1,22 @@
+2004-10-08  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * acconfig.h: Add _GLIBCXX_USE___CXA_ATEXIT.
+       * acinclude.m4 (GLIBCXX_ENABLE_CXA_ATEXIT): New.
+       * configure.ac: Call GLIBCXX_ENABLE_CXA_EXIT.
+       * configure: Regenerate.
+       * src/mt_allocator.cc (__pool::~__pool): Make conditional on
+       _GLIBCXX_USE___CXA_ATEXIT macro.
+       * docs/html/ext/mt_allocator.html: Add note about deallocation.
+       * testsuite/ext/mt_allocator/deallocate_local-2.cc: Guard checks
+       with _GLIBCXX_USE___CXA_ATEXIT.
+       * testsuite/ext/mt_allocator/deallocate_global_thread-3.cc: Same.
+       * testsuite/ext/mt_allocator/deallocate_global_thread-1.cc: Same.
+       * testsuite/ext/mt_allocator/deallocate_global-4.cc: Same.
+       * testsuite/ext/mt_allocator/deallocate_global-2.cc: Same.
+       * testsuite/ext/mt_allocator/deallocate_local_thread-3.cc: Same.
+       * testsuite/ext/mt_allocator/deallocate_local_thread-1.cc: Same.
+       * testsuite/ext/mt_allocator/deallocate_local-4.cc: Same.
+       
 2004-10-07  Phil Edwards  <phil@codesourcery.com>
 
        * testsuite/lib/libstdc++.exp:  Update list of undefined functions.
index cffecbd172fd21cf89f1fe0aaea4f32d9c9757db..6a2ba98887d001cd58e5ace43a5bf515bb025792 100644 (file)
@@ -28,6 +28,9 @@
 // Define to use concept checking code from the boost libraries.
 #undef _GLIBCXX_CONCEPT_CHECKS
 
+// Define to use __cxa_atexit.
+#undef _GLIBCXX_USE___CXA_ATEXIT
+
 // Define to use symbol versioning in the shared library.
 #undef _GLIBCXX_SYMVER
 
index 0bd4aa645d92973a83019469aa83ce2581761166..f45845a7249a446ef94c28eb2bd8caad5bbda65f 100644 (file)
@@ -611,6 +611,21 @@ AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
   fi
 ])
 
+dnl
+dnl Check for --enable-__cxa_atexit
+dnl
+dnl --enable-__cxa_atexit defines _GLIBCXX_USE___CXA_ATEXIT
+dnl --disable-__cxa_atexit doesn't define _GLIBCXX_USE___CXA_ATEXIT
+dnl  +  Usage:  GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
+dnl       Where DEFAULT is either `yes' or `no'.
+dnl
+AC_DEFUN([GLIBCXX_ENABLE_CXA_ATEXIT], [
+  GLIBCXX_ENABLE(__cxa_atexit,$1,,
+                 [Define if __cxa_atexit is to be used instead of atexit.])
+  if test $enable___cxa_atexit = yes; then
+    AC_DEFINE(_GLIBCXX_USE___CXA_ATEXIT)
+  fi
+])
 
 dnl
 dnl Does any necessary configuration of the testsuite directory.  Generates
index acb7d732abc2951f7b318f3dea12f54e4d24a685..be444e501870ccacb97bc51f7ed797f721237992 100644 (file)
@@ -29,6 +29,9 @@
 // Define to use concept checking code from the boost libraries.
 #undef _GLIBCXX_CONCEPT_CHECKS
 
+// Define to use __cxa_atexit.
+#undef _GLIBCXX_USE___CXA_ATEXIT
+
 // Define to use symbol versioning in the shared library.
 #undef _GLIBCXX_SYMVER
 
index b2ca698a0d7d8140883f1b58a03adb32c9177fde..530efa0c646ef049aff71fc654816e76fbae1a35 100755 (executable)
@@ -856,6 +856,8 @@ Optional Features:
   --enable-sjlj-exceptions
                           force use of builtin_setjmp for exceptions
                           [default=auto]
+  --enable-__cxa_atexit   Define if __cxa_atexit is to be used instead of
+                          atexit. [default=no]
   --enable-libstdcxx-pch  build pre-compiled libstdc++ headers
                           [default=$is_hosted]
   --enable-cstdio=PACKAGE use target-specific I/O package
@@ -4397,7 +4399,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
 case $host in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 4400 "configure"' > conftest.$ac_ext
+  echo '#line 4402 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -5018,7 +5020,7 @@ fi;
     #
     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
     cat > conftest.$ac_ext << EOF
-#line 5021 "configure"
+#line 5023 "configure"
 struct S { ~S(); };
 void bar();
 void foo()
@@ -5074,6 +5076,29 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 echo "${ECHO_T}$ac_exception_model_name" >&6
 
 
+   # Check whether --enable-__cxa_atexit or --disable-__cxa_atexit was given.
+if test "${enable___cxa_atexit+set}" = set; then
+  enableval="$enable___cxa_atexit"
+
+      case "$enableval" in
+       yes|no) ;;
+       *) { { echo "$as_me:$LINENO: error: Argument to enable/disable __cxa_atexit must be yes or no" >&5
+echo "$as_me: error: Argument to enable/disable __cxa_atexit must be yes or no" >&2;}
+   { (exit 1); exit 1; }; } ;;
+      esac
+
+else
+  enable___cxa_atexit=no
+fi;
+
+  if test $enable___cxa_atexit = yes; then
+    cat >>confdefs.h <<\_ACEOF
+#define _GLIBCXX_USE___CXA_ATEXIT 1
+_ACEOF
+
+  fi
+
+
   echo "$as_me:$LINENO: checking for enabled PCH" >&5
 echo $ECHO_N "checking for enabled PCH... $ECHO_C" >&6
    # Check whether --enable-libstdcxx-pch or --disable-libstdcxx-pch was given.
index a11f034120be43456ba11be525d7e89a6fe51bac..9978891ff9b028d3d49af37e2b1aaa952895332f 100644 (file)
@@ -78,6 +78,7 @@ GLIBCXX_ENABLE_HOSTED
 
 # Check for support bits and g++ features that don't require linking.
 GLIBCXX_ENABLE_SJLJ_EXCEPTIONS
+GLIBCXX_ENABLE_CXA_ATEXIT([no])
 GLIBCXX_ENABLE_PCH($is_hosted)
 
 # Enable all the variable C++ runtime options.  
index 9ddd5a052de9dbc3bc9af7565a2b5988b5f45838..f2f8348ca25959b7d86e3fa7d3d15ea73db5356d 100644 (file)
@@ -265,14 +265,26 @@ The _S_initialize() function:
     I.e. _S_bin[ n ].free[ n ] = 0;
 </p>
 <p>
-  - Initialize the mutex of each bin_record:
-    The bin_record-&gt;mutex is used to protect the global freelist. This concept
-    of a global freelist is explained in more detail in the section
-    "A multi threaded example", but basically this mutex is locked whenever 
-    a block of memory is retrieved or returned to the global freelist for this
-    specific bin. This only occurs when a number of blocks are grabbed from the
-    global list to a thread specific list or when a thread decides to return 
-    some blocks to the global freelist.
+  - Initialize the mutex of each bin_record: The bin_record-&gt;mutex
+    is used to protect the global freelist. This concept of a global
+    freelist is explained in more detail in the section "A multi
+    threaded example", but basically this mutex is locked whenever a
+    block of memory is retrieved or returned to the global freelist
+    for this specific bin. This only occurs when a number of blocks
+    are grabbed from the global list to a thread specific list or when
+    a thread decides to return some blocks to the global freelist.
+</p>
+
+<p> Notes about deallocation. On systems with the function
+<code>__cxa_atexit</code>, the allocator will free all memory
+allocated before program termination. However, because this relies on
+the precise and exactly-conforming ordering of static destructors,
+including those of a static local <code>__pool</code> object, it is
+not available on systems that don't have the necessary underlying
+support. On those systems, memory debugging programs like valgrind or
+purify may notice leaks: sorry about this inconvenience. However, most
+operating systems actually reclaim this memory at program termination
+anyway.
 </p>
 
 <h3 class="left">
index 1e45f4cfb1b7d5237dc47b10248935ba36fd87a1..7c3f5a4fa64da305b7d082c7dae9420ffa328684 100644 (file)
@@ -48,6 +48,7 @@ namespace __gnu_cxx
 {
   __pool<false>::~__pool()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (_M_init && !_M_options._M_force_new)
       {
        for (size_t __n = 0; __n < _M_bin_size; ++__n)
@@ -65,6 +66,7 @@ namespace __gnu_cxx
        delete _M_bin;
        delete _M_binmap;
       }
+#endif
   }
 
   void
@@ -174,6 +176,7 @@ namespace __gnu_cxx
 #ifdef __GTHREADS
   __pool<true>::~__pool()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (_M_init && !_M_options._M_force_new)
       {
        if (__gthread_active_p())
@@ -213,6 +216,7 @@ namespace __gnu_cxx
        delete _M_bin;
        delete _M_binmap;
       }
+#endif
   }
 
   void
index f048487298972ebbcd4476b4babbc9b383861e2b..01baada54708b1cf50b183bef1d9937fc34f0f29 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::exception();
+#endif
   }
 };
  
index 02c6a4c4c685104bbfacd4ed46bd92603214f4bb..3d5b96233f5f6692b0c099ba9f2570f6866fec7b 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };
  
index 1f0ac281af77a038511f7510a1ad0a699f10282e..3ec3abcd6b673bcd16778e96638aea50202570a9 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };
  
index 10efea66ec60a73f57490b38e7524dd5466a1c78..398ef31d39d3c6f3e04c958de6a01f5cded360ff 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };
  
index a6af89f11f05033a4c82c6d6c6ba23e2d69bf9cf..b8e2784f484d82ea3bc4b659d7b0f7490c77efa5 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };
  
index c194b977d577cfb9172f8b5f42b1e97f8eaf9297..1df7fb500cd63abfc91817b3cd289d809c859b30 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };
  
index 5664d3caff87e068947ca46aa8af1b98f7366e72..2191264e9424f5dd03f636c85c0df14395f8135d 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };
  
index 973f758d98df6945632f6d457049606c48eb0e52..6094a718a0edd3284d5be3262c1644659e2a3c8a 100644 (file)
@@ -31,8 +31,10 @@ struct count_check
   count_check() {}
   ~count_check()
   {
+#ifdef _GLIBCXX_USE___CXA_ATEXIT
     if (count != 0)
       throw std::runtime_error("count isn't zero");
+#endif
   }
 };