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>
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>
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: I58c34563d6b9f78b47f40e4a92ee0c0aa3992ecd
Signed-off-by: Bernhard Rosenkraenzer <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>
Redo clang patch in a way that doesn't break gcc 4.8

Change-Id: I6b0ed3cf05b552c982f851d161c5bcb7f1cd5930
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
remove typos and multiple declarations

Change-Id: Iff32874c2f801519b57f19a3cc1c2c76b7c7f6fa
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
libc: krait: Use performance version of bcopy and memmove

Ported from CM10.2.

bionic-benchmarks on mako:
before:
                     iterations      ns/op
BM_string_memmove/8    50000000         32   243.54 MiB/s
BM_string_memmove/64   20000000        143   446.41 MiB/s
BM_string_memmove/512    2000000        885   578.14 MiB/s
BM_string_memmove/1K    1000000       1733   590.55 MiB/s
BM_string_memmove/8K     200000      13618   601.54 MiB/s
BM_string_memmove/16K     100000      27276   600.66 MiB/s
BM_string_memmove/32K      50000      59115   554.30 MiB/s
BM_string_memmove/64K      10000     118162   554.63 MiB/s

after:
                     iterations      ns/op
BM_string_memmove/8    50000000         20   381.94 MiB/s
BM_string_memmove/64  100000000         17  3636.07 MiB/s
BM_string_memmove/512   50000000         50 10116.80 MiB/s
BM_string_memmove/1K   20000000         98 10429.23 MiB/s
BM_string_memmove/8K    2000000        876  9346.43 MiB/s
BM_string_memmove/16K    1000000       1836  8923.09 MiB/s
BM_string_memmove/32K     500000       4392  7459.79 MiB/s
BM_string_memmove/64K     200000       8562  7653.85 MiB/s

Change-Id: Id64913a71857d9cfdf6bd1bbe2c66cfc49d72748

Conflicts:
	libc/arch-arm/krait/bionic/memmove.S
	libc/arch-arm/krait/krait.mk
libc: Enable high-performance memmove and bcopy for cortex-a15

Change-Id: Id8e4e595021dd13bf4ab5620f5fb0b0d80333616
Fix build issues with clang 3.4

clang 3.4 (just like gcc) implements _Unwind_GetIP - use Bionic's
implementation only if older clang versions are used.

Don't set incorrect values for WCHAR_MIN and WCHAR_MAX when using clang
in c++11 mode (c++11 has a builtin wchar_t that happens to be unsigned
in clang). Signed WCHAR_MIN and WCHAR_MAX defines in clang++ -std=c++11
cause anything using stlport to fail.

Change-Id: I46ed08b873f34e01c5e66aa8d91c71478bfcc25d
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>

Conflicts:
	libc/bionic/debug_stacktrace.cpp
[DO NOT SUBMIT] Use assembly wrapper for three __aeabi mem routines.

__aeabi_memcpy
__aeabi_memmove
__aeabi_memset

Otherwise Clang will generate infinite recursive calls to itself.

BUG: 2216385
Change-Id: I7a2f3afdb191d32570d17b4a0c79804ed8ec9f91
Add strcmp/memcmp testing.

Bug: 9797008
Change-Id: I11b1da060d29f7dacbb53f20a3e2082395b5bd8a

Conflicts:
	tests/buffer_tests.cpp
	tests/buffer_tests.h
	tests/string_test.cpp
bionic: move benchmarks out of tests directory

Change-Id: I4d054965198af22c9a9c821d1bc53f4e9ea01248
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
Move bionic over to GCC's 'warning' attribute.

This is a better solution than the old __warn_references because it's
a compile-time rather than link-time warning, it doesn't rely on something
that doesn't appear to be supported by gold (which is why you only used
to see these warnings on mips builds), and the errors refer to the exact
call site(s) rather than just telling you which object file contains a
reference to the bad function.

This is primarily so we can build bionic for aarch64; building libc.so
caused these warnings to fire (because link time is the wrong time) and
warnings are errors.

Change-Id: I5df9281b2a9d98b164a9b11807ea9472c6faa9e3
-03