This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ARM] Reorganize memchr selection.


This patch cleans up the auto configury mechanism used to select
different implementations of memchr for various architecture versions.

The approach here is to remove the selection of memchr within automake
and instead use complimentary logic in memchr-stub.c and memchr.S to
choose between the gerneric memchr.c implementation or one of the
architecture specific implementations.

This patch also changes the selection criteria inline with the
previous proposal here:

https://sourceware.org/ml/newlib/2015/msg00752.html

but using the ACLE predefines.

Regressed for armv7-a armv5 armv8-a, correct selection of memcpy
implementation by manual inspection of a test program built for these
three architectures.

OK?

/Marcus
From 267b0addc2c853e3566a3a5c505ab0d5d9e21f2f Mon Sep 17 00:00:00 2001
From: Marcus Shawcroft <marcus.shawcroft@arm.com>
Date: Tue, 3 Nov 2015 14:17:56 +0000
Subject: [PATCH 2/4] [ARM] Reorganize memchr selection.

The patch cleans up the auto configury mechanism used to select
different implementations of memchr for various architecture versions.

The approach here is to remove the selection of memchr within automake
and instead use complimentary logic in memchr-stub.c and memchr.S to
choose between the gerneric memchr.c implementation or one of the
architecture specific implementations.

This patch also changes the selection criteria inline with the
previous proposal here:

https://sourceware.org/ml/newlib/2015/msg00752.html

but using the ACLE predefines.

Regressed for armv7-a armv5 armv8-a, correct selection of memcpy
implementation by manual inspection of a test program built for these
three architectures.

OK?
---
 newlib/ChangeLog                      | 10 +++++++
 newlib/libc/machine/arm/Makefile.am   | 20 +++++++-------
 newlib/libc/machine/arm/Makefile.in   | 50 +++++++++++++++++++----------------
 newlib/libc/machine/arm/configure     | 48 ---------------------------------
 newlib/libc/machine/arm/configure.in  | 26 ------------------
 newlib/libc/machine/arm/memchr-stub.c | 36 +++++++++++++++++++++++++
 newlib/libc/machine/arm/memchr.S      | 44 +++++++++++++++++++-----------
 7 files changed, 111 insertions(+), 123 deletions(-)
 create mode 100644 newlib/libc/machine/arm/memchr-stub.c

diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index a1eedc4..0ee4732 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,5 +1,15 @@
 2015-11-05  Marcus Shawcroft  <marcus.shawcroft@arm.com>
 
+	* libc/machine/arm/Makefile.am: Drop MEMCHR_SRC and MEMCHR_OBJ.
+	* libc/machine/arm/Makefile.in: Regenerate.
+	* libc/machine/arm/memchr-stub.c: New.
+	* libc/machine/arm/memchr.S: Adjust comments.  Include memchr.c and
+	acle-compat.h
+	* libc/machine/arm/configure.in (HAVE_ARMV7): Remove.
+	* libc/machine/arm/configure: Regenerate.
+
+2015-11-05  Marcus Shawcroft  <marcus.shawcroft@arm.com>
+
 	* libc/machine/arm/Makefile.am: Drop MEMCPY_SRC and MEMCPY_OBJ.
 	* libc/machine/arm/Makefile.in: Regenerate.
 	* libc/machine/arm/configure.in: Remove HAVE_ARMV8A, HAVE_ARMV7A and
diff --git a/newlib/libc/machine/arm/Makefile.am b/newlib/libc/machine/arm/Makefile.am
index 70afdf1..3903b53 100644
--- a/newlib/libc/machine/arm/Makefile.am
+++ b/newlib/libc/machine/arm/Makefile.am
@@ -21,31 +21,26 @@ STRLEN_SRC=strlen.c
 STRLEN_OBJ=$(lpfx)strlen.o
 endif
 
-if HAVE_ARMV7
-MEMCHR_SRC=memchr.S
-MEMCHR_OBJ=$(lpfx)memchr.o
-else
-MEMCHR_SRC=
-MEMCHR_OBJ=
-endif
-
 lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c \
-		$(MEMCHR_SRC) $(STRLEN_SRC) \
+		$(STRLEN_SRC) \
 		strlen-armv7.S aeabi_memcpy.c aeabi_memcpy-armv7a.S \
 		aeabi_memmove.c aeabi_memmove-soft.S \
 		aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c
+lib_a_SOURCES += memchr-stub.c
+lib_a_SOURCES += memchr.S
 lib_a_SOURCES += memcpy-stub.c
 lib_a_SOURCES += memcpy.S
 
 lib_a_CCASFLAGS=$(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
-lib_a_LIBADD = $(STRLEN_OBJ) $(MEMCHR_OBJ)
+lib_a_LIBADD = $(STRLEN_OBJ)
 
-lib_a_DEPENDENCIES = $(STRLEN_OBJ) $(MEMCHR_OBJ)
+lib_a_DEPENDENCIES = $(STRLEN_OBJ)
 
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 
+MEMCHR_DEP=acle-compat.h arm_asm.h
 MEMCPY_DEP=memcpy-armv7a.S memcpy-armv7m.S
 STRCMP_DEP=strcmp-arm-tiny.S strcmp-armv4.S strcmp-armv4t.S strcmp-armv6.S \
 	strcmp-armv6m.S strcmp-armv7.S strcmp-armv7m.S
@@ -54,6 +49,9 @@ AEABI_MEMMOVE_DEP=aeabi_memmove-thumb.S aeabi_memmove-thumb2.S \
 AEABI_MEMSET_DEP=aeabi_memset-thumb.S aeabi_memset-thumb2.S \
 	aeabi_memset-arm.S
 
+$(lpfx)memchr.o: $(MEMCHR_DEP)
+$(lpfx)memchr.obj: $(MEMCHR_DEP)
+
 $(lpfx)memcpy.o: $(MEMCPY_DEP)
 
 $(lpfx)memcpy.obj: $(MEMCPY_DEP)
diff --git a/newlib/libc/machine/arm/Makefile.in b/newlib/libc/machine/arm/Makefile.in
index 8b69c12..7fd375a 100644
--- a/newlib/libc/machine/arm/Makefile.in
+++ b/newlib/libc/machine/arm/Makefile.in
@@ -70,20 +70,18 @@ ARFLAGS = cru
 lib_a_AR = $(AR) $(ARFLAGS)
 @HAVE_THUMB1_FALSE@am__DEPENDENCIES_1 = $(lpfx)strlen.o
 @HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__DEPENDENCIES_1 = $(lpfx)strlen.o
-@HAVE_ARMV7_TRUE@am__DEPENDENCIES_2 = $(lpfx)memchr.o
-@HAVE_ARMV7_TRUE@am__objects_1 = lib_a-memchr.$(OBJEXT)
-@HAVE_THUMB1_FALSE@am__objects_2 = lib_a-strlen.$(OBJEXT)
-@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__objects_2 =  \
+@HAVE_THUMB1_FALSE@am__objects_1 = lib_a-strlen.$(OBJEXT)
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__objects_1 =  \
 @HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@	lib_a-strlen.$(OBJEXT)
 am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-access.$(OBJEXT) \
 	lib_a-strcmp.$(OBJEXT) lib_a-strcpy.$(OBJEXT) $(am__objects_1) \
-	$(am__objects_2) lib_a-strlen-armv7.$(OBJEXT) \
-	lib_a-aeabi_memcpy.$(OBJEXT) \
+	lib_a-strlen-armv7.$(OBJEXT) lib_a-aeabi_memcpy.$(OBJEXT) \
 	lib_a-aeabi_memcpy-armv7a.$(OBJEXT) \
 	lib_a-aeabi_memmove.$(OBJEXT) \
 	lib_a-aeabi_memmove-soft.$(OBJEXT) \
 	lib_a-aeabi_memset.$(OBJEXT) lib_a-aeabi_memset-soft.$(OBJEXT) \
-	lib_a-aeabi_memclr.$(OBJEXT) lib_a-memcpy-stub.$(OBJEXT) \
+	lib_a-aeabi_memclr.$(OBJEXT) lib_a-memchr-stub.$(OBJEXT) \
+	lib_a-memchr.$(OBJEXT) lib_a-memcpy-stub.$(OBJEXT) \
 	lib_a-memcpy.$(OBJEXT)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -217,21 +215,18 @@ noinst_LIBRARIES = lib.a
 @HAVE_THUMB1_FALSE@STRLEN_OBJ = $(lpfx)strlen.o
 @HAVE_THUMB1_TRUE@@OPT_SIZE_FALSE@STRLEN_OBJ = 
 @HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@STRLEN_OBJ = $(lpfx)strlen.o
-@HAVE_ARMV7_FALSE@MEMCHR_SRC = 
-@HAVE_ARMV7_TRUE@MEMCHR_SRC = memchr.S
-@HAVE_ARMV7_FALSE@MEMCHR_OBJ = 
-@HAVE_ARMV7_TRUE@MEMCHR_OBJ = $(lpfx)memchr.o
-lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c $(MEMCHR_SRC) \
-	$(STRLEN_SRC) strlen-armv7.S aeabi_memcpy.c \
-	aeabi_memcpy-armv7a.S aeabi_memmove.c aeabi_memmove-soft.S \
-	aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c \
+lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c $(STRLEN_SRC) \
+	strlen-armv7.S aeabi_memcpy.c aeabi_memcpy-armv7a.S \
+	aeabi_memmove.c aeabi_memmove-soft.S aeabi_memset.c \
+	aeabi_memset-soft.S aeabi_memclr.c memchr-stub.c memchr.S \
 	memcpy-stub.c memcpy.S
 lib_a_CCASFLAGS = $(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
-lib_a_LIBADD = $(STRLEN_OBJ) $(MEMCHR_OBJ)
-lib_a_DEPENDENCIES = $(STRLEN_OBJ) $(MEMCHR_OBJ)
+lib_a_LIBADD = $(STRLEN_OBJ)
+lib_a_DEPENDENCIES = $(STRLEN_OBJ)
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
+MEMCHR_DEP = acle-compat.h arm_asm.h
 MEMCPY_DEP = memcpy-armv7a.S memcpy-armv7m.S
 STRCMP_DEP = strcmp-arm-tiny.S strcmp-armv4.S strcmp-armv4t.S strcmp-armv6.S \
 	strcmp-armv6m.S strcmp-armv7.S strcmp-armv7m.S
@@ -312,12 +307,6 @@ lib_a-strcmp.o: strcmp.S
 lib_a-strcmp.obj: strcmp.S
 	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strcmp.obj `if test -f 'strcmp.S'; then $(CYGPATH_W) 'strcmp.S'; else $(CYGPATH_W) '$(srcdir)/strcmp.S'; fi`
 
-lib_a-memchr.o: memchr.S
-	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memchr.o `test -f 'memchr.S' || echo '$(srcdir)/'`memchr.S
-
-lib_a-memchr.obj: memchr.S
-	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memchr.obj `if test -f 'memchr.S'; then $(CYGPATH_W) 'memchr.S'; else $(CYGPATH_W) '$(srcdir)/memchr.S'; fi`
-
 lib_a-strlen-armv7.o: strlen-armv7.S
 	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-strlen-armv7.o `test -f 'strlen-armv7.S' || echo '$(srcdir)/'`strlen-armv7.S
 
@@ -342,6 +331,12 @@ lib_a-aeabi_memset-soft.o: aeabi_memset-soft.S
 lib_a-aeabi_memset-soft.obj: aeabi_memset-soft.S
 	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-aeabi_memset-soft.obj `if test -f 'aeabi_memset-soft.S'; then $(CYGPATH_W) 'aeabi_memset-soft.S'; else $(CYGPATH_W) '$(srcdir)/aeabi_memset-soft.S'; fi`
 
+lib_a-memchr.o: memchr.S
+	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memchr.o `test -f 'memchr.S' || echo '$(srcdir)/'`memchr.S
+
+lib_a-memchr.obj: memchr.S
+	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memchr.obj `if test -f 'memchr.S'; then $(CYGPATH_W) 'memchr.S'; else $(CYGPATH_W) '$(srcdir)/memchr.S'; fi`
+
 lib_a-memcpy.o: memcpy.S
 	$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-memcpy.o `test -f 'memcpy.S' || echo '$(srcdir)/'`memcpy.S
 
@@ -396,6 +391,12 @@ lib_a-aeabi_memclr.o: aeabi_memclr.c
 lib_a-aeabi_memclr.obj: aeabi_memclr.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-aeabi_memclr.obj `if test -f 'aeabi_memclr.c'; then $(CYGPATH_W) 'aeabi_memclr.c'; else $(CYGPATH_W) '$(srcdir)/aeabi_memclr.c'; fi`
 
+lib_a-memchr-stub.o: memchr-stub.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memchr-stub.o `test -f 'memchr-stub.c' || echo '$(srcdir)/'`memchr-stub.c
+
+lib_a-memchr-stub.obj: memchr-stub.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memchr-stub.obj `if test -f 'memchr-stub.c'; then $(CYGPATH_W) 'memchr-stub.c'; else $(CYGPATH_W) '$(srcdir)/memchr-stub.c'; fi`
+
 lib_a-memcpy-stub.o: memcpy-stub.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy-stub.o `test -f 'memcpy-stub.c' || echo '$(srcdir)/'`memcpy-stub.c
 
@@ -573,6 +574,9 @@ uninstall-am:
 	uninstall-am
 
 
+$(lpfx)memchr.o: $(MEMCHR_DEP)
+$(lpfx)memchr.obj: $(MEMCHR_DEP)
+
 $(lpfx)memcpy.o: $(MEMCPY_DEP)
 
 $(lpfx)memcpy.obj: $(MEMCPY_DEP)
diff --git a/newlib/libc/machine/arm/configure b/newlib/libc/machine/arm/configure
index eb62361..ce982c6 100755
--- a/newlib/libc/machine/arm/configure
+++ b/newlib/libc/machine/arm/configure
@@ -565,8 +565,6 @@ ac_unique_file="Makefile.am"
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 CFLAGS
-HAVE_ARMV7_FALSE
-HAVE_ARMV7_TRUE
 OPT_SIZE_FALSE
 OPT_SIZE_TRUE
 HAVE_THUMB1_FALSE
@@ -3501,48 +3499,6 @@ else
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether armv7 processor is supported" >&5
-$as_echo_n "checking whether armv7 processor is supported... " >&6; }
-if ${acnewlib_cv_armv7_processor+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat > conftest.c <<EOF
-
-#if defined (_ISA_ARM_7) || defined (__ARM_ARCH_6T2__)
-  #define HAVE_ARMV7
- #else
-  #error "ARMV7 is not supported."
-#endif
-int main () {
-  return 0;
-}
-EOF
-if { ac_try='${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
-							1>&5'
-  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }
-then
-  acnewlib_cv_armv7_processor=yes;
-else
-  acnewlib_cv_armv7_processor=no;
-fi
-rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acnewlib_cv_armv7_processor" >&5
-$as_echo "$acnewlib_cv_armv7_processor" >&6; }
-
- if test x"$acnewlib_cv_armv7_processor" = x"yes"; then
-  HAVE_ARMV7_TRUE=
-  HAVE_ARMV7_FALSE='#'
-else
-  HAVE_ARMV7_TRUE='#'
-  HAVE_ARMV7_FALSE=
-fi
-
-
 
 
 ac_config_files="$ac_config_files Makefile"
@@ -3741,10 +3697,6 @@ if test -z "${OPT_SIZE_TRUE}" && test -z "${OPT_SIZE_FALSE}"; then
   as_fn_error $? "conditional \"OPT_SIZE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${HAVE_ARMV7_TRUE}" && test -z "${HAVE_ARMV7_FALSE}"; then
-  as_fn_error $? "conditional \"HAVE_ARMV7\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
diff --git a/newlib/libc/machine/arm/configure.in b/newlib/libc/machine/arm/configure.in
index b76f731..ad7bfe0 100644
--- a/newlib/libc/machine/arm/configure.in
+++ b/newlib/libc/machine/arm/configure.in
@@ -60,32 +60,6 @@ rm -f conftest*])
 
 AM_CONDITIONAL(OPT_SIZE, test x"$acnewlib_cv_opt_size" = x"yes")
 
-dnl Check for whether ARM_7 or ARM_ARCH_6T2 is defined.
-dnl This macro is used to support memchr() for old CPU.
-AC_CACHE_CHECK(whether armv7 processor is supported,
-	       acnewlib_cv_armv7_processor, [dnl
-cat > conftest.c <<EOF
-
-#if defined (_ISA_ARM_7) || defined (__ARM_ARCH_6T2__)
-  #define HAVE_ARMV7
- #else
-  #error "ARMV7 is not supported."
-#endif
-int main () {
-  return 0;
-}
-EOF
-if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
-							1>&AS_MESSAGE_LOG_FD])
-then
-  acnewlib_cv_armv7_processor=yes;
-else
-  acnewlib_cv_armv7_processor=no;
-fi
-rm -f conftest*])
-
-AM_CONDITIONAL(HAVE_ARMV7, test x"$acnewlib_cv_armv7_processor" = x"yes")
-
 AC_SUBST(CFLAGS)
 
 AC_CONFIG_FILES([Makefile])
diff --git a/newlib/libc/machine/arm/memchr-stub.c b/newlib/libc/machine/arm/memchr-stub.c
new file mode 100644
index 0000000..21ffbbd
--- /dev/null
+++ b/newlib/libc/machine/arm/memchr-stub.c
@@ -0,0 +1,36 @@
+/* Copyright (c) 2015 ARM Ltd.
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+       * Redistributions of source code must retain the above copyright
+	 notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above copyright
+	 notice, this list of conditions and the following disclaimer in the
+	 documentation and/or other materials provided with the distribution.
+       * Neither the name of the Linaro nor the
+	 names of its contributors may be used to endorse or promote products
+	 derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
+
+/* The structure of the following #if #else #endif conditional chain
+   must match the chain in memchr.S.  */
+
+#include "acle-compat.h"
+
+#if __ARM_ARCH_ISA_THUMB >= 2 && defined (__ARM_FEATURE_DSP)
+/* Defined in memchr.S.  */
+#else
+# include "../../string/memchr.c"
+#endif
diff --git a/newlib/libc/machine/arm/memchr.S b/newlib/libc/machine/arm/memchr.S
index a17dfa3..0f2c938 100644
--- a/newlib/libc/machine/arm/memchr.S
+++ b/newlib/libc/machine/arm/memchr.S
@@ -35,6 +35,32 @@
    an optimised path for large data sets; the worst case is finding the
    match early in a large data set. */
 
+/* Copyright (c) 2015 ARM Ltd.
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+       * Redistributions of source code must retain the above copyright
+	 notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above copyright
+	 notice, this list of conditions and the following disclaimer in the
+	 documentation and/or other materials provided with the distribution.
+       * Neither the name of the Linaro nor the
+	 names of its contributors may be used to endorse or promote products
+	 derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
+
 @ 2011-02-07 david.gilbert@linaro.org
 @    Extracted from local git a5b438d861
 @ 2011-07-14 david.gilbert@linaro.org
@@ -50,10 +76,11 @@
 	.syntax unified
 	.arch armv6t2
 
+#include "acle-compat.h"
 #include "arm_asm.h"
 
 @ NOTE: This ifdef MUST match the one in memchr-stub.c
-#if defined(_ISA_ARM_7) || defined(__ARM_ARCH_6T2__)
+#if __ARM_ARCH_ISA_THUMB >= 2 && defined (__ARM_FEATURE_DSP)
 
 @ this lets us check a flag in a 00/ff byte easily in either endianness
 #ifdef __ARMEB__
@@ -165,18 +192,5 @@ memchr:
 	subs	r0,r0,#1
 	bx	lr
 #else
-  /* For an older CPU we just fall back to the .c code.  */
-
-  /* Leave this field blank.  So the memchr() is not defined, and this will
-     automatically pull in the default C definition of memchr() from
-     ../../string/memchr.c.  No need to include this file explicitely.
-     The lib_a-memchr.o will not be generated, so it won't replace the
-     default lib_a-memchr.o which is generated by ../../string/memchr.c.
-     See the commands in configure.in and Makefile.am for more details.
-
-     However, if we need to rewrite this function to be more efficient, we
-     can add the corresponding assembly code into this field and change the
-     commands in configure.in and Makefile.am to allow the corresponding
-     lib_a-memchr.o to be generated.
-  */
+  /* Defined in memchr-stub.c.  */
 #endif
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]