Always take GCC's definition of NULL.

There's a (bad) definition of NULL in <linux/stddef.h>, and this
definition of NULL, and the One True definition in the <stddef.h> provided
by the compiler. This change at least kills one of the bad duplicates.
Killing the <linux/stddef.h> one is harder, because it's in a generated
file.

Change-Id: Iea4ccb12d6758199f312ea9cd753b84322d5c471
libstdc++: make operator new call abort on failure.

This change ensures that operator new will call abort() in case
of memory allocation failure. Note that due to our usage of memory
overcommit, this can only happen under very rare circumstances
(i.e. trying to allocate memory larger than the larger free range
of virtual address space, or when memory is corrutped in various
ways).

Change-Id: I128b8bf626216e899c22a00f24492cd148a1fc94
strftime: Use snprintf() instead of sprintf()

Change-Id: I112ac012894eddc96e5f3e77cb87bb300596e3ce
Signed-off-by: Jim Huang <jserv@0xlab.org>
time: Improve C99 compliance

Quote from Linux Programmer's Manual:
  "If t is non-NULL, the return value is also stored in the memory
   pointed to by t."

Change-Id: I8cb66b67e5f34c536ce2f0db76a6dc337c42ea3f
Signed-off-by: Jim Huang <jserv@0xlab.org>
libc: Add logcat error message for memory corruption

Our dlmalloc implementation currently calls abort() when it detects
that the heap is corrupted, or that an invalid pointer is passed to
one of its functions.

The only way to detect this is because abort() will force-fully
crash the current program with a magic fault address of '0xdeadbaad'.

However, this is not really well documented, and a frequent topic
on the android-ndk forum (among others).

This change makes our dlmalloc code dump a simple message to the
log just before the abort() call (and hence before the stack trace)
to better help identify the problem.

Change-Id: Iebf7eb7fe26463ecadfaca8f247d237edb441e3c
libc: Define new symbol visibility macros

This patch defines a few new macros that can be used to control the
visibility of symbols exported by the C library:

- ENTRY_PRIVATE() can be used in assembly sources to indicate
  that an assembler function should have "hidden" visibility, i.e.
  will never be exported by the C library's shared library.

  This is the equivalent of using __LIBC_HIDDEN__ for a C function,
  but ENTRY_PRIVATE() works like ENTRY(), and must be used with
  END() to tag the end of the function.

- __LIBC_ABI_PUBLIC__ can be used to tag a C functions as being
  part of the C library's public ABI. This is important for a
  few functions that must be exposed by the NDK to maintain
  binary compatibility.

  Once a symbol has been tagged with this macro, it shall
  *never* be removed from the library, even if it becomes
  directly unused due to implementation changes
  (e.g. __is_threaded).

- __LIBC_ABI_PRIVATE__ can be used for C functions that should
  always be exported by the C library because they are used by
  other libraries in the platform, but should not be exposed
  by the NDK. It is possible to remove such symbols from the
  implementation if all callers are also modified.

+ Add missing END() assembly macro for x86

Change-Id: Ia96236ea0dbec41d57bea634b39d246b30e5e234
update stddef.h

Pull in an updated version of stddef.h from the linux kernel.
Pulled from upstream kernel at 891003abb0db6bfffd61b76ad0ed39bb7c3db8e1

This file was generated using the following command:

cd bionic/libc/kernel/
./tools/clean_header.py -u ../../../external/kernel-headers/original/linux/stddef.h

Change-Id: I6c29f3fa100c5368da41d0f0da39bc50fa668e9d
Eliminate duplicate constants

include/elf.h contains basically the same values as
linux/auxvec.h. Eliminate dups.

include/sys/exec_elf.h contains basically the same
values as linux/elf.h. Eliminate dups.

Change-Id: I66b8358161bb52223bb657f8f73ba28b324f4fa3
Give the timer_create SIGEV_THREAD helper threads sensible names.

Bug: 6609676
Change-Id: I286b197c75beee4d9930b0973f2d7dd47c14e91c
Fix sysconf(_SC_NPROCESSORS_CONF) on ARM.

Bug: http://code.google.com/p/enh/issues/detail?id=33
Change-Id: I679b4cd888d362031042284e8edf01c5273a92aa
memmove: Don't call memcpy if regions overlap

memmove() unconditionally calls memcpy() if "dst" < "src". For
example, in the code below, memmove() would end up calling memcpy(),
even though the regions of memory overlap.

int main() {
  char buf3[0x800];
  char *dst  = &buf3[1];
  char *src = &buf3[0x400];
  memset(buf3, 0, sizeof(buf3));
  memmove(dst, src, 0x400);
  printf("1: %s\n", buf3);
  return 0;
}

Calling memcpy() on overlaping regions only works if you assume
that memcpy() copies from start to finish. On some architectures,
it's more efficient to call memcpy() from finish to start.

This is also triggering a failure in some of my code.

More reading:
* http://lwn.net/Articles/414467/
* https://bugzilla.redhat.com/show_bug.cgi?id=638477#c31 (comment 31)

Change-Id: I65a51ae3a52dd4af335fe5c278056b8c2cbd8948