Update newlib to support efficient string operation functions for Thumb.

Hale Wang Hale.Wang@arm.com
Tue Aug 26 09:45:00 GMT 2014


Hi,

This patch is used to resubmit the previous newlib patch. And at the same time, this patch can also clean up the arm backend in newlib.

The memchr-stub.c and memcpy-stub.c are redundant. There is no need to explicitely include the corresponding source files(../../string/*.c).

Jeff Johnston provided a cleaner way to realize this. This patch use this solution to clean up all the functions in newlib/libc/machine/arm.

By the way, the previous issue fixed in the previous patch is also included in this patch.

Bootstrap and no make check regression on X86-64.

Patch also attached for convenience.

Thanks and Best Regards,
Hale Wang

=============================================================
newlib/ChangeLog:

2014-08-25  Hale Wang  <hale.wang@arm.com>
	* libc/machine/arm/memchr.S: Clean up the wrapper.
	* libc/machine/arm/memcpy.S: Likewise.
	* libc/machine/arm/memchr-stub.c: Delete this redundant file.
	* libc/machine/arm/memcpy-stub.c: Likewise.
	* libc/machine/arm/strcmp.S: Add speed-preferred wrapper.
	* libc/machine/arm/strlen.S: Likewise.
	* libc/machine/arm/Makefile.am: Add dependencies.
	* libc/machine/arm/Makefile.in: Regenerated.
	* libc/machine/arm/configure.in: Add dependencies.
	* libc/machine/arm/configure: Regenerated.

=============================================================

diff --git a/newlib/libc/machine/arm/Makefile.am b/newlib/libc/machine/arm/Makefile.am
index fb33926..ad14ae2 100644
--- a/newlib/libc/machine/arm/Makefile.am
+++ b/newlib/libc/machine/arm/Makefile.am
@@ -6,13 +6,60 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
 AM_CCASFLAGS = $(INCLUDES)
 
+if HAVE_THUMB1
+if OPT_SIZE
+STRCMP_SRC=strcmp.S
+STRCMP_OBJ=$(lpfx)strcmp.o
+STRLEN_SRC=strlen.c
+STRLEN_OBJ=$(lpfx)strlen.o
+else
+STRCMP_SRC=
+STRCMP_OBJ=
+STRLEN_SRC=
+STRLEN_OBJ=
+endif
+else
+STRCMP_SRC=strcmp.S
+STRCMP_OBJ=$(lpfx)strcmp.o
+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
+
+if OPT_SIZE
+MEMCPY_SRC=
+MEMCPY_OBJ=
+else
+if HAVE_ARMV7A
+MEMCPY_SRC=memcpy.S
+MEMCPY_OBJ=$(lpfx)memcpy.o
+else
+if HAVE_ARMV7M
+MEMCPY_SRC=memcpy.S
+MEMCPY_OBJ=$(lpfx)memcpy.o
+else
+MEMCPY_SRC=
+MEMCPY_OBJ=
+endif !HAVE_ARMV7M
+endif !HAVE_ARMV7A
+endif !OPT_SIZE
+
 noinst_LIBRARIES = lib.a
 
-lib_a_SOURCES = setjmp.S access.c strlen.c strcmp.S strcpy.c \
-	        memcpy.S memcpy-stub.c memchr-stub.c memchr.S \
-		strlen.c strlen-armv7.S
+lib_a_SOURCES = setjmp.S access.c $(STRCMP_SRC) strcpy.c \
+	        $(MEMCPY_SRC) $(MEMCHR_SRC) $(STRLEN_SRC) \
+		strlen-armv7.S
 lib_a_CCASFLAGS=$(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
+lib_a_LIBADD = $(STRCMP_OBJ) $(STRLEN_OBJ) $(MEMCHR_OBJ) $(MEMCPY_OBJ)
+lib_a_DEPENDENCIES = $(STRCMP_OBJ) $(STRLEN_OBJ) $(MEMCHR_OBJ) $(MEMCPY_OBJ)
 
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff --git a/newlib/libc/machine/arm/Makefile.in b/newlib/libc/machine/arm/Makefile.in
index 1ccfac5..ac39f7f 100644
--- a/newlib/libc/machine/arm/Makefile.in
+++ b/newlib/libc/machine/arm/Makefile.in
@@ -68,13 +68,27 @@ CONFIG_CLEAN_VPATH_FILES =
 LIBRARIES = $(noinst_LIBRARIES)
 ARFLAGS = cru
 lib_a_AR = $(AR) $(ARFLAGS)
-lib_a_LIBADD =
+@HAVE_THUMB1_FALSE@am__DEPENDENCIES_1 = $(lpfx)strcmp.o
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__DEPENDENCIES_1 = $(lpfx)strcmp.o
+@HAVE_THUMB1_FALSE@am__DEPENDENCIES_2 = $(lpfx)strlen.o
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__DEPENDENCIES_2 = $(lpfx)strlen.o
+@HAVE_ARMV7_TRUE@am__DEPENDENCIES_3 = $(lpfx)memchr.o
+@HAVE_ARMV7A_FALSE@@HAVE_ARMV7M_TRUE@@OPT_SIZE_FALSE@am__DEPENDENCIES_4 = $(lpfx)memcpy.o
+@HAVE_ARMV7A_TRUE@@OPT_SIZE_FALSE@am__DEPENDENCIES_4 =  \
+@HAVE_ARMV7A_TRUE@@OPT_SIZE_FALSE@	$(lpfx)memcpy.o
+@HAVE_THUMB1_FALSE@am__objects_1 = lib_a-strcmp.$(OBJEXT)
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__objects_1 =  \
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@	lib_a-strcmp.$(OBJEXT)
+@HAVE_ARMV7A_FALSE@@HAVE_ARMV7M_TRUE@@OPT_SIZE_FALSE@am__objects_2 = lib_a-memcpy.$(OBJEXT)
+@HAVE_ARMV7A_TRUE@@OPT_SIZE_FALSE@am__objects_2 =  \
+@HAVE_ARMV7A_TRUE@@OPT_SIZE_FALSE@	lib_a-memcpy.$(OBJEXT)
+@HAVE_ARMV7_TRUE@am__objects_3 = lib_a-memchr.$(OBJEXT)
+@HAVE_THUMB1_FALSE@am__objects_4 = lib_a-strlen.$(OBJEXT)
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@am__objects_4 =  \
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@	lib_a-strlen.$(OBJEXT)
 am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-access.$(OBJEXT) \
-	lib_a-strlen.$(OBJEXT) lib_a-strcmp.$(OBJEXT) \
-	lib_a-strcpy.$(OBJEXT) lib_a-memcpy.$(OBJEXT) \
-	lib_a-memcpy-stub.$(OBJEXT) lib_a-memchr-stub.$(OBJEXT) \
-	lib_a-memchr.$(OBJEXT) lib_a-strlen.$(OBJEXT) \
-	lib_a-strlen-armv7.$(OBJEXT)
+	$(am__objects_1) lib_a-strcpy.$(OBJEXT) $(am__objects_2) \
+	$(am__objects_3) $(am__objects_4) lib_a-strlen-armv7.$(OBJEXT)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
@@ -105,6 +119,7 @@ CC = @CC@
 CCAS = @CCAS@
 CCASFLAGS = @CCASFLAGS@
 CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
@@ -199,13 +214,39 @@ top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = cygnus
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 AM_CCASFLAGS = $(INCLUDES)
+@HAVE_THUMB1_FALSE@STRCMP_SRC = strcmp.S
+@HAVE_THUMB1_TRUE@@OPT_SIZE_FALSE@STRCMP_SRC =
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@STRCMP_SRC = strcmp.S
+@HAVE_THUMB1_FALSE@STRCMP_OBJ = $(lpfx)strcmp.o
+@HAVE_THUMB1_TRUE@@OPT_SIZE_FALSE@STRCMP_OBJ =
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@STRCMP_OBJ = $(lpfx)strcmp.o
+@HAVE_THUMB1_FALSE@STRLEN_SRC = strlen.c
+@HAVE_THUMB1_TRUE@@OPT_SIZE_FALSE@STRLEN_SRC =
+@HAVE_THUMB1_TRUE@@OPT_SIZE_TRUE@STRLEN_SRC = strlen.c
+@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
+@HAVE_ARMV7A_FALSE@@HAVE_ARMV7M_FALSE@@OPT_SIZE_FALSE@MEMCPY_SRC =
+@HAVE_ARMV7A_FALSE@@HAVE_ARMV7M_TRUE@@OPT_SIZE_FALSE@MEMCPY_SRC = memcpy.S
+@HAVE_ARMV7A_TRUE@@OPT_SIZE_FALSE@MEMCPY_SRC = memcpy.S
+@OPT_SIZE_TRUE@MEMCPY_SRC =
+@HAVE_ARMV7A_FALSE@@HAVE_ARMV7M_FALSE@@OPT_SIZE_FALSE@MEMCPY_OBJ =
+@HAVE_ARMV7A_FALSE@@HAVE_ARMV7M_TRUE@@OPT_SIZE_FALSE@MEMCPY_OBJ = $(lpfx)memcpy.o
+@HAVE_ARMV7A_TRUE@@OPT_SIZE_FALSE@MEMCPY_OBJ = $(lpfx)memcpy.o
+@OPT_SIZE_TRUE@MEMCPY_OBJ =
 noinst_LIBRARIES = lib.a
-lib_a_SOURCES = setjmp.S access.c strlen.c strcmp.S strcpy.c \
-	        memcpy.S memcpy-stub.c memchr-stub.c memchr.S \
-		strlen.c strlen-armv7.S
+lib_a_SOURCES = setjmp.S access.c $(STRCMP_SRC) strcpy.c \
+	        $(MEMCPY_SRC) $(MEMCHR_SRC) $(STRLEN_SRC) \
+		strlen-armv7.S
 
 lib_a_CCASFLAGS = $(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
+lib_a_LIBADD = $(STRCMP_OBJ) $(STRLEN_OBJ) $(MEMCHR_OBJ) $(MEMCPY_OBJ)
+lib_a_DEPENDENCIES = $(STRCMP_OBJ) $(STRLEN_OBJ) $(MEMCHR_OBJ) $(MEMCPY_OBJ)
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 MEMCPY_DEP = memcpy-armv7a.S memcpy-armv7m.S
@@ -312,29 +353,17 @@ lib_a-access.o: access.c
 lib_a-access.obj: access.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.obj `if test -f 'access.c'; then $(CYGPATH_W) 'access.c'; else $(CYGPATH_W) '$(srcdir)/access.c'; fi`
 
-lib_a-strlen.o: strlen.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.o `test -f 'strlen.c' || echo '$(srcdir)/'`strlen.c
-
-lib_a-strlen.obj: strlen.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.obj `if test -f 'strlen.c'; then $(CYGPATH_W) 'strlen.c'; else $(CYGPATH_W) '$(srcdir)/strlen.c'; fi`
-
 lib_a-strcpy.o: strcpy.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy.o `test -f 'strcpy.c' || echo '$(srcdir)/'`strcpy.c
 
 lib_a-strcpy.obj: strcpy.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy.obj `if test -f 'strcpy.c'; then $(CYGPATH_W) 'strcpy.c'; else $(CYGPATH_W) '$(srcdir)/strcpy.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
-
-lib_a-memcpy-stub.obj: memcpy-stub.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy-stub.obj `if test -f 'memcpy-stub.c'; then $(CYGPATH_W) 'memcpy-stub.c'; else $(CYGPATH_W) '$(srcdir)/memcpy-stub.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-strlen.o: strlen.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.o `test -f 'strlen.c' || echo '$(srcdir)/'`strlen.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-strlen.obj: strlen.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strlen.obj `if test -f 'strlen.c'; then $(CYGPATH_W) 'strlen.c'; else $(CYGPATH_W) '$(srcdir)/strlen.c'; fi`
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
diff --git a/newlib/libc/machine/arm/configure b/newlib/libc/machine/arm/configure
index bf0c669..4cecba4 100755
--- a/newlib/libc/machine/arm/configure
+++ b/newlib/libc/machine/arm/configure
@@ -564,6 +564,17 @@ PACKAGE_URL=''
 ac_unique_file="Makefile.am"
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
+CFLAGS
+HAVE_ARMV7M_FALSE
+HAVE_ARMV7M_TRUE
+HAVE_ARMV7A_FALSE
+HAVE_ARMV7A_TRUE
+HAVE_ARMV7_FALSE
+HAVE_ARMV7_TRUE
+OPT_SIZE_FALSE
+OPT_SIZE_TRUE
+HAVE_THUMB1_FALSE
+HAVE_THUMB1_TRUE
 sys_dir
 machine_dir
 libm_machine_dir
@@ -3410,6 +3421,218 @@ OBJEXT=${oext}
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using thumb1" >&5
+$as_echo_n "checking whether we are using thumb1... " >&6; }
+if ${acnewlib_cv_thumb1_processor+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+
+#if defined (__thumb__) && !defined (__thumb2__)
+  #define _THUMB1
+ #else
+  #error "not thumb1"
+#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_thumb1_processor=yes;
+else
+  acnewlib_cv_thumb1_processor=no;
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acnewlib_cv_thumb1_processor" >&5
+$as_echo "$acnewlib_cv_thumb1_processor" >&6; }
+
+ if test x"$acnewlib_cv_thumb1_processor" = x"yes"; then
+  HAVE_THUMB1_TRUE=
+  HAVE_THUMB1_FALSE='#'
+else
+  HAVE_THUMB1_TRUE='#'
+  HAVE_THUMB1_FALSE=
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the size is preferred" >&5
+$as_echo_n "checking whether the size is preferred... " >&6; }
+if ${acnewlib_cv_opt_size+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+
+#if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)
+  #define OPT_SIZE
+ #else
+  #error "not need for size optimization."
+#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_opt_size=yes;
+else
+  acnewlib_cv_opt_size=no;
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acnewlib_cv_opt_size" >&5
+$as_echo "$acnewlib_cv_opt_size" >&6; }
+
+ if test x"$acnewlib_cv_opt_size" = x"yes"; then
+  OPT_SIZE_TRUE=
+  OPT_SIZE_FALSE='#'
+else
+  OPT_SIZE_TRUE='#'
+  OPT_SIZE_FALSE=
+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
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether armv7a processor is supported" >&5
+$as_echo_n "checking whether armv7a processor is supported... " >&6; }
+if ${acnewlib_cv_armv7a_processor+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+
+#if defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED)
+  #define HAVE_ARMV7A
+ #else
+  #error "ARMV7A 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_armv7a_processor=yes;
+else
+  acnewlib_cv_armv7a_processor=no;
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acnewlib_cv_armv7a_processor" >&5
+$as_echo "$acnewlib_cv_armv7a_processor" >&6; }
+
+ if test x"$acnewlib_cv_armv7a_processor" = x"yes"; then
+  HAVE_ARMV7A_TRUE=
+  HAVE_ARMV7A_FALSE='#'
+else
+  HAVE_ARMV7A_TRUE='#'
+  HAVE_ARMV7A_FALSE=
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether armv7m processor is supported" >&5
+$as_echo_n "checking whether armv7m processor is supported... " >&6; }
+if ${acnewlib_cv_armv7m_processor+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+
+#if defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
+  #define HAVE_ARMV7M
+ #else
+  #error "ARMV7M 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_armv7m_processor=yes;
+else
+  acnewlib_cv_armv7m_processor=no;
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acnewlib_cv_armv7m_processor" >&5
+$as_echo "$acnewlib_cv_armv7m_processor" >&6; }
+
+ if test x"$acnewlib_cv_armv7m_processor" = x"yes"; then
+  HAVE_ARMV7M_TRUE=
+  HAVE_ARMV7M_FALSE='#'
+else
+  HAVE_ARMV7M_TRUE='#'
+  HAVE_ARMV7M_FALSE=
+fi
+
+
+
+
 ac_config_files="$ac_config_files Makefile"
 
 cat >confcache <<\_ACEOF
@@ -3598,6 +3821,26 @@ if test -z "${USE_LIBTOOL_TRUE}" && test -z "${USE_LIBTOOL_FALSE}"; then
   as_fn_error $? "conditional \"USE_LIBTOOL\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_THUMB1_TRUE}" && test -z "${HAVE_THUMB1_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_THUMB1\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+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
+if test -z "${HAVE_ARMV7A_TRUE}" && test -z "${HAVE_ARMV7A_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_ARMV7A\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${HAVE_ARMV7M_TRUE}" && test -z "${HAVE_ARMV7M_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_ARMV7M\" 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 6236338..edf9222 100644
--- a/newlib/libc/machine/arm/configure.in
+++ b/newlib/libc/machine/arm/configure.in
@@ -10,5 +10,133 @@ AC_CONFIG_AUX_DIR(../../../..)
 
 NEWLIB_CONFIGURE(../../..)
 
+dnl Check for Thumb1 supported.
+AC_CACHE_CHECK(whether we are using thumb1,
+	       acnewlib_cv_thumb1_processor, [dnl
+cat > conftest.c <<EOF
+
+#if defined (__thumb__) && !defined (__thumb2__)
+  #define _THUMB1
+ #else
+  #error "not thumb1"
+#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_thumb1_processor=yes;
+else
+  acnewlib_cv_thumb1_processor=no;
+fi
+rm -f conftest*])
+
+AM_CONDITIONAL(HAVE_THUMB1, test x"$acnewlib_cv_thumb1_processor" = x"yes")
+
+dnl Check for whether the size is preferred.
+AC_CACHE_CHECK(whether the size is preferred,
+	       acnewlib_cv_opt_size, [dnl
+cat > conftest.c <<EOF
+
+#if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)
+  #define OPT_SIZE
+ #else
+  #error "not need for size optimization."
+#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_opt_size=yes;
+else
+  acnewlib_cv_opt_size=no;
+fi
+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")
+
+dnl Check for whether ARM_ARCH_7A is defined.
+AC_CACHE_CHECK(whether armv7a processor is supported,
+	       acnewlib_cv_armv7a_processor, [dnl
+cat > conftest.c <<EOF
+
+#if defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED)
+  #define HAVE_ARMV7A
+ #else
+  #error "ARMV7A 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_armv7a_processor=yes;
+else
+  acnewlib_cv_armv7a_processor=no;
+fi
+rm -f conftest*])
+
+AM_CONDITIONAL(HAVE_ARMV7A, test x"$acnewlib_cv_armv7a_processor" = x"yes")
+
+dnl Check for whether ARM_ARCH_7M is defined.
+AC_CACHE_CHECK(whether armv7m processor is supported,
+	       acnewlib_cv_armv7m_processor, [dnl
+cat > conftest.c <<EOF
+
+#if defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
+  #define HAVE_ARMV7M
+ #else
+  #error "ARMV7M 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_armv7m_processor=yes;
+else
+  acnewlib_cv_armv7m_processor=no;
+fi
+rm -f conftest*])
+
+AM_CONDITIONAL(HAVE_ARMV7M, test x"$acnewlib_cv_armv7m_processor" = x"yes")
+
+AC_SUBST(CFLAGS)
+
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
diff --git a/newlib/libc/machine/arm/memchr-stub.c b/newlib/libc/machine/arm/memchr-stub.c
deleted file mode 100644
index 04d9d5f..0000000
--- a/newlib/libc/machine/arm/memchr-stub.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (c) 2010-2011, Linaro Limited
-   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 Linaro Limited 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.
-*/
-
-#include "arm_asm.h"
-
-
-/* Note: This ifdef MUST match the one in memchr.S */
-#if defined(_ISA_ARM_7) || defined(__ARM_ARCH_6T2__)
-  /* Do nothing - the memchr.S will get used */
-#else
-  /* For an older CPU we just fall back to the .c code */
-#include "../../string/memchr.c"
-#endif
-
diff --git a/newlib/libc/machine/arm/memchr.S b/newlib/libc/machine/arm/memchr.S
index 1ba8268..a17dfa3 100644
--- a/newlib/libc/machine/arm/memchr.S
+++ b/newlib/libc/machine/arm/memchr.S
@@ -164,5 +164,19 @@ memchr:
 	pop	{r4,r5,r6,r7}
 	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.
+  */
 #endif
diff --git a/newlib/libc/machine/arm/memcpy-stub.c b/newlib/libc/machine/arm/memcpy-stub.c
deleted file mode 100644
index 449d31a..0000000
--- a/newlib/libc/machine/arm/memcpy-stub.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2013 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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. The name of the company may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 sole purpose of this file is to include the plain memcpy provided
-   in newlib.  An optimized version of memcpy is provided in the assembly
-   file memcpy.S in this directory. */
-#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \
-     (!((defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED)) \
-        || defined (__ARM_ARCH_7EM__) || defined (__ARM_ARCH_7M__))))
-
-#include "../../string/memcpy.c"
-
-#else
-        /* Do nothing. See memcpy.S in this directory. */
-#endif
diff --git a/newlib/libc/machine/arm/memcpy.S b/newlib/libc/machine/arm/memcpy.S
index 734a197..3997524 100644
--- a/newlib/libc/machine/arm/memcpy.S
+++ b/newlib/libc/machine/arm/memcpy.S
@@ -27,7 +27,19 @@
  */
 
 #if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)
-        /* Do nothing here. See memcpy-stub.c in the same directory. */
+  /* Leave this field blank.  So the memcpy() is not defined, and this will
+     automatically pull in the default C definition of memcpy() from
+     ../../string/memcpy.c.  No need to include this file explicitely.
+     The lib_a-memcpy.o will not be generated, so it won't replace the default
+     lib_a-memcpy.o which is generated by ../../string/memcpy.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-memcpy.o to be generated.
+  */
+
 #elif defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED)
 #include "memcpy-armv7a.S"
 
@@ -35,5 +47,5 @@
 #include "memcpy-armv7m.S"
 
 #else
-        /* Do nothing here. See memcpy-stub.c in the same directory. */
+  /* Leave this filed blank.  See the commands above.  */
 #endif
diff --git a/newlib/libc/machine/arm/strcmp.S b/newlib/libc/machine/arm/strcmp.S
index 1742322..fecfdfd 100644
--- a/newlib/libc/machine/arm/strcmp.S
+++ b/newlib/libc/machine/arm/strcmp.S
@@ -64,8 +64,27 @@
 	|| (__ARM_ARCH == 6 && __ARM_ARCH_PROFILE == 'M')
 
 # if defined (__thumb__) && !defined (__thumb2__)
-/* Thumb1 only variant.  */
-#  include "strcmp-armv4t.S"
+/* Thumb1 only variant.  If size is preferred, use strcmp-armv4t.S.
+   If speed is preferred, the strcmp function in ../../string/strcmp.c
+   will be used.  */
+
+#  if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)
+#   include "strcmp-armv4t.S"
+#  else
+    /* Leave this field blank.  So the strcmp() is not defined, and this will
+       automatically pull in the default C definition of strcmp() from
+       ../../string/strcmp.c.  No need to include this file explicitely.
+       The lib_a-strcmp.o will not be generated, so it won't replace the
+       default lib_a-strcmp.o which is generated by ../../string/strcmp.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-strcmp.o to be generated.
+    */
+#  endif
+
 # else
 #  include "strcmp-arm-tiny.S"
 # endif
diff --git a/newlib/libc/machine/arm/strlen.c b/newlib/libc/machine/arm/strlen.c
index b8de229..7e59e75 100644
--- a/newlib/libc/machine/arm/strlen.c
+++ b/newlib/libc/machine/arm/strlen.c
@@ -34,6 +34,24 @@
 #if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \
   (defined (__thumb__) && !defined (__thumb2__))
 
+# if !defined (PREFER_SIZE_OVER_SPEED) && !defined (__OPTIMIZE_SIZE__)
+/* Thumb1 only variant.
+   If speed is preferred, the strlen() function in ../../string/strlen.c
+   will be used.
+
+   Leave this field blank.  So the strlen() is not defined, and this will
+   automatically pull in the default C definition of strlen() from
+   ../../string/strlen.c.  No need to include this file explicitely.
+   The lib_a-strlen.o will not be generated, so it won't replace the default
+   lib_a-strlen.o which is generated by ../../string/strlen.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-strlen.o to be generated.
+*/
+# else
 size_t
 strlen (const char* str)
 {
@@ -43,7 +61,7 @@ strlen (const char* str)
   asm ("mov	%0, #0\n"
        "1:\n\t"
        "ldrb	%1, [%2, %0]\n\t"
-       "add 	%0, %0, #1\n\t"
+       "add	%0, %0, #1\n\t"
        "cmp	%1, #0\n\t"
        "bne	1b"
        : "=&r" (len), "=&r" (scratch) : "r" (str) : "memory", "cc");
@@ -58,6 +76,7 @@ strlen (const char* str)
   return end - str - 1;
 #endif
 }
+#endif
 #else
 
 #if !(defined(_ISA_ARM_7) || defined(__ARM_ARCH_6T2__))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib-cleanup-3.patch
Type: application/octet-stream
Size: 29683 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20140826/b11cfa94/attachment.obj>


More information about the Newlib mailing list