From patchwork Wed Jan 11 17:48:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 90966 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1238462qgi; Wed, 11 Jan 2017 09:48:45 -0800 (PST) X-Received: by 10.84.229.137 with SMTP id c9mr14992989plk.175.1484156925832; Wed, 11 Jan 2017 09:48:45 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w21si6425859pgi.268.2017.01.11.09.48.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 09:48:45 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-14272-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of newlib-return-14272-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-14272-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=ODrU i0B5H5p363QVILSmZYlSMWEprTspSqAqejL+ugw0yabj2M03Vh1eb58brbG0hX6e mtesLoDLKw+K95ZNHS9KvNFxf2TIRFWL8WLKYPNTwHQOE0jNbovCRnhZYQv0J/qj +00r6MqqgFFx3w8XjVDQHl813YMZQnJKf011dAM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=BFUbSSaYj1 B0lZGjjBmi+unWj3A=; b=TQj+qtOBuc5OruDHJJMzGYv+ewPDkJXYQykKL5g5A0 QgNWg+yBPfe1/CoWXcfCYWo54ki6ljfEOSIRI+9J5H3p4jUu5YkM/XcumOo2sbEW JyaiQPd/ciVKgsvMJ+C9S7MzL40yyHyp7Nb7uLo0w1ZKjWwx6hdeYu5zIDlW2hLc U= Received: (qmail 32923 invoked by alias); 11 Jan 2017 17:48:34 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 32911 invoked by uid 89); 11 Jan 2017 17:48:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*i:sk:8989152, 1108, Howland, H*f:sk:8989152 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jan 2017 17:48:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 86165AD7; Wed, 11 Jan 2017 09:48:21 -0800 (PST) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 379013F24D for ; Wed, 11 Jan 2017 09:48:21 -0800 (PST) Subject: Re: [PATCH, newlib] Allow locking routine to be retargeted To: newlib@sourceware.org References: <34e2c2ad-be0f-44ed-201e-a6f294814f4e@foss.arm.com> <5851557A.4080707@embedded-brains.de> <800fa569-cd83-bd61-95e3-7ad83e053d6c@foss.arm.com> <4409ff03-7c2f-550d-a57a-6b6503bd5933@foss.arm.com> <1483987769.1304.2.camel@op.pl> <6e978ca7-e90e-5fa9-84c4-19c24a993e4a@foss.arm.com> <1484068006.1266.1.camel@op.pl> <89891529-77aa-48af-50bf-aede537a5f1d@LGSInnovations.com> From: Thomas Preudhomme Message-ID: <37230278-6fc6-b0f0-6254-c6e6882f5a99@foss.arm.com> Date: Wed, 11 Jan 2017 17:48:19 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <89891529-77aa-48af-50bf-aede537a5f1d@LGSInnovations.com> X-IsSubscribed: yes On 11/01/17 16:46, Craig Howland wrote: > On 01/11/2017 11:09 AM, Thomas Preudhomme wrote: >> Here you are. It has worked fine with my limited testing. I welcome all >> feedback about the testing you can throw at this. >> >> Best regards, >> >> Thomas > > +TRAD_SYNOPSIS > + void __retarget_lock_init(<[lock_ptr]>) > + _LOCK_T * <[lock_ptr]>; > + > + void __retarget_lock_init_recursive(<[lock_ptr]>) > + _LOCK_T * <[lock_ptr]>; > ... > > > Please leave out the TRAD_SYNOPSIS section. The documentation tools ignore > them. It is not worth the time to attempt to maintain them. (While it's not > necessarily worth the effort to go back and remove them from all the legacy > files, it makes the most sense to not put them in new things so that going > forward there is not quite as much clutter.) Very well. How about the attached patch? Best regards, Thomas diff --git a/newlib/configure b/newlib/configure index 30e1d57664302248af9087b0051290e2aff4b382..42b1e13feeda8a5b7ad3cf365393bd4640da4c8c 100755 --- a/newlib/configure +++ b/newlib/configure @@ -798,6 +798,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 @@ -1469,6 +1470,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 @@ -2470,6 +2472,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 || @@ -11776,7 +11790,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11779 "configure" +#line 11793 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11882,7 +11896,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11885 "configure" +#line 11899 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12421,6 +12435,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" \ diff --git a/newlib/configure.in b/newlib/configure.in index 01c6367a99cdf6f74a5ad15c8a4eb4a45f206e9d..70cffa76a966f8d9cd1c8888156002e76ea13dc2 100644 --- a/newlib/configure.in +++ b/newlib/configure.in @@ -218,6 +218,17 @@ AC_ARG_ENABLE(newlib_nano_formatted_io, *) AC_MSG_ERROR(bad value ${enableval} for newlib-nano-formatted-io) ;; esac],[newlib_nano_formatted_io=no]) +dnl Support --enable-retargetable-locking +dnl This option is also read in libc/configure.in. It is repeated +dnl here so that it shows up in the help text. +AC_ARG_ENABLE(newlib-retargetable-locking, +[ --enable-newlib-retargetable-locking Allow locking routines to be retargeted at link time], +[case "${enableval}" in + yes) newlib_retargetable_locking=yes ;; + no) newlib_retargetable_locking=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-retargetable-locking) ;; + esac],[newlib_retargetable_locking=no]) + NEWLIB_CONFIGURE(.) dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and @@ -442,6 +453,10 @@ if test "${newlib_nano_formatted_io}" = "yes"; then AC_DEFINE_UNQUOTED(_NANO_FORMATTED_IO) fi +if test "${newlib_retargetable_locking}" = "yes"; then +AC_DEFINE_UNQUOTED(_RETARGETABLE_LOCKING) +fi + dnl dnl Parse --enable-newlib-iconv-encodings option argument dnl diff --git a/newlib/libc/configure b/newlib/libc/configure index 5dccc852b8cd90d697a90f113ec17982741ecc3a..35077b81550aa999026ff67a7428fec6509a26ce 100755 --- a/newlib/libc/configure +++ b/newlib/libc/configure @@ -751,6 +751,8 @@ build newlib_basedir MAY_SUPPLY_SYSCALLS_FALSE MAY_SUPPLY_SYSCALLS_TRUE +NEWLIB_RETARGETABLE_LOCKING_FALSE +NEWLIB_RETARGETABLE_LOCKING_TRUE NEWLIB_NANO_FORMATTED_IO_FALSE NEWLIB_NANO_FORMATTED_IO_TRUE target_alias @@ -797,6 +799,7 @@ enable_option_checking enable_newlib_io_pos_args enable_newlib_nano_malloc enable_newlib_nano_formatted_io +enable_newlib_retargetable_locking enable_multilib enable_target_optspace enable_malloc_debugging @@ -1448,6 +1451,7 @@ Optional Features: --enable-newlib-io-pos-args enable printf-family positional arg support --enable-newlib-nano-malloc Use small-footprint nano-malloc implementation --enable-newlib-nano-formatted-io Use small-footprint nano-formatted-IO implementation + --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 @@ -2252,6 +2256,26 @@ 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_lock=no ;; + *) as_fn_error $? "bad value ${enableval} for newlib-retargetable-locking" "$LINENO" 5 ;; + esac +else + newlib_retargetable_locking=no +fi + + if test x$newlib_retargetable_locking = xyes; then + NEWLIB_RETARGETABLE_LOCKING_TRUE= + NEWLIB_RETARGETABLE_LOCKING_FALSE='#' +else + NEWLIB_RETARGETABLE_LOCKING_TRUE='#' + NEWLIB_RETARGETABLE_LOCKING_FALSE= +fi + + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || @@ -11525,7 +11549,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11528 "configure" +#line 11552 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11631,7 +11655,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11634 "configure" +#line 11658 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12248,6 +12272,10 @@ if test -z "${NEWLIB_NANO_FORMATTED_IO_TRUE}" && test -z "${NEWLIB_NANO_FORMATTE as_fn_error $? "conditional \"NEWLIB_NANO_FORMATTED_IO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${NEWLIB_RETARGETABLE_LOCKING_TRUE}" && test -z "${NEWLIB_RETARGETABLE_LOCKING_FALSE}"; then + as_fn_error $? "conditional \"NEWLIB_RETARGETABLE_LOCKING\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MAY_SUPPLY_SYSCALLS_TRUE}" && test -z "${MAY_SUPPLY_SYSCALLS_FALSE}"; then as_fn_error $? "conditional \"MAY_SUPPLY_SYSCALLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/newlib/libc/configure.in b/newlib/libc/configure.in index 0a7bb8815be44fb1e92f753fa2c8df2a31b95f94..ac25a3933c4a4794f3cfe291e0275d0ed001b96a 100644 --- a/newlib/libc/configure.in +++ b/newlib/libc/configure.in @@ -36,6 +36,16 @@ AC_ARG_ENABLE(newlib_nano_formatted_io, esac],[newlib_nano_formatted_io=no]) AM_CONDITIONAL(NEWLIB_NANO_FORMATTED_IO, test x$newlib_nano_formatted_io = xyes) +dnl Support --enable-retargetable-locking used by libc/sys +AC_ARG_ENABLE(newlib-retargetable-locking, +[ --enable-newlib-retargetable-locking Allow locking routines to be retargeted at link time], +[case "${enableval}" in + yes) newlib_retargetable_locking=yes ;; + no) newlib_retargetable_lock=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for newlib-retargetable-locking) ;; + esac],[newlib_retargetable_locking=no]) +AM_CONDITIONAL(NEWLIB_RETARGETABLE_LOCKING, test x$newlib_retargetable_locking = xyes) + NEWLIB_CONFIGURE(..) AM_CONDITIONAL(NEWLIB_NANO_MALLOC, test x$newlib_nano_malloc = xyes) diff --git a/newlib/libc/include/sys/lock.h b/newlib/libc/include/sys/lock.h index 9075e35c9179968031010432515e3a845ff6ca8d..9a8e2528c79a89d5807da8c4bb0e65151870bf42 100644 --- a/newlib/libc/include/sys/lock.h +++ b/newlib/libc/include/sys/lock.h @@ -3,10 +3,13 @@ /* dummy lock routines for single-threaded aps */ +#include +#include <_ansi.h> + +#ifndef _RETARGETABLE_LOCKING + typedef int _LOCK_T; typedef int _LOCK_RECURSIVE_T; - -#include <_ansi.h> #define __LOCK_INIT(class,lock) static int lock = 0; #define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0; @@ -21,4 +24,46 @@ typedef int _LOCK_RECURSIVE_T; #define __lock_release(lock) (_CAST_VOID 0) #define __lock_release_recursive(lock) (_CAST_VOID 0) +#else + +#ifdef __cplusplus +extern "C" { +#endif + +struct _lock; +typedef struct _lock * _LOCK_T; +#define _LOCK_RECURSIVE_T _LOCK_T + +#define __LOCK_INIT(class,lock) extern struct _lock _lock_ ## lock; \ + class _LOCK_T lock = &_lock_ ## lock +#define __LOCK_INIT_RECURSIVE(class,lock) __LOCK_INIT(class,lock) + +extern void __retarget_lock_init(_LOCK_T *lock); +#define __lock_init(lock) __retarget_lock_init(&lock) +extern void __retarget_lock_init_recursive(_LOCK_T *lock); +#define __lock_init_recursive(lock) __retarget_lock_init_recursive(&lock) +extern void __retarget_lock_close(_LOCK_T lock); +#define __lock_close(lock) __retarget_lock_close(lock) +extern void __retarget_lock_close_recursive(_LOCK_T lock); +#define __lock_close_recursive(lock) __retarget_lock_close_recursive(lock) +extern void __retarget_lock_acquire(_LOCK_T lock); +#define __lock_acquire(lock) __retarget_lock_acquire(lock) +extern void __retarget_lock_acquire_recursive(_LOCK_T lock); +#define __lock_acquire_recursive(lock) __retarget_lock_acquire_recursive(lock) +extern int __retarget_lock_try_acquire(_LOCK_T lock); +#define __lock_try_acquire(lock) __retarget_lock_try_acquire(lock) +extern int __retarget_lock_try_acquire_recursive(_LOCK_T lock); +#define __lock_try_acquire_recursive(lock) \ + __retarget_lock_try_acquire_recursive(lock) +extern void __retarget_lock_release(_LOCK_T lock); +#define __lock_release(lock) __retarget_lock_release(lock) +extern void __retarget_lock_release_recursive(_LOCK_T lock); +#define __lock_release_recursive(lock) __retarget_lock_release_recursive(lock) + +#ifdef __cplusplus +} +#endif + +#endif /* _RETARGETABLE_LOCKING */ + #endif /* __SYS_LOCK_H__ */ diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am index 2d45d1029ace8087b57657cbc11feabf76f4206e..76ed8480c28ebfb68e2f48432c0359b11f1522a8 100644 --- a/newlib/libc/stdlib/Makefile.am +++ b/newlib/libc/stdlib/Makefile.am @@ -74,6 +74,11 @@ GENERAL_SOURCES += \ wcstold.c endif # HAVE_LONG_DOUBLE +if NEWLIB_RETARGETABLE_LOCKING +GENERAL_SOURCES += \ + lock.c +endif + if NEWLIB_NANO_MALLOC MALIGNR=nano-malignr MALLOPTR=nano-malloptr diff --git a/newlib/libc/stdlib/Makefile.in b/newlib/libc/stdlib/Makefile.in index 466ab6d1e02ea919f6c8ceed792024955bef1a66..3295e981c87bac3b21a6b72dda148f892fe018d6 100644 --- a/newlib/libc/stdlib/Makefile.in +++ b/newlib/libc/stdlib/Makefile.in @@ -57,6 +57,9 @@ host_triplet = @host@ @HAVE_LONG_DOUBLE_TRUE@ strtold.c \ @HAVE_LONG_DOUBLE_TRUE@ wcstold.c +@NEWLIB_RETARGETABLE_LOCKING_TRUE@am__append_2 = \ +@NEWLIB_RETARGETABLE_LOCKING_TRUE@ lock.c + DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am subdir = stdlib @@ -81,7 +84,9 @@ lib_a_AR = $(AR) $(ARFLAGS) @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(ELIX_2_OBJS) @HAVE_LONG_DOUBLE_TRUE@am__objects_1 = lib_a-strtold.$(OBJEXT) \ @HAVE_LONG_DOUBLE_TRUE@ lib_a-wcstold.$(OBJEXT) -am__objects_2 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \ +@NEWLIB_RETARGETABLE_LOCKING_TRUE@am__objects_2 = \ +@NEWLIB_RETARGETABLE_LOCKING_TRUE@ lib_a-lock.$(OBJEXT) +am__objects_3 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \ lib_a-__call_atexit.$(OBJEXT) lib_a-__exp10.$(OBJEXT) \ lib_a-__ten_mu.$(OBJEXT) lib_a-_Exit.$(OBJEXT) \ lib_a-abort.$(OBJEXT) lib_a-abs.$(OBJEXT) \ @@ -112,8 +117,8 @@ am__objects_2 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \ lib_a-wcstol.$(OBJEXT) lib_a-wcstoul.$(OBJEXT) \ lib_a-wcstombs.$(OBJEXT) lib_a-wcstombs_r.$(OBJEXT) \ lib_a-wctomb.$(OBJEXT) lib_a-wctomb_r.$(OBJEXT) \ - $(am__objects_1) -am__objects_3 = lib_a-arc4random.$(OBJEXT) \ + $(am__objects_1) $(am__objects_2) +am__objects_4 = lib_a-arc4random.$(OBJEXT) \ lib_a-arc4random_uniform.$(OBJEXT) lib_a-cxa_atexit.$(OBJEXT) \ lib_a-cxa_finalize.$(OBJEXT) lib_a-drand48.$(OBJEXT) \ lib_a-ecvtbuf.$(OBJEXT) lib_a-efgcvt.$(OBJEXT) \ @@ -128,7 +133,7 @@ am__objects_3 = lib_a-arc4random.$(OBJEXT) \ lib_a-wcstoll_r.$(OBJEXT) lib_a-wcstoull.$(OBJEXT) \ lib_a-wcstoull_r.$(OBJEXT) lib_a-atoll.$(OBJEXT) \ lib_a-llabs.$(OBJEXT) lib_a-lldiv.$(OBJEXT) -am__objects_4 = lib_a-a64l.$(OBJEXT) lib_a-btowc.$(OBJEXT) \ +am__objects_5 = lib_a-a64l.$(OBJEXT) lib_a-btowc.$(OBJEXT) \ lib_a-getopt.$(OBJEXT) lib_a-getsubopt.$(OBJEXT) \ lib_a-l64a.$(OBJEXT) lib_a-malign.$(OBJEXT) \ lib_a-mbrlen.$(OBJEXT) lib_a-mbrtowc.$(OBJEXT) \ @@ -137,22 +142,23 @@ am__objects_4 = lib_a-a64l.$(OBJEXT) lib_a-btowc.$(OBJEXT) \ lib_a-valloc.$(OBJEXT) lib_a-wcrtomb.$(OBJEXT) \ lib_a-wcsnrtombs.$(OBJEXT) lib_a-wcsrtombs.$(OBJEXT) \ lib_a-wctob.$(OBJEXT) -am__objects_5 = lib_a-putenv.$(OBJEXT) lib_a-putenv_r.$(OBJEXT) \ +am__objects_6 = lib_a-putenv.$(OBJEXT) lib_a-putenv_r.$(OBJEXT) \ lib_a-setenv.$(OBJEXT) lib_a-setenv_r.$(OBJEXT) -am__objects_6 = lib_a-rpmatch.$(OBJEXT) lib_a-system.$(OBJEXT) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_7 = $(am__objects_4) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_5) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_6) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__objects_7 = $(am__objects_4) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ $(am__objects_5) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__objects_7 = \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(am__objects_4) -@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_2) \ -@USE_LIBTOOL_FALSE@ $(am__objects_3) $(am__objects_7) +am__objects_7 = lib_a-rpmatch.$(OBJEXT) lib_a-system.$(OBJEXT) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_8 = $(am__objects_5) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_6) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_7) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__objects_8 = $(am__objects_5) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ $(am__objects_6) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__objects_8 = \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(am__objects_5) +@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_3) \ +@USE_LIBTOOL_FALSE@ $(am__objects_4) $(am__objects_8) lib_a_OBJECTS = $(am_lib_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) -@HAVE_LONG_DOUBLE_TRUE@am__objects_8 = strtold.lo wcstold.lo -am__objects_9 = __adjust.lo __atexit.lo __call_atexit.lo __exp10.lo \ +@HAVE_LONG_DOUBLE_TRUE@am__objects_9 = strtold.lo wcstold.lo +@NEWLIB_RETARGETABLE_LOCKING_TRUE@am__objects_10 = lock.lo +am__objects_11 = __adjust.lo __atexit.lo __call_atexit.lo __exp10.lo \ __ten_mu.lo _Exit.lo abort.lo abs.lo aligned_alloc.lo \ assert.lo atexit.lo atof.lo atoff.lo atoi.lo atol.lo calloc.lo \ div.lo dtoa.lo dtoastub.lo environ.lo envlock.lo eprintf.lo \ @@ -163,28 +169,28 @@ am__objects_9 = __adjust.lo __atexit.lo __call_atexit.lo __exp10.lo \ rand_r.lo random.lo realloc.lo reallocf.lo sb_charsets.lo \ strtod.lo strtodg.lo strtol.lo strtorx.lo strtoul.lo utoa.lo \ wcstod.lo wcstol.lo wcstoul.lo wcstombs.lo wcstombs_r.lo \ - wctomb.lo wctomb_r.lo $(am__objects_8) -am__objects_10 = arc4random.lo arc4random_uniform.lo cxa_atexit.lo \ + wctomb.lo wctomb_r.lo $(am__objects_9) $(am__objects_10) +am__objects_12 = arc4random.lo arc4random_uniform.lo cxa_atexit.lo \ cxa_finalize.lo drand48.lo ecvtbuf.lo efgcvt.lo erand48.lo \ jrand48.lo lcong48.lo lrand48.lo mrand48.lo msize.lo mtrim.lo \ nrand48.lo rand48.lo seed48.lo srand48.lo strtoll.lo \ strtoll_r.lo strtoull.lo strtoull_r.lo wcstoll.lo wcstoll_r.lo \ wcstoull.lo wcstoull_r.lo atoll.lo llabs.lo lldiv.lo -am__objects_11 = a64l.lo btowc.lo getopt.lo getsubopt.lo l64a.lo \ +am__objects_13 = a64l.lo btowc.lo getopt.lo getsubopt.lo l64a.lo \ malign.lo mbrlen.lo mbrtowc.lo mbsinit.lo mbsnrtowcs.lo \ mbsrtowcs.lo on_exit.lo valloc.lo wcrtomb.lo wcsnrtombs.lo \ wcsrtombs.lo wctob.lo -am__objects_12 = putenv.lo putenv_r.lo setenv.lo setenv_r.lo -am__objects_13 = rpmatch.lo system.lo -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_14 = $(am__objects_11) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_12) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_13) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__objects_14 = $(am__objects_11) \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ $(am__objects_12) -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__objects_14 = \ -@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(am__objects_11) -@USE_LIBTOOL_TRUE@am_libstdlib_la_OBJECTS = $(am__objects_9) \ -@USE_LIBTOOL_TRUE@ $(am__objects_10) $(am__objects_14) +am__objects_14 = putenv.lo putenv_r.lo setenv.lo setenv_r.lo +am__objects_15 = rpmatch.lo system.lo +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_16 = $(am__objects_13) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_14) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_15) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__objects_16 = $(am__objects_13) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ $(am__objects_14) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__objects_16 = \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(am__objects_13) +@USE_LIBTOOL_TRUE@am_libstdlib_la_OBJECTS = $(am__objects_11) \ +@USE_LIBTOOL_TRUE@ $(am__objects_12) $(am__objects_16) libstdlib_la_OBJECTS = $(am_libstdlib_la_OBJECTS) libstdlib_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -367,7 +373,7 @@ GENERAL_SOURCES = __adjust.c __atexit.c __call_atexit.c __exp10.c \ quick_exit.c rand.c rand_r.c random.c realloc.c reallocf.c \ sb_charsets.c strtod.c strtodg.c strtol.c strtorx.c strtoul.c \ utoa.c wcstod.c wcstol.c wcstoul.c wcstombs.c wcstombs_r.c \ - wctomb.c wctomb_r.c $(am__append_1) + wctomb.c wctomb_r.c $(am__append_1) $(am__append_2) @NEWLIB_NANO_MALLOC_FALSE@MALIGNR = malignr @NEWLIB_NANO_MALLOC_TRUE@MALIGNR = nano-malignr @NEWLIB_NANO_MALLOC_FALSE@MALLOPTR = malloptr @@ -1002,6 +1008,12 @@ lib_a-wcstold.o: wcstold.c lib_a-wcstold.obj: wcstold.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstold.obj `if test -f 'wcstold.c'; then $(CYGPATH_W) 'wcstold.c'; else $(CYGPATH_W) '$(srcdir)/wcstold.c'; fi` +lib_a-lock.o: lock.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lock.o `test -f 'lock.c' || echo '$(srcdir)/'`lock.c + +lib_a-lock.obj: lock.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lock.obj `if test -f 'lock.c'; then $(CYGPATH_W) 'lock.c'; else $(CYGPATH_W) '$(srcdir)/lock.c'; fi` + lib_a-arc4random.o: arc4random.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-arc4random.o `test -f 'arc4random.c' || echo '$(srcdir)/'`arc4random.c diff --git a/newlib/libc/stdlib/lock.c b/newlib/libc/stdlib/lock.c new file mode 100644 index 0000000000000000000000000000000000000000..c0b8a173a3bae16cd91d231dff7de2b4bb8cd9e3 --- /dev/null +++ b/newlib/libc/stdlib/lock.c @@ -0,0 +1,108 @@ +/* +FUNCTION +<<__retarget_lock_init>>, <<__retarget_lock_init_recursive>>, <<__retarget_lock_close>>, <<__retarget_lock_close_recursive>>, <<__retarget_lock_acquire>>, <<__retarget_lock_acquire_recursive>>, <<__retarget_lock_try_acquire>>, <<__retarget_lock_try_acquire_recursive>>, <<__retarget_lock_release>>, <<__retarget_lock_release_recursive>>---locking routines + +INDEX + __retarget_lock_init +INDEX + __retarget_lock_init_recursive +INDEX + __retarget_lock_close +INDEX + __retarget_lock_close_recursive +INDEX + __retarget_lock_acquire +INDEX + __retarget_lock_acquire_recursive +INDEX + __retarget_lock_try_acquire +INDEX + __retarget_lock_try_acquire_recursive +INDEX + __retarget_lock_release +INDEX + __retarget_lock_release_recursive + +ANSI_SYNOPSIS + #include + void __retarget_lock_init (_LOCK_T * <[lock_ptr]>); + void __retarget_lock_init_recursive (_LOCK_T * <[lock_ptr]>); + void __retarget_lock_close (_LOCK_T <[lock]>); + void __retarget_lock_close_recursive (_LOCK_T <[lock]>); + void __retarget_lock_acquire (_LOCK_T <[lock]>); + void __retarget_lock_acquire_recursive (_LOCK_T <[lock]>); + int __retarget_lock_try_acquire (_LOCK_T <[lock]>); + int __retarget_lock_try_acquire_recursive (_LOCK_T <[lock]>); + void __retarget_lock_release (_LOCK_T <[lock]>); + void __retarget_lock_release_recursive (_LOCK_T <[lock]>); + +DESCRIPTION +These empty functions are used for locking to allow applications to retarget +them. They are used in place of the default dummy lock macros when newlib +is configured with --enable-newlib-retargetable-locking. +*/ + +/* dummy lock routines for single-threaded apps */ + +#include + +struct _lock { + char unused; +}; + +struct _lock _ATTRIBUTE((__weak__)) _lock___sinit_lock; +struct _lock _ATTRIBUTE((__weak__)) _lock___sfp_lock; +struct _lock _ATTRIBUTE((__weak__)) _lock___atexit_lock; +struct _lock _ATTRIBUTE((__weak__)) _lock___malloc_lock_object; + +void _ATTRIBUTE((__weak__)) +__retarget_lock_init (_LOCK_T *lock) +{ +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_init_recursive(_LOCK_T *lock) +{ +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_close(_LOCK_T lock) +{ +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_close_recursive(_LOCK_T lock) +{ +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_acquire (_LOCK_T lock) +{ +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_acquire_recursive (_LOCK_T lock) +{ +} + +int _ATTRIBUTE((__weak__)) +__retarget_lock_try_acquire(_LOCK_T lock) +{ + return 1; +} + +int _ATTRIBUTE((__weak__)) +__retarget_lock_try_acquire_recursive(_LOCK_T lock) +{ + return 1; +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_release (_LOCK_T lock) +{ +} + +void _ATTRIBUTE((__weak__)) +__retarget_lock_release_recursive (_LOCK_T lock) +{ +} diff --git a/newlib/newlib.hin b/newlib/newlib.hin index d03dfac0eea6a8917a92b8f0f3584c2cd42b9388..397bc9b96eafddace3a75be509157040654b6fde 100644 --- a/newlib/newlib.hin +++ b/newlib/newlib.hin @@ -82,6 +82,9 @@ /* Define if small footprint nano-formatted-IO implementation used. */ #undef _NANO_FORMATTED_IO +/* Define if using retargetable functions for default lock routines. */ +#undef _RETARGETABLE_LOCKING + /* * Iconv encodings enabled ("to" direction) */