[ARM] Fix memchr selection logic.

Marcus Shawcroft marcus.shawcroft@arm.com
Thu Nov 5 09:55:00 GMT 2015


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ARM-Fix-memchr-selection-logic.patch
Type: text/x-patch
Size: 2504 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20151105/af6cd274/attachment.bin>


More information about the Newlib mailing list