Allow verifying _REENT_CHECK macros memory allocation
- change sys/reent.h to replace _REENT_CHECK_DEBUG with _REENT_CHECK_VERIFY which when set asserts that any memory allocated is non-NULL and calls __assert_func directly - add new --enable-newlib-reent-check-verify configure option - add support for configure.host to specify default for newlib_reent_check_verify - add _REENT_CHECK_VERIFY macro support to acconfig.h and newlib.hin
This commit is contained in:
parent
175b215e05
commit
e06f2fbde7
|
@ -26,6 +26,9 @@
|
|||
very restricted storage. */
|
||||
#undef _WANT_REENT_SMALL
|
||||
|
||||
/* Verify _REENT_CHECK macros allocate memory successfully. */
|
||||
#undef _REENT_CHECK_VERIFY
|
||||
|
||||
/* Multibyte supported */
|
||||
#undef _MB_CAPABLE
|
||||
|
||||
|
|
|
@ -788,6 +788,7 @@ enable_newlib_register_fini
|
|||
enable_newlib_io_long_long
|
||||
enable_newlib_io_long_double
|
||||
enable_newlib_mb
|
||||
enable_newlib_reent_check_verify
|
||||
enable_newlib_iconv_encodings
|
||||
enable_newlib_iconv_from_encodings
|
||||
enable_newlib_iconv_to_encodings
|
||||
|
@ -1463,6 +1464,7 @@ Optional Features:
|
|||
--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
|
||||
--enable-newlib-reent-check-verify enable checking of _REENT_CHECK memory allocation
|
||||
--enable-newlib-iconv-encodings enable specific comma-separated list of bidirectional iconv encodings to be built-in
|
||||
--enable-newlib-iconv-from-encodings enable specific comma-separated list of \"from\" iconv encodings to be built-in
|
||||
--enable-newlib-iconv-to-encodings enable specific comma-separated list of \"to\" iconv encodings to be built-in
|
||||
|
@ -2310,6 +2312,17 @@ else
|
|||
newlib_mb=
|
||||
fi
|
||||
|
||||
# Check whether --enable-newlib-reent-check-verify was given.
|
||||
if test "${enable_newlib_reent_check_verify+set}" = set; then :
|
||||
enableval=$enable_newlib_reent_check_verify; case "${enableval}" in
|
||||
yes) newlib_reent_check_verify=yes;;
|
||||
no) newlib_reent_check_verify=no ;;
|
||||
*) as_fn_error $? "bad value ${enableval} for newlib-reent-check-verify option" "$LINENO" 5 ;;
|
||||
esac
|
||||
else
|
||||
newlib_reent_check_verify=
|
||||
fi
|
||||
|
||||
# Check whether --enable-newlib-iconv-encodings was given.
|
||||
if test "${enable_newlib_iconv_encodings+set}" = set; then :
|
||||
enableval=$enable_newlib_iconv_encodings; if test x${enableval} = x; then
|
||||
|
@ -11840,7 +11853,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 11843 "configure"
|
||||
#line 11856 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -11946,7 +11959,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 11949 "configure"
|
||||
#line 11962 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -12351,6 +12364,13 @@ _ACEOF
|
|||
|
||||
fi
|
||||
|
||||
if test "${newlib_reent_check_verify}" = "yes"; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define _REENT_CHECK_VERIFY 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
if test "${newlib_io_c99_formats}" = "yes"; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define _WANT_IO_C99_FORMATS 1
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
# newlib_io_long_double --enable-newlib-io-long-double ("yes", "no", "")
|
||||
# newlib_global_stdio_streams --enable-global-stdio-streams ("yes", "no, "")
|
||||
# newlib_fno_builtin --disable-newlib-fno-builtin ("yes", "no, "")
|
||||
# newlib_reent_check_verify --enable-newlib-reent-check-verify ("yes", "no, "")
|
||||
|
||||
# It sets the following shell variables:
|
||||
# newlib_cflags Special CFLAGS to use when building
|
||||
|
@ -76,6 +77,7 @@ default_newlib_io_long_double=no
|
|||
default_newlib_io_pos_args=no
|
||||
default_newlib_atexit_dynamic_alloc=yes
|
||||
default_newlib_nano_malloc=no
|
||||
default_newlib_reent_check_verify=no
|
||||
aext=a
|
||||
oext=o
|
||||
lpfx="lib_a-"
|
||||
|
@ -952,6 +954,13 @@ if [ "x${newlib_nano_malloc}" = "x" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Enable _REENT_CHECK macro memory allocation verification.
|
||||
if [ "x${newlib_reent_check_verify}" = "x" ]; then
|
||||
if [ ${default_newlib_reent_check_verify} = "yes" ]; then
|
||||
newlib_reent_check_verify="yes";
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove rpc headers if xdr_dir not specified
|
||||
if [ "x${xdr_dir}" = "x" ]; then
|
||||
noinclude="${noinclude} rpc/types.h rpc/xdr.h"
|
||||
|
|
|
@ -66,6 +66,16 @@ AC_ARG_ENABLE(newlib-mb,
|
|||
*) AC_MSG_ERROR(bad value ${enableval} for newlib-mb option) ;;
|
||||
esac], [newlib_mb=])dnl
|
||||
|
||||
dnl Enable verification of successful memory allocation for _REENT_CHECK family of macros
|
||||
dnl Support --enable-newlib-reent-check-verify
|
||||
AC_ARG_ENABLE(newlib-reent-check-verify,
|
||||
[ --enable-newlib-reent-check-verify enable checking of _REENT_CHECK memory allocation],
|
||||
[case "${enableval}" in
|
||||
yes) newlib_reent_check_verify=yes;;
|
||||
no) newlib_reent_check_verify=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for newlib-reent-check-verify option) ;;
|
||||
esac], [newlib_reent_check_verify=])dnl
|
||||
|
||||
dnl Support --enable-newlib-iconv-encodings
|
||||
AC_ARG_ENABLE(newlib-iconv-encodings,
|
||||
[ --enable-newlib-iconv-encodings enable specific comma-separated list of bidirectional iconv encodings to be built-in],
|
||||
|
@ -396,6 +406,10 @@ if test "${newlib_elix_level}" -gt "0"; then
|
|||
AC_DEFINE_UNQUOTED(_ELIX_LEVEL,${newlib_elix_level})
|
||||
fi
|
||||
|
||||
if test "${newlib_reent_check_verify}" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(_REENT_CHECK_VERIFY)
|
||||
fi
|
||||
|
||||
if test "${newlib_io_c99_formats}" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(_WANT_IO_C99_FORMATS)
|
||||
fi
|
||||
|
|
|
@ -498,10 +498,10 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||
|
||||
#endif /* _REENT_GLOBAL_STDIO_STREAMS */
|
||||
|
||||
/* Only add assert() calls if we are specified to debug. */
|
||||
#ifdef _REENT_CHECK_DEBUG
|
||||
/* Specify how to handle reent_check malloc failures. */
|
||||
#ifdef _REENT_CHECK_VERIFY
|
||||
#include <assert.h>
|
||||
#define __reent_assert(x) assert(x)
|
||||
#define __reent_assert(x) ((x) ? (void)0 : __assert_func(__FILE__, __LINE__, (char *)0, "REENT malloc succeeded"))
|
||||
#else
|
||||
#define __reent_assert(x) ((void)0)
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
very restricted storage. */
|
||||
#undef _WANT_REENT_SMALL
|
||||
|
||||
/* Verify _REENT_CHECK macros allocate memory successfully. */
|
||||
#undef _REENT_CHECK_VERIFY
|
||||
|
||||
/* Multibyte supported */
|
||||
#undef _MB_CAPABLE
|
||||
|
||||
|
|
Loading…
Reference in New Issue