From 58d6976a6e8cf1af0cf2747d5b8caa05eb765487 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 8 Jun 2010 18:44:14 +0000 Subject: [PATCH] 2010-06-08 Jeff Johnston * configure.in: Add test for enable-newlib-register-fini to set the _WANT_REGISTER_FINI flag. * configure: Regenerated. * Makefile.in: Ditto. * newlib.hin: Add _WANT_REGISTER_FINI flag. * libc/stdlib/__call_atexit.c: Add test for _WANT_REGISTER_FINI to enable the register_fini function. --- newlib/ChangeLog | 10 ++++++++++ newlib/configure | 26 ++++++++++++++++++++++++-- newlib/configure.in | 13 +++++++++++++ newlib/libc/stdlib/__call_atexit.c | 4 ++++ newlib/newlib.hin | 3 +++ 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 00d0bc86e..b0d12cf52 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,13 @@ +2010-06-08 Jeff Johnston + + * configure.in: Add test for enable-newlib-register-fini + to set the _WANT_REGISTER_FINI flag. + * configure: Regenerated. + * Makefile.in: Ditto. + * newlib.hin: Add _WANT_REGISTER_FINI flag. + * libc/stdlib/__call_atexit.c: Add test for + _WANT_REGISTER_FINI to enable the register_fini function. + 2010-06-04 Mark Mitchell * libc/stdlib/__call_atexit.c (__libc_fini): Declare. diff --git a/newlib/configure b/newlib/configure index 9d06d32a0..8dd6254ec 100755 --- a/newlib/configure +++ b/newlib/configure @@ -822,6 +822,7 @@ ac_user_opts=' enable_option_checking enable_newlib_io_pos_args enable_newlib_io_c99_formats +enable_newlib_register_fini enable_newlib_io_long_long enable_newlib_io_long_double enable_newlib_mb @@ -1495,6 +1496,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-newlib-io-pos-args enable printf-family positional arg support --enable-newlib-io-c99-formats enable C99 support in IO functions like printf/scanf + --enable-newlib-register-fini enable finalization function registration using atexit --enable-newlib-io-long-long enable long long type support in IO functions like printf/scanf --enable-newlib-io-long-double enable long double type support in IO functions printf/scanf --enable-newlib-mb enable multibyte support @@ -2051,6 +2053,19 @@ else newlib_io_c99_formats= fi +# Check whether --enable-newlib-register-fini was given. +if test "${enable_newlib_register_fini+set}" = set; then + enableval=$enable_newlib_register_fini; case "${enableval}" in + yes) newlib_register_fini=yes;; + no) newlib_register_fini=no ;; + *) { { $as_echo "$as_me:$LINENO: error: bad value ${enableval} for newlib-register-fini option" >&5 +$as_echo "$as_me: error: bad value ${enableval} for newlib-register-fini option" >&2;} + { (exit 1); exit 1; }; } ;; + esac +else + newlib_register_fini= +fi + # Check whether --enable-newlib-io-long-long was given. if test "${enable_newlib_io_long_long+set}" = set; then enableval=$enable_newlib_io_long_long; case "${enableval}" in @@ -12590,7 +12605,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12593 "configure" +#line 12608 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12696,7 +12711,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12699 "configure" +#line 12714 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13083,6 +13098,13 @@ _ACEOF fi +if test "${newlib_register_fini}" = "yes"; then +cat >>confdefs.h <<_ACEOF +#define _WANT_REGISTER_FINI 1 +_ACEOF + +fi + if test "${newlib_io_long_long}" = "yes"; then cat >>confdefs.h <<_ACEOF #define _WANT_IO_LONG_LONG 1 diff --git a/newlib/configure.in b/newlib/configure.in index 8fe01f310..b6e5dee3c 100644 --- a/newlib/configure.in +++ b/newlib/configure.in @@ -29,6 +29,15 @@ AC_ARG_ENABLE(newlib-io-c99-formats, *) AC_MSG_ERROR(bad value ${enableval} for newlib-io-c99-formats option) ;; esac], [newlib_io_c99_formats=])dnl +dnl Support --enable-newlib-register-fini +AC_ARG_ENABLE(newlib-register-fini, +[ --enable-newlib-register-fini enable finalization function registration using atexit], +[case "${enableval}" in + yes) newlib_register_fini=yes;; + no) newlib_register_fini=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-register-fini option) ;; + esac], [newlib_register_fini=])dnl + dnl Support --enable-newlib-io-long-long AC_ARG_ENABLE(newlib-io-long-long, [ --enable-newlib-io-long-long enable long long type support in IO functions like printf/scanf], @@ -244,6 +253,10 @@ if test "${newlib_io_c99_formats}" = "yes"; then AC_DEFINE_UNQUOTED(_WANT_IO_C99_FORMATS) fi +if test "${newlib_register_fini}" = "yes"; then +AC_DEFINE_UNQUOTED(_WANT_REGISTER_FINI) +fi + if test "${newlib_io_long_long}" = "yes"; then AC_DEFINE_UNQUOTED(_WANT_IO_LONG_LONG) fi diff --git a/newlib/libc/stdlib/__call_atexit.c b/newlib/libc/stdlib/__call_atexit.c index c99b2744e..4c4506343 100644 --- a/newlib/libc/stdlib/__call_atexit.c +++ b/newlib/libc/stdlib/__call_atexit.c @@ -15,6 +15,8 @@ void free(void *) _ATTRIBUTE((__weak__)); extern _LOCK_RECURSIVE_T __atexit_lock; #endif +#ifdef _WANT_REGISTER_FINI + /* If "__libc_fini" is defined, finalizers (either "__libc_fini_array", or "_fini", as appropriate) will be run after all user-specified atexit handlers. For example, you can define @@ -51,6 +53,8 @@ register_fini(void) } } +#endif /* _WANT_REGISTER_FINI */ + /* * Call registered exit handlers. If D is null then all handlers are called, * otherwise only the handlers from that DSO are called. diff --git a/newlib/newlib.hin b/newlib/newlib.hin index 1ac25178c..3c5338685 100644 --- a/newlib/newlib.hin +++ b/newlib/newlib.hin @@ -19,6 +19,9 @@ /* long long type support in IO functions like printf/scanf enabled */ #undef _WANT_IO_LONG_LONG +/* Register application finalization function using atexit. */ +#undef _WANT_REGISTER_FINI + /* long double type support in IO functions like printf/scanf enabled */ #undef _WANT_IO_LONG_DOUBLE