C++11 literal fix.
Use __typeof__() instead of typeof()

typeof() is a gcc builtin and is not always available (such as clang when
-std=c*). Both gcc and clang always expose __typeof__(), so just use that.

Change-Id: I75e2a990acc35f6f39b2c353f6548100ec03c67f
Use __inline__ for fortify.

libunwind has #define inline /* empty */ which breaks our fortified headers.
glibc uses __inline but our BSD-derived headers often override that. __inline__
is the third alternative understood by GCC that -- as far as I know -- neither
the C library itself nor third-party code tries to mess with.

Bug: 12871594
Change-Id: I6677e70ea531bb7d4c46021b43af760d4ad8ecf7
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
Add "__noreturn" to assert and assert2

These functions should print assertion violation messages and then
call abort(). They do really not return control flow afterwards.
Consider the declaration of the similar __assert_fail from glibc:

extern void __assert_fail (const char *__assertion,
                           const char *__file,
			   unsigned int __line,
                           const char *__function)
     __THROW __attribute__ ((__noreturn__));

Bionic has __noreturn defined in sys/cdefs.h to be that GNU
noreturn attribute.

This patch has a practical value. Consider the following function:

void check(void* ptr) {
  assert(ptr != NULL);
}

Without this patch applied, gcc (and presumably clang) shows even in
debug mode:

warning: unused parameter 'ptr' [-Wunused-parameter]

In release mode, NDEBUG is defined and assert() becomes a no-op, as
one should expect. Thus, the warning is shown correctly then.

Another code sample:

float array[2];
int i = 3;
...
assert(i < 2);
array[i] = 0;

gcc says,

warning: array subscript is below array bounds [-Warray-bounds]

In other words, without noreturn attribute, assertions do not
allow a compiler's static analyzer to properly understand
the preconditions.

Change-Id: I3be92e99787c528899cf243ed448c4730c00c45b
Signed-off-by: Vadim Markovtsev <gmarkhor@gmail.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>
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>
revert cortex string optimization routines for now

Change-Id: I410bdef93efd51277b494bde0300a01c49e926f7
Signed-off-by: Amit Pundir <amit.pundir@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>
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 memcpy with the cortex-strings implementation

Benchmarks on a Nexus 10 have shown this implementation to be
up to 12% faster.

Change-Id: I212df99357b338221779cfba118ebfff441c9457
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
Add .cfi_startproc/.cfi_endproc wrapper to memcpy

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