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).

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
bionic:Add new header files for graphics

The header files "hwmem.h" and "b2r2_blt.h" are needed
by the ST-Ericsson graphics implementation.

Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
bionic: Add ARMv7 optimized string handling routines

Add ARMv7 - and especially Cortex-A9 - optimized string handling
routines based on the versions found in the cortex-strings library.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Add workarounds for current compilers

With current compilers, we're getting "this function cannot be inlined"
errors on vsnprintf and strlcpy because the always_inline attribute is
set.

Before marking this a "fix" instead of a "workaround", we should figure
out why the functions can't be inlined.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Make use of new memcpy, tweak settings

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The new memcpy() is slightly faster than the cortex-strings version,
and fixes the Galaxy Nexus camera issue.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
bionic: Add Cortex-A15 optimized version of memcpy

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add the memcpy implementation from cortex-strings -- faster than
the current implementation on both A9 and A15.

To be investigated: Breaks saving pictures from the camera in
Galaxy Nexus builds

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
remove typos and multiple declarations

Change-Id: Iff32874c2f801519b57f19a3cc1c2c76b7c7f6fa
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
revert cortex string optimization routines for now

Change-Id: I410bdef93efd51277b494bde0300a01c49e926f7
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Add optimized sincos() function (ported from linaro_android_4.2.2)

Change-Id: I77f84d7ebc2dd7d5aa352b108b05e2651b5605c1
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Declare __page_shift and __page_size with C linkage

__page_shift and __page_size are defined in asm/page.h with
C linkage - their implementation needs to use the same linkage.

The different linkage types cause a compiler error with clang.
Fixing them seems to be a good idea regardless of the compiler.

Change-Id: I35ed66a08989ced1db422eb03e4d154a5d6b5bda
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
Fix mismatch between declaration and forward declaration

KernelArgumentBlock is defined as a class in KernelArgumentBlock.h, but
forward declarations refer to it as a struct.

While this is essentially the same, the mismatch causes a compiler
warning in clang (and may cause warnings in future versions of gcc) in
code that is supposed to be compiled with -Werror.

Change-Id: I4ba49d364c44d0a42c276aff3a8098300dbdcdf0
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
Fix build after 4.4 merge

Change-Id: I9b5eb314746ebadfced2f4a055a8e1306ca9e4ec
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Don't include memchr.c twice

Change-Id: I663a934dd4c8e7e87e8d018c878b3c4d04b0b914
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
[ARM] libm: squashed CAF e_pow implementation made generic

Summary:
The following commits have been edited to be more
general than just for qcom devices. Any arm neon device
will benefit from this change.

commit 5587d4f73977774f12f7e459edf05881ca4d4367
Author: Lucas Crowthers <lucasc@codeaurora.org>
Date:   Thu Apr 25 15:56:16 2013 -0400

    libm: optimistic pow calling.

    Call optimized pow optimistically and revert to full range
    implementation if we detect an out-of-range input.

    Change-Id: I6f3aa734adbf99484b7ff70736ef83a41e5815b8

commit 1801b320beeae4ec6078e46d45bbf65d6c8e8bee
Author: Lucas Crowthers <lucasc@codeaurora.org>
Date:   Mon Aug 27 14:35:57 2012 -0400

    Bionic/libm: Pow optimizations and bug fixes.

    Use VFP calling convention for pow_neon handoff function by default.
    Fix register usage collision between two different polynomial
    coefficients in pow_neon.  Remove conditional execution in pow_neon
    and replace with branching.

    Change-Id: I76095f4a006e2fb01a53943b66fd69bfa1fd3033

commit 688c9786420309ee660e9641c6523ec8b78f30d2
Author: Lucas Crowthers <lucasc@codeaurora.org>
Date:   Mon Aug 27 14:27:59 2012 -0400

    Bionic/libm: Prefer branches and VFP ABI.

    For internal functions set gcc attribute "aapcs-vfp" for ARM
    and use -fno-if-conversion to prefer branches over predicated
    instructions (improves performance on architectures with good
    branch prediction).

    Change-Id: I8424e0e82a19d35e7e3b6e3e122dcdecdd5426fd

commit eb45d36b9c23707551f73581c5bf181e46acd381
Author: Lucas Crowthers <lucasc@codeaurora.org>
Date:   Fri Jun 15 19:27:46 2012 -0400

    Bionic/libm: fast neon pow() for small x,y.

    Add a fast neon version of pow() suitable for relatively small
    positive x and y (between 0 and 4).  Run the standard
    implementation in all other cases.  Gives approximately 60%
    performance improvement to AnTuTu FPU scores

    Change-Id: I97e0712daeb2740764b26a44be0caaa39c481453

Test Plan: verified, test it out on any ARM NEON device.

Reviewers: randall.rushing, jriordan001, anders3408

Differential Revision: http://review.codefirex.com/D231

Conflicts:
	libm/Android.mk
libm: sync with upstream freebsd

Summary:
New long double functions have been included,
but are not in use due to the android double long
handling. imprecise.c is not built for the same reason.

Test Plan: verified

Reviewers: randall.rushing

Differential Revision: http://review.codefirex.com/D232
libm: add fmal long double stub

Summary:
This is needed in some target cases, and has since been fixed internally in the AOSP.

From enh@google.com regarding this change:
you were right, and this was the way we should have done it, but i didn't work that out until i fixed this in the same way as part of the aarch64 work (where the weak reference didn't work).

Test Plan: verified

Reviewers: randall.rushing, jriordan001, synergy

Reviewed By: synergy

Differential Revision: http://review.codefirex.com/D234
Make use of new memcpy, tweak settings
Summary:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The new memcpy() is slightly faster than the cortex-strings version,
and fixes the Galaxy Nexus camera issue.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[ARM] libc: optimized strnlen, strncat, strncmp, and strlcat

Summary:
Date:   Mon Sep 23 14:45:06 2013 -0700

    [ARM] libc: use basic ASM strnlen implementation

    Summary:
    This is based on the current naive strlen routine from
    netbsd

    Test Plan: significant implemented bench gains

    Reviewers: randall.rushing, synergy

    Reviewed By: synergy

    Differential Revision: http://review.codefirex.com/D499

    Conflicts:
        libc/Android.mk

Author: synergydev <synergye@codefi.re>
Date:   Mon Sep 23 14:43:27 2013 -0700

    [ARM] libc: use optimized ASM strncmp implementation

    Summary:
    This strncmp implementation is based on the current
    arm netbsd implementation

    Test Plan: https://sourceware.org/git/?p=glibc.git;a=blob;f=benchtests/bench-strncmp.c;h=25df3dbc2eb25346d9a897f8d7a2ada9725584e3;hb=master and integrated bionic-benchmark

    Reviewers: randall.rushing

Author: synergydev <synergye@codefi.re>
Date:   Sat Sep 21 23:45:58 2013 -0700

    [ARM] libc: use basic ASM strncat implementation

    Summary:
    This implementation is the naive strncat implementation
    for ARM from netbsd upstream.

    Test Plan: Someone else test please, bench gain is significant with http://repo.or.cz/w/glibc.git/blob_plain/ec901dcf2886cfb81d88f9a63cfcd62b9efe6381:/benchtests/bench-strncat.c (no currently integrated bench, only test which is good with this change).

    Reviewers: randall.rushing, ConnorBaker, synergy

    Reviewed By: synergy

Author: synergydev <synergye@codefi.re>
Date:   Mon Sep 23 14:42:47 2013 -0700

    [ARM] libc: use basic ASM strlcat implementation

    Summary: This is based on the netbsd naive strlcat implementation

    Test Plan: +1 here

    Reviewers: randall.rushing, synergy

    Reviewed By: synergy

Test Plan: significant implemented bench gains

Reviewers: randall.rushing, synergy

Reviewed By: synergy

Differential Revision: http://review.codefirex.com/D238

Conflicts:
	libc/Android.mk
[ARM] libc: define return and conditional return macros

Summary: Required by the new strncat, strlcat, strncmp, and strnlen

Test Plan: verified

Reviewers: randall.rushing, jriordan001, anders3408, synergy

Reviewed By: synergy

Differential Revision: http://review.codefirex.com/D239
libm: Squashed CAF sin/cos implementation for ARM NEON

Summary:
Bionic/libm: Add precision-correct de-serialize sin/cos.

Modify sin/cos to improve performance while retaining bit-for-bit
accuracy with existing algorithm.

Change-Id: Iaba2dd731cd015732744705dad8bddb713b43067
(cherry picked from commit df55e67573e176042c5d2ae084c758bc2e9e0025)
(cherry picked from commit 6a688d7aa4512731c430673ccd4f0d6e3999d439)
(cherry picked from commit 47bb7bc2962bff835000dca016f6319c20734398)

Bionic/libm: add assembly versions of sin/cos.

Add assembly versions of sin/cos with integrated remainder pi/2
calculation.  Directly extracted from binary libm.so compiled with
__ieee754_rem_pio2 calls inlined.

Change-Id: Ia093f420e58e794635e3a5f09e8236ae7601f1f6
(cherry picked from commit 19a356a1ed6384a9161739d5833cf5cfd88a8d3b)
(cherry picked from commit 1c9bdcfa6a68cd1a13a1e3b1a51616bddffeefad)
(cherry picked from commit cdaad8ab61325e958926b57a6a726d0cfa6f7511)

Bionic/libm: Remove extra vmov from sin/cos.

Move integer representations of x bits on the integer side rather
than moving them to and from the FP registers.

Change-Id: I1895db385c9616cdae9ab6403f392dfbae292adc
(cherry picked from commit 1d0c5a9fe67141515fa54403d985828590f9c206)
(cherry picked from commit ca46b68c30cf470464ffac530b8bdba242cc5c17)
(cherry picked from commit d7acb8827620ab7331995e843fd79015aed84996)

Test Plan: testing

Reviewers: jriordan001, randall.rushing, synergy

Reviewed By: synergy

Differential Revision: http://review.codefirex.com/D270