Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2019-10-07 22:29:33 +0300
committerJeff Johnston <jjohnstn@redhat.com>2019-10-07 22:36:03 +0300
commite06f2fbde7d9d8ca3d363035dacbbc4b81e29c9a (patch)
treedf1831d7edb2fe3f0273f19faa38dfdf78584b50 /newlib
parent175b215e054a8cee50d91317f3af22a3b2c3d320 (diff)
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
Diffstat (limited to 'newlib')
-rw-r--r--newlib/acconfig.h3
-rwxr-xr-xnewlib/configure24
-rw-r--r--newlib/configure.host9
-rw-r--r--newlib/configure.in14
-rw-r--r--newlib/libc/include/sys/reent.h6
-rw-r--r--newlib/newlib.hin3
6 files changed, 54 insertions, 5 deletions
diff --git a/newlib/acconfig.h b/newlib/acconfig.h
index de26c5ef3..c28f7d692 100644
--- a/newlib/acconfig.h
+++ b/newlib/acconfig.h
@@ -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
diff --git a/newlib/configure b/newlib/configure
index 6eef23c40..55c664206 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -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
diff --git a/newlib/configure.host b/newlib/configure.host
index 87bf78a3a..fe7d9b7b5 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -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"
diff --git a/newlib/configure.in b/newlib/configure.in
index adce036bf..ec5039d2b 100644
--- a/newlib/configure.in
+++ b/newlib/configure.in
@@ -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
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 7f8124deb..74b70e9c0 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -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
diff --git a/newlib/newlib.hin b/newlib/newlib.hin
index 18306f293..416d0c629 100644
--- a/newlib/newlib.hin
+++ b/newlib/newlib.hin
@@ -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