bionic/libm: fix x86 support regression

Support for x86 and MIPS broke due to an incorrect merge conflict
resolution in commit 5015fe9.  Commit d348cd5 repaired MIPS support
but not x86.  This commit repairs the incorrect merge conflict
resolution, bringing back support for x86 (and potential future
architectures).

Change-Id: I8994d653e5a2f79c9bfacb1c87159c8cdd4f81a7

Conflicts:
	libm/Android.mk

Signed-off-by: Paul Beeler <sparksco@gmail.com>
Revert "memcmp: prefetch optimizing for ARM Cortex-A8/A9"

This reverts commit 579dba196255d3f2db7664cfba2db4cb86f59aa9.
libc: Add optimized memcpy for Cortex-A15

 * This version is from Newlib and is written/recommended by ARM as the best
   routine for Cortex-A15.

Change-Id: Ie9c2817dabda929ae4efaada5f6d467d53551ba4

Conflicts:
	libc/Android.mk
libc: Enable the fast memmove for NEON targets

 * The CodeAurora version of memmove provides roughly 20x the throughput
   of the default version for all tested platforms. Enable it.

Change-Id: Ia9740f6b38a72c0bd6a6818c96d73e2c23bb5979
libc: Remove Scorpion memmove() routine

 * This code is slower than the new implementation under every
   circumstance on Scorpion devices. Remove it and standardize on one
   implementation.
 * Also remove "optimized" memmove_words, which was just a pointer to
   memmove. The performance was identical to the C version on Krait, and
   has regressions on other platforms. This function is only used for
   System.arraycopy in Dalvik.

Change-Id: I42d06fbd7c56d9874b80a0e768dbadf0fa5025a4

Conflicts:
	libc/Android.mk

Signed-off-by: Paul Beeler <sparksco@gmail.com>
Simple google3-compatible benchmarking.

Based on our open-source RE2 benchmarking code.

Includes benchmarks for a handful of <string.h> functions.

Change-Id: I30eb70d25dbf4ad5f2ca44976a8ce3b1ff7dad01
Add a memmove(3) benchmark.

Change-Id: I9c0ffae0b5aae29521b7e68e5ce2318b5a401cba
libc: Add optimized strcmp

This version is from Newlib.

Original comment of the author:

The attached patch provides a new implementation of strcmp for ARM, using
LDRD instead of LDR whenever possible.

For older architectures that do not support LDRD, this implementation uses
the same algorithm as before.

This patch replaces strcmp.c with strcmp.S. The huge inline assembly from
strcmp.c was converted into plain assembly and included in strcmp.S under
the appropriate predefines.

Testing and benchmarking:
* Validation: successfully passes a test that compares different strings of
length 1-128 and offsets 0-8 from a word boundary. Checked on qemu/A15/A9,
ARM/Thumb mode, Big/Little Endian. This test is also added to newlib
testsuite as part of this patch.
* Integration with gcc: no regression on qemu for arm-none-eabi --with-cpu
a15/a9 --with-mode arm/thumb.
* Performance (relative to the current strcmp in newlib, only in ARM mode):
On Dhrystone, the new implementation (ldrd) is 22% faster on Cortex-A15
FPGA, and 16% on Cortex-A9 VE2.
On synthetic benchmarks, which measure the average number of cycles for
strcmp on strings of length 4-128K and offsets 0,1,2,3,4,8 from a word
boundary, where the strings are equal, the new implementation is three times
faster for long strings, when the input strings have the same offset from a
word boundary, and up to 30% faster in other cases, on both A15 FPGA and A9
VE2.

Change-Id: I7a39770cad48c2ecc6b6d375165652cd4f0c0619
Signed-off-by: Dirk Rettschlag <dirk.rettschlag@gmail.com>
libc: Fix invalid macro

Change-Id: Ia0c1d81cecb2f05834842bf3e6a3cc9cb06e00c9
libm: Enable fast NEON pow() for supported targets

Change-Id: Iabda43e3c8462074a9a46c8f496eac903ea17084

Conflicts:
	libm/Android.mk
	libm/src/e_pow.c

Signed-off-by: Paul Beeler <sparksco@gmail.com>
Add some extra extra checks in for ARMV7A and NEON on ARM targets

Signed-off-by: Paul Beeler <sparksco@gmail.com>
linker: add -Wl,--exclude-libs,ALL to LDFLAGS

The linker is essentially a shared library, and incorporates
it's own copy of libc. Even though it's unnecessary, currently
/system/bin/linker is exporting various libc symbols (only to
apps which explicitly dlopen /system/bin/linker)

Add --exclude-libs,ALL, which tells the static linker to mark
all of the imported libc symbols as hidden. This reduces the
size of /system/bin/linker from 92K to 67K with no obvious
loss in functionality.

  $ adb shell ls -l /system/bin/linker
  -rwxrwxrwx root     root        92260 2013-01-16 16:52 linker

  $ adb shell ls -l /system/bin/linker
  -rwxrwxrwx root     root        67660 2013-01-16 16:49 linker

Documentation on exclude-libs can be found at
http://sourceware.org/binutils/docs-2.21/ld/Options.html

Change-Id: I4508287770e4b7a845def2e6b4af969f9c866c6a
Add functionlity to the scripts to replace tokens in kernel headers
based on architecture.
Add missing extern "C".

Change-Id: Idbf24ce8482ff03f24caa89bafb08677b1c5cec3
Disable leak checking for mksh; it's way too leaky.

When each shell leaks ~240 allocations, you can't see the leaks from
the program you ran with "adb shell".

Bug: 7291287
Change-Id: Ib8780db72ba0114ebdb24768537da74bbb61f354

Conflicts:
	libc/bionic/malloc_debug_common.cpp

Signed-off-by: Paul Beeler <sparksco@gmail.com>
Don't free anything when reporting leaks.

We don't know that they're not going to be cleaned up by a
C++ global destructor that runs after us. This is the case with
bootanimation, for example.

Bug: 7291287
Change-Id: Iba402514d1735fdc2ae4bc95b65396d816be46c0

Conflicts:
	libc/bionic/malloc_debug_check.cpp

Signed-off-by: Paul Beeler <sparksco@gmail.com>
libc: use more secure system properties if available

Currently, system properties are passed via the environment
variable ANDROID_PROPERTY_WORKSPACE and a file descriptor passed
from parent to child. This is insecure for setuid executables,
as the environment variable can be changed by the caller.

Modify system property handling so that we get the properties
from a root owned properties file, rather than using an
environment variable.  Fall back to the environment variable
if the file doesn't exist.

Bug: 8045561
Change-Id: I54f3efa98cf7d63d88788da5ce0d19e34fd7851a
prctl.h: include sys/cdefs.h

prctl.h uses __BEGIN_DECLS but fails to include sys/cdefs.h
(where it's defined).  Code which includes prctl.h without
previously including sys/cdefs.h will fail to compile.

Fixed.

Change-Id: If4c9f3308f08b93596dcd00e351ae786807e9320
system_properties: do more checking of file

Check that the permissions on the properties file
are exactly as we expect them to be.

Make sure we close the fd if fstat fails.

Refactor the code slightly.

Change-Id: I5503fd58c3b8093ce7e6d05920748ed70eaf8e2c
Use the NetBSD <sys/exec_elf.h>.

Replace a kernel header file dependency with files from NetBSD.
They're more complete, and ELF is ELF, whether you're on Linux or a BSD.

Bug: 7973611
Change-Id: I83ee719e7efdf432ec2ddbe8be271d05b2f558d7