headers: Unbreak some ARM syscalls

Restore the outside-kernel exclusion for some syscalls that was
removed by change I959b64280e184655ef8c713aa79f9e23cb1f7df4,
since these syscalls are used elsewhere.

Change-Id: I5b5bf3d78edd137e820d25281a375966b6c009ec
Modify Android mem* routines with CodeAurora versions.

Update the memcpy, memmove, and memset routines to use the
versions from CodeAurora when specified in the bionic/Android.mk
file (actually activated in the BoardConfig.mk file under
device/<vendor>/<board>).  With this change, the mem* routines are
only used for the msm8660, while other platforms will use the
current Android mem* routines.

Future platforms can modify the makefile to use the CodeAurora-based
mem* routines as desired.  This has the benefit of making the CodeAurora-
based routines opt-in instead of opt-out.

Also, PLDSIZE and PLDOFFS can be specified in the BoardConfig.mk as well,
so other platforms with different PLD tunings can use the same code
without modifying the source file itself.

Tests with FileCycler-0.3 showed a slight 1.1% improvement with these
files on an 8660v2, based on the average of three FileCycler runs with
and without the patch.  Since the min/max values did not overlap, and
the average score showed an improvement, we can consider upstreaming these
modifications.

Change-Id: I6946076bc6a88a2a2c8667b09494e1eb31e01ee0
TLS: Call kernel helper in additional situations

ARMv6 has HW TLS support, and thus we should be using it rather
than hacking the Linux Kernel to use the software mechanism.
Unfortunately, ARMv6 targets without Thumb2 do not support the
necessary TLS instructions in Thumb Mode. Converting the tls libc
routines to ARM Mode will require an additional branch to switch
modes. Therefore, let's simply use the Kernel's Helper Routine
which already operates in ARM Mode. This changed behavior only
applies if the HAVE_ARM_TLS_REGISTER option is defined.
Otherwise, the existing paradigm is used.

Change-Id: I282697b0ab97cb62affd018494076e6ffa4d392a
Use GCC's __attribute__((const)) to reduce code size

__attribute__((const)) is mainly intended for the compiler to optimize
away repeated calls to a function that the compiler knows will return
the same value repeatedly.

By adding __attribute__((const)), the compiler can choose to call the
function just once and cache the return value.  Therefore, this yields
code size reduction.

Here are the reference results by arm-eabi-size for crespo device:

[before]
   text    data     bss     dec     hex filename
 267715   10132   45948  323795   4f0d3

[after]
   text    data     bss     dec     hex filename
 267387   10132   45948  323467   4ef8b

Change-Id: I1d80465c0f88158449702d4dc6398a130eb77195
sha1: code cleanup and use modern C syntax

Apply the following changes:
- Remove out-of-date workaround (SPARC64_GCC_WORKAROUND)
- Use C99 prototype and stdint type

Change-Id: I630cf97f6824f72f4165e0fa9e5bfdad8edabe48
sha1: Use bswap* to optimize byte order

bionic libc already makes use of ARMv6+ rev/rev16 instruction for
endian conversion, and this patch rewrites some parts of SHA1
implementations with swap32 and swap64 routines, which is known to
bring performance improvements.

The reference sha1bench on Nexus S:

[before]
Rounds: 100000, size: 6250K, time: 1.183s, speed: 5.16  MB/s

Change-Id: Id04c0fa1467b3006b5a8736cbdd95855ed7c13e4
[after]
Rounds: 100000, size: 6250K, time: 1.025s, speed: 5.957 MB/sB
linker: optimize SysV ELF hash function

This change can avoid one iterative operation in inner loop.
Inspired by glibc.

Change-Id: I3f641c086654809574289fa6eba0ee1d32e79aa3
Add ARMv7 optimized strlen()

Merge the ARM optimized strlen() routine from Linaro.  Although it is
optimized for ARM Cortex-A9, the performance is still reasonably faster
than the original on Cortex-A8 machines.

Reference benchmark on Nexus S (ARM Cortex-A8; 1 GHz):

[before]
             prc thr   usecs/call      samples   errors cnt/samp     size
strlen_1k      1   1      1.31712           97        0     1000     1024

[after]
             prc thr   usecs/call      samples   errors cnt/samp     size
strlen_1k      1   1      1.05855           96        0     1000     1024

Change-Id: I809928804726620f399510af1cd1c852ed754403
linker: Minor optimization of ELF header manipulating

This patch applies the following changes:
 - word alignment to the temporary space for holding ELF header
 - Instead of sequential character comparison of ELF header, use
   pre-calculated value.

Change-Id: I9882e3ffeb25acc05d14803fc7aca3a6a05e3674
memmove: Fix the abuse of memcpy() for overlapping regions

memcpy is not defined for overlapping regions.

Original author: Chris Dearman <chris@mips.com>

Change-Id: Icc2acc860c932eaf1df488630146f4e07388a444
memcmp: prefetch optimizing for ARM Cortex-A8/A9

The original memcmp() was tweaked for ARM9, which is not optimal for ARM
Cortex-A cores.  This patch merges the prefetch optimizations from
ST-Ericsson and removes NEON slowdowns.

Reference experiement results on Nexus S (ARM Cortex-A8; 1 GHz) using
strbench program:
    http://pasky.or.cz//dev/glibc/strbench/

[before]
size, samples, TIMES[s] - user, system, total)
   4   262144         2.510000 0.000000 2.510000
   8   131072         1.570000 0.010000 1.590000
  32    32768         1.310000 0.000000 1.320000

[after]
size, samples, TIMES[s] - user, system, total)
   4   262144         2.280000 0.000000 2.290000
   8   131072         1.210000 0.000000 1.220000
  32    32768         1.040000 0.000000 1.050000

Change-Id: I961847da96d2025f7049773cd2ddaa08579e78d6
bionic: Update mechanism to detect number of CPU's for msm targets

msm targets use CPU hotplug for power management, which results in
/proc/cpuinfo and /proc/stat to return back incorrect number of
available CPUs for msm configuration.

Use /sys/devices/system/cpu/present instead when indicating total
number of CPUs to userspace processes and let system power
management take care of when to swich CPUs between online/offline
states.

Only 0-N format is supported for detecting number of CPUs.
0-N,M format for detecting number of CPUs is not supported, and is
currently not a valid configuration on msm targets.

ifdef for QCOM_HARDWARE

Change-Id: I40ab2f79ca67cdbf7f1bf87d52007f822ee76269
Add missing define to build qcom libgralloc.

This is needed by hardware/qcom/display/libgralloc/ashmemalloc.cpp.

Change-Id: I7b35bcdaedf3874d17a0e6ce18931c11db1e133d
Add missing define to build qcom libgralloc.

This is needed by hardware/qcom/display/libgralloc/pmemalloc.cpp

Change-Id: Id0732b82ed6c1852def9688544ec92e04afeff00
Add missing define for libcopybit.

This is needed by hardware/qcom/display/libcopybit/copybit.cpp.

Change-Id: Ic50a75b93b39443b772dd4cab67a55f75ad2b5ad
fix ARMv7 optimized strlen() usage condition

Change-Id: Ia2ab059b092f80c02d95ca95d3062954c0ad1023
getopt(): fix missing carriage return on bad parameters

This affect all command line tools which show the usage on stdout
after an invalid parameter error (printed on stderr)

Change-Id: I8e2cb3fda241ab989dc42055f15082f8b3ba1397
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
bionic: Fix aliasing violations

This makes bionic compile with compilers enforcing
strict adherence to aliasing rules (e.g. gcc 4.6
with -Wstrict-aliasing=2 -Werror=strict-aliasing).

Conflicts:

	libc/netbsd/resolv/res_send.c

Change-Id: I640bafe9fef399f856c9e57cb0ab877e8656e522
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
Signed-off-by: Evan McClain <aeroevan@gmail.com>
bionic: Add ; after anonymous union declaration

This improves compatibility with different compilers

Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
libm: Add a proper sincos() implementation

Add a proper sincos() implementation that unifies the common
calculations for sin and cos instead of running them twice.

This should cause a speedup even in code not using that
(fairly uncommon) function because gcc can optimize separate
sin() and cos() calls into sincos() calls.

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

Change-Id: I644578ab443506c7404d2638d6d4917ff6c96f20