From bd54749095ee45d7136b6e7c8a1e5218749c87b6 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 25 Oct 2016 17:38:19 +0100 Subject: Allow locking routine to be retargeted At the moment when targeting bare-metal targets or systems without definition for the locking primitives newlib, uses dummy empty macros. This has the advantage of reduced size and faster implementation but does not allow the application to retarget the locking routines. Retargeting is useful for a single toolchain to support multiple systems since then it's only at link time that you know which system you are targeting. This patch adds a new configure option --enable-newlib-retargetable-locking to use dummy empty functions instead of dummy empty macros. The default is to keep the current behavior to not have any size or speed impact on targets not interested in this feature. To allow for any size of lock, the _LOCK_T type is changed into pointer to struct _lock and the _init function are tasked with allocating the locks. The platform being targeted must provide the static locks. A dummy implementation of the locking routines and static lock is provided for single-threaded applications to link successfully out of the box. To ensure that the behavior is consistent (either no locking whatsoever or working locking), the dummy implementation is strongly defined such that a partial retargeting will cause a doubly defined link error. Indeed, the linker will only pull in the file providing the dummy implementation if it cannot find an implementation for one of the routine or lock. --- newlib/configure | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'newlib/configure') diff --git a/newlib/configure b/newlib/configure index 2ac07fe06..de28c25b3 100755 --- a/newlib/configure +++ b/newlib/configure @@ -802,6 +802,7 @@ enable_newlib_nano_malloc enable_newlib_unbuf_stream_opt enable_lite_exit enable_newlib_nano_formatted_io +enable_newlib_retargetable_locking enable_multilib enable_target_optspace enable_malloc_debugging @@ -1473,6 +1474,7 @@ Optional Features: --disable-newlib-unbuf-stream-opt disable unbuffered stream optimization in streamio --enable-lite-exit enable light weight exit --enable-newlib-nano-formatted-io Use nano version formatted IO + --enable-newlib-retargetable-locking Allow locking routines to be retargeted at link time --enable-multilib build many library versions (default) --enable-target-optspace optimize for space --enable-malloc-debugging indicate malloc debugging requested @@ -2474,6 +2476,18 @@ else fi +# Check whether --enable-newlib-retargetable-locking was given. +if test "${enable_newlib_retargetable_locking+set}" = set; then : + enableval=$enable_newlib_retargetable_locking; case "${enableval}" in + yes) newlib_retargetable_locking=yes ;; + no) newlib_retargetable_locking=no ;; + *) as_fn_error $? "bad value ${enableval} for newlib-retargetable-locking" "$LINENO" 5 ;; + esac +else + newlib_retargetable_locking=no +fi + + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || @@ -11780,7 +11794,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11783 "configure" +#line 11797 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11886,7 +11900,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11889 "configure" +#line 11903 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12455,6 +12469,13 @@ _ACEOF fi +if test "${newlib_retargetable_locking}" = "yes"; then +cat >>confdefs.h <<_ACEOF +#define _RETARGETABLE_LOCKING 1 +_ACEOF + +fi + if test "x${iconv_encodings}" != "x" \ || test "x${iconv_to_encodings}" != "x" \ -- cgit v1.2.3