Commit cc999d03 by Jason Merrill Committed by Jason Merrill

linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE): New.

	* linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE): New.
	(GLIBCXX_CHECK_STDLIB_SUPPORT): Check for atexit and at_quick_exit.
	* include/c_std/cstdlib: Add atexit and at_quick_exit.
	* include/c_global/cstdlib: Add atexit and at_quick_exit.
	* testsuite/18_support/quick_exit/quick_exit.cc: New.

From-SVN: r195948
parent b63fe007
2013-02-11 Jason Merrill <jason@redhat.com>
* linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE): New.
(GLIBCXX_CHECK_STDLIB_SUPPORT): Check for atexit and at_quick_exit.
* config.h.in, configure: Regenerate.
* include/c_std/cstdlib: Add atexit and at_quick_exit.
* include/c_global/cstdlib: Add atexit and at_quick_exit.
* testsuite/18_support/quick_exit/quick_exit.cc: New.
2013-02-11 Paolo Carlini <paolo.carlini@oracle.com> 2013-02-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/56282 PR libstdc++/56282
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
/* Define to 1 if you have the `atanl' function. */ /* Define to 1 if you have the `atanl' function. */
#undef HAVE_ATANL #undef HAVE_ATANL
/* Define to 1 if you have the `at_quick_exit' function. */
#undef HAVE_AT_QUICK_EXIT
/* Define to 1 if the target assembler supports thread-local storage. */ /* Define to 1 if the target assembler supports thread-local storage. */
#undef HAVE_CC_TLS #undef HAVE_CC_TLS
...@@ -303,6 +306,9 @@ ...@@ -303,6 +306,9 @@
/* Define to 1 if you have the `qfpclass' function. */ /* Define to 1 if you have the `qfpclass' function. */
#undef HAVE_QFPCLASS #undef HAVE_QFPCLASS
/* Define to 1 if you have the `quick_exit' function. */
#undef HAVE_QUICK_EXIT
/* Define to 1 if you have the `setenv' function. */ /* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV #undef HAVE_SETENV
......
...@@ -57,6 +57,8 @@ namespace std ...@@ -57,6 +57,8 @@ namespace std
extern "C" void abort(void) throw () _GLIBCXX_NORETURN; extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
extern "C" int atexit(void (*)()) throw (); extern "C" int atexit(void (*)()) throw ();
extern "C" void exit(int) throw () _GLIBCXX_NORETURN; extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
extern "C" int at_quick_exit(void (*)()) throw ();
extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;
} // namespace std } // namespace std
#else #else
...@@ -67,6 +69,7 @@ namespace std ...@@ -67,6 +69,7 @@ namespace std
#undef abort #undef abort
#undef abs #undef abs
#undef atexit #undef atexit
#undef at_quick_exit
#undef atof #undef atof
#undef atoi #undef atoi
#undef atol #undef atol
...@@ -83,6 +86,7 @@ namespace std ...@@ -83,6 +86,7 @@ namespace std
#undef mbstowcs #undef mbstowcs
#undef mbtowc #undef mbtowc
#undef qsort #undef qsort
#undef quick_exit
#undef rand #undef rand
#undef realloc #undef realloc
#undef srand #undef srand
...@@ -103,6 +107,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -103,6 +107,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::abort; using ::abort;
using ::abs; using ::abs;
using ::atexit; using ::atexit;
#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
using ::at_quick_exit;
#endif
using ::atof; using ::atof;
using ::atoi; using ::atoi;
using ::atol; using ::atol;
...@@ -121,6 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -121,6 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::mbtowc; using ::mbtowc;
#endif // _GLIBCXX_HAVE_MBSTATE_T #endif // _GLIBCXX_HAVE_MBSTATE_T
using ::qsort; using ::qsort;
#ifdef _GLIBCXX_HAVE_QUICK_EXIT
using ::quick_exit;
#endif
using ::rand; using ::rand;
using ::realloc; using ::realloc;
using ::srand; using ::srand;
......
...@@ -57,6 +57,8 @@ namespace std ...@@ -57,6 +57,8 @@ namespace std
extern "C" void abort(void) throw () _GLIBCXX_NORETURN; extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
extern "C" int atexit(void (*)()) throw (); extern "C" int atexit(void (*)()) throw ();
extern "C" void exit(int) throw () _GLIBCXX_NORETURN; extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
extern "C" int at_quick_exit(void (*)()) throw ();
extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;
} // namespace } // namespace
#else #else
...@@ -67,6 +69,7 @@ namespace std ...@@ -67,6 +69,7 @@ namespace std
#undef abort #undef abort
#undef abs #undef abs
#undef atexit #undef atexit
#undef at_quick_exit
#undef atof #undef atof
#undef atoi #undef atoi
#undef atol #undef atol
...@@ -83,6 +86,7 @@ namespace std ...@@ -83,6 +86,7 @@ namespace std
#undef mbstowcs #undef mbstowcs
#undef mbtowc #undef mbtowc
#undef qsort #undef qsort
#undef quick_exit
#undef rand #undef rand
#undef realloc #undef realloc
#undef srand #undef srand
...@@ -103,6 +107,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -103,6 +107,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::abort; using ::abort;
using ::abs; using ::abs;
using ::atexit; using ::atexit;
#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
using ::at_quick_exit;
#endif
using ::atof; using ::atof;
using ::atoi; using ::atoi;
using ::atol; using ::atol;
...@@ -121,6 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -121,6 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::mbtowc; using ::mbtowc;
#endif // _GLIBCXX_HAVE_MBSTATE_T #endif // _GLIBCXX_HAVE_MBSTATE_T
using ::qsort; using ::qsort;
#ifdef _GLIBCXX_HAVE_QUICK_EXIT
using ::quick_exit;
#endif
using ::rand; using ::rand;
using ::realloc; using ::realloc;
using ::srand; using ::srand;
......
...@@ -239,6 +239,35 @@ dnl 2) has "C" linkage ...@@ -239,6 +239,35 @@ dnl 2) has "C" linkage
dnl dnl
dnl argument 1 is name of function to check dnl argument 1 is name of function to check
dnl dnl
dnl ASSUMES argument is a stdlib function with ONE parameter
dnl
dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1
AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1], [
AC_MSG_CHECKING([for $1 declaration])
if test x${glibcxx_cv_func_$1_use+set} != xset; then
AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <stdlib.h>],
[ $1(0);],
[glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
AC_LANG_RESTORE
])
fi
AC_MSG_RESULT($glibcxx_cv_func_$1_use)
if test x$glibcxx_cv_func_$1_use = x"yes"; then
AC_CHECK_FUNCS($1)
fi
])
dnl
dnl Check to see if the (stdlib function) argument passed is
dnl 1) declared when using the c++ compiler
dnl 2) has "C" linkage
dnl
dnl argument 1 is name of function to check
dnl
dnl ASSUMES argument is a stdlib function with TWO parameters dnl ASSUMES argument is a stdlib function with TWO parameters
dnl dnl
dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
...@@ -306,6 +335,8 @@ AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [ ...@@ -306,6 +335,8 @@ AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
ac_save_CXXFLAGS="$CXXFLAGS" ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS='-fno-builtin -D_GNU_SOURCE' CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(at_quick_exit)
GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(quick_exit)
GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold) GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof) GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
......
// 2013-02-11 Jason Merrill
// Copyright (C) 2013 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/>.
// 18.5 - Start and termination
#include <cstdlib>
void handler()
{
std::_Exit(0);
}
void wrong_handler()
{
std::abort();
}
int main()
{
std::at_quick_exit (handler);
std::atexit (wrong_handler);
std::quick_exit (1);
}
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