This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[ARM] Fix memchr selection logic.
- From: Marcus Shawcroft <marcus dot shawcroft at arm dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Cc: Richard Earnshaw <Richard dot Earnshaw at arm dot com>
- Date: Thu, 5 Nov 2015 09:07:36 +0000
- Subject: [ARM] Fix memchr selection logic.
- Authentication-results: sourceware.org; auth=none
Hi,
While looking at cleaning up the ARM automake/autoconf foo I notice that
the the existing configury is broken for memchr selection.
The existing mechanism requires that automake selects the appropriate
implementation file, or none at all in order that the default memchr.c
is built and linked. The automake selection hangs on the autoconf test
that sets HAVE_ARMV7 which in turn relies on building a test fragment
including the following:
#if defined (_ISA_ARM_7) || defined (__ARM_ARCH_6T2__)
The definition of _ISA_ARM_7 is provided by arm_asm.h and is not
available to the configury fragment hence that limb of the test will
never trigger. Expanding the current definition of _ISA_ARM_7 directly
into the configury test would give:
#if (__ARM_ARCH >= 7 && defined (__ARM_ARCH_ISA_ARM)) || defined
(__ARM_ARCH_6T2__)
This seems to me to be flawed in that in excludes T2 for no good reason
in the left hand limb and that the test ought to exclude M profile,
hence this patch proposes to redefine the configury test for HAVE_ARMV7 as:
#if (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE != 'M') || defined
(__ARM_ARCH_6T2__)
The HAVE_ARMV7 define is used only in the selection of memchr source.
The effect of this change is that all targets matching the above test
will select the ARM centric memchr.S implementation instead of the
generic memchr.c. Current behaviour is that only __ARM_ARCH_6T2 targets
select the memchr.S.
Tested by running regression for armv5 armv7-a armv7ve armv8-a.
Selection of correct memchr implementation checked by manually
inspecting the linked memchr in a test program compiled for each of
those four architectures.
I intend to refactor the auto foo further but would like to get correct
behaviour in place before I start moving things around.
OK ?
2015-11-04 Marcus Shawcroft <marcus.shawcroft@arm.com>
* libc/machine/arm/configure.in (HAVE_ARMV7): Correct logic.
* libc/machine/arm/memchr.S: Likewise.
* libc/machine/arm/configure: Regenerate.
From d87f224c6e19b764dc1d627845c27aab10fe2cfe Mon Sep 17 00:00:00 2001
From: Marcus Shawcroft <marcus.shawcroft@arm.com>
Date: Wed, 4 Nov 2015 14:23:14 +0000
Subject: [PATCH] [ARM] Fix memchr selection logic.
---
newlib/ChangeLog | 6 ++++++
newlib/libc/machine/arm/configure | 2 +-
newlib/libc/machine/arm/configure.in | 2 +-
newlib/libc/machine/arm/memchr.S | 2 +-
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 3dec6e2..bbb4683 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-04 Marcus Shawcroft <marcus.shawcroft@arm.com>
+
+ * libc/machine/arm/configure.in (HAVE_ARMV7): Correct logic.
+ * libc/machine/arm/memchr.S: Likewise.
+ * libc/machine/arm/configure: Regenerate.
+
2015-11-03 Marcus Shawcroft <marcus.shawcroft@arm.com>
* libc/machine/arm/configure.in: Check for __ARM_ARCH_8A__.
diff --git a/newlib/libc/machine/arm/configure b/newlib/libc/machine/arm/configure
index 9f82c7f..2c217bc 100755
--- a/newlib/libc/machine/arm/configure
+++ b/newlib/libc/machine/arm/configure
@@ -3514,7 +3514,7 @@ if ${acnewlib_cv_armv7_processor+:} false; then :
else
cat > conftest.c <<EOF
-#if defined (_ISA_ARM_7) || defined (__ARM_ARCH_6T2__)
+#if (__ARM_ARCH >= 7 && defined (__ARM_ARCH_ISA_ARM)) || defined (__ARM_ARCH_6T2__)
#define HAVE_ARMV7
#else
#error "ARMV7 is not supported."
diff --git a/newlib/libc/machine/arm/configure.in b/newlib/libc/machine/arm/configure.in
index 69fbe2b..794baf7 100644
--- a/newlib/libc/machine/arm/configure.in
+++ b/newlib/libc/machine/arm/configure.in
@@ -66,7 +66,7 @@ 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__)
+#if (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE != 'M') || defined (__ARM_ARCH_6T2__)
#define HAVE_ARMV7
#else
#error "ARMV7 is not supported."
diff --git a/newlib/libc/machine/arm/memchr.S b/newlib/libc/machine/arm/memchr.S
index a17dfa3..53b1f63 100644
--- a/newlib/libc/machine/arm/memchr.S
+++ b/newlib/libc/machine/arm/memchr.S
@@ -53,7 +53,7 @@
#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 >= 7 && __ARM_ARCH_PROFILE != 'M') || defined (__ARM_ARCH_6T2__)
@ this lets us check a flag in a 00/ff byte easily in either endianness
#ifdef __ARMEB__
--
1.9.1