libc: krait: Implement optimized versions of memmove and bcopy

Restore a jellybean optimization for memmove and bcopy on krait.
Code has been refactored to thumb2 for consistency with the rest of
bionic libc, as well as performance and correctness.

Change-Id: I8f2f77dce4534fbce1bdf0188ab353bf34ab8637
Fix dns search domain use in gethostbyname.

Need to load search domain data before we attempt to use it.
bug:6799630

Change-Id: Ib228f4ca260339f71a2e28d5930c0a722bd43c92
__strnlen_chk: avoid recursive strlen calls

Don't use FORTIFY_SOURCE on functions which implement
FORTIFY_SOURCE.

Bug: 12216860
Change-Id: I61db1b47ccdd6bdcf41eab3303f4806494016199
Clean up more recursive FORTIFY_SOURCE calls

Don't use FORTIFY_SOURCE on functions which implement
FORTIFY_SOURCE, to avoid infinite recursion problems.

The previous patch only addressed one of the problems.

Bug: 12216860
Change-Id: I6f30ae7cb5b481be9942add18182ea4839d348a6
libc: Enable high-performance memmove and bcopy for cortex-a15

Change-Id: Id8e4e595021dd13bf4ab5620f5fb0b0d80333616
libc: Unbreak build for scorpion

Use cortex-a15 memcpy and krait memset routines

Change-Id: I02cb178b33b01fc91e903f1f7b620640fd0f3310
Clean up some ARMv4/ARMv5 cruft.

Change-Id: I29e836fea4b53901e29f96c6888869c35f6726be
Clean up the pthread-only atomic stuff a little.

It looks like we can probably just use the generic GCC stuff instead;
the generated code looks pretty similar. We should come back to that.

These routines are only used by the pthread implementation, and
__bionic_atomic_inc isn't used, so we can remove it.

Change-Id: I8b5b8cb30a1b159f0e85c3675aee06ddef39b429
ARM: Change dmb domain for bionic_atomic_barrier()

This patch changes the domain that the memory barrier operates on. Assumes
that the scope of bionic_atomic_barrier() does not include device memory,
memory shared with the GPU or any other memory external to the processor
cluster.

Change-Id: I291e741c98a64c86f3a3cf99811bbf1e714ac9aa
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Remove harmful attempts to be helpful in pthread_mutex functions.

Most callers won't check for EINVAL, so it's best to fail early.
GCC takes the nonnull attribute as a guarantee that an argument
won't be NULL, so these hacks were already ineffective, which is
how we found that at least one commercial game was using NULL
as if it's a mutex, but actually getting no-op behavior.

Bug: 11971278
Change-Id: I89646e043d931778805a8b692e07a34d076ee6bf
Revert "Remove harmful attempts to be helpful in pthread_mutex functions."

This reverts commit 53f15d0325feeaf7e58dc79fce4ddf55e0a64b7a.
libc: krait: support KINGFISHER optimized memcpy

When defined use the KINGFISHER optimized
cortex-a9 memcpy instead to improve performance.

Change-Id: Idcfb94cc1e10d8326d7a9e623baed91125d7caf6
Import memchr implementation from cortex-strings for Cortex A15

Benchmarks on a Nexus 10 have shown the cortex-strings implementation
of memchr to be 60%-70% faster (depending on input)

Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>

Change-Id: I72b119905234570e54068375e5c3593d0647c67c
Replace Cortex A15 strlen implementation with cortex-strings

Benchmarks on a Nexus 10 have shown this implementation to be 5%-20%
faster (depending on input)

Change-Id: I4331a390c404a77b1e13909d713c4258a3776bca
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
libc: Fix memchr inclusion

Change-Id: I6f374f16b08e19851a375a4abad3e8235f8da59c
libc: Fix memchr inclusion on scorpion

Change-Id: I0f4d31c85c8671be9790feab03469f89520763b7
libc: krait: Fix memmove half-word atomicity

In tailing case of less than 7, if even number of bytes are left, then
use half word load/store to make sure the whole routine is half-word
atomic

Change-Id: I54948ac050ff866986a7e144d4240652981ea87a
Fix pthread_detach for already-exited threads.

This fix handles the case when pthread_detach is
called for threads which have already exited.
This is required to avoid any memory leak

Change-Id: I2bf7f41234d93b226132a4c51705f4186f4961c3
Reported-by: Paresh Nakhe <pnakhe@codeaurora.org>
Merge tag 'android-4.4.3_r1.1' into kk-4.4