summaryrefslogtreecommitdiff
path: root/m4/ax_cxx_dtor_after_atexit.m4
diff options
context:
space:
mode:
authorBastien ROUCARIÈS <roucaries.bastien@gmail.com>2015-01-01 18:19:30 +0100
committerBastien ROUCARIÈS <roucaries.bastien@gmail.com>2015-01-04 12:53:51 +0100
commit69f8f6b40fae850289a43ec58b8d9f80e5183dca (patch)
treedb181b25dfbd028746acad51b64952d362fa82dc /m4/ax_cxx_dtor_after_atexit.m4
parente3c5810d10d4eccca756896eac9a1624a5ad11c2 (diff)
downloadautoconf-archive-69f8f6b40fae850289a43ec58b8d9f80e5183dca.tar.gz
Modernize ax_cxx_dtor_after_atexit.m4
Diffstat (limited to 'm4/ax_cxx_dtor_after_atexit.m4')
-rw-r--r--m4/ax_cxx_dtor_after_atexit.m455
1 files changed, 28 insertions, 27 deletions
diff --git a/m4/ax_cxx_dtor_after_atexit.m4 b/m4/ax_cxx_dtor_after_atexit.m4
index ee05aa6..c148194 100644
--- a/m4/ax_cxx_dtor_after_atexit.m4
+++ b/m4/ax_cxx_dtor_after_atexit.m4
@@ -11,6 +11,8 @@
# If the C++ compiler calls global destructors after atexit functions,
# define HAVE_DTOR_AFTER_ATEXIT.
#
+# Conformant behavior is to have global destructors after atexit
+#
# Per Paragraph 3.6.3/1 of the C++11 Standard:
#
# Destructors (12.4) for initialized objects [..] with static storage
@@ -37,36 +39,35 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 7
+#serial 8
AU_ALIAS([AC_CXX_DTOR_AFTER_ATEXIT], [AX_CXX_DTOR_AFTER_ATEXIT])
AC_DEFUN([AX_CXX_DTOR_AFTER_ATEXIT],
-[AC_CACHE_CHECK(whether the compiler calls global destructors after functions registered through atexit,
-ax_cv_cxx_dtor_after_atexit,
-[AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_RUN([
-#include <unistd.h>
-#include <stdlib.h>
-
-static int dtor_called = 0;
-class A { public : ~A () { dtor_called = 1; } };
-static A a;
+[dnl
+ AC_CACHE_CHECK(whether the compiler calls global destructors after functions registered through atexit,
+ [ax_cv_cxx_dtor_after_atexit],
+ [AC_LANG_PUSH([C++])
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM(dnl
+ [
+ #include <unistd.h>
+ #include <cstdlib>
-void f() { _exit(dtor_called); }
+ static int dtor_called = 0;
+ class A { public : ~A () { dtor_called = 1; } };
+ static A a;
-int main (int , char **)
-{
- atexit (f);
- return 0;
-}
-],
- ax_cv_cxx_dtor_after_atexit=yes, ax_cv_cxx_dtor_after_atexit=yes=no,
- ax_cv_cxx_dtor_after_atexit=yes)
- AC_LANG_RESTORE
-])
-if test "$ax_cv_cxx_dtor_after_atexit" = yes; then
- AC_DEFINE(HAVE_DTOR_AFTER_ATEXIT,,
- [define if the compiler calls global destructors after functions registered through atexit])
-fi
+ void f() { _exit(dtor_called); }],
+ [
+ atexit (f);
+ return 0;
+ ])],
+ ax_cv_cxx_dtor_after_atexit=yes,
+ ax_cv_cxx_dtor_after_atexit=no,
+ ax_cv_cxx_dtor_after_atexit=yes)
+ AC_LANG_POP([C++])
+ ])
+ AS_IF([test "X$ax_cv_cxx_dtor_after_atexit" = Xyes],
+ [AC_DEFINE(HAVE_DTOR_AFTER_ATEXIT,,
+ [define if the compiler calls global destructors after functions registered through atexit])])
])