libm: fix invalid result of function remquo/remquof

Currently we will get the wrong result as follows:
remquof(0x7bb33336, 0x63000000) = -671088640, 0x00000000
remquo(0xbff0000000000003, 0x3ff0000000000003) = 1, 0x8000000000000000
remquo(0x9120000000000001, 0x0000000000000005) = -1288490188, 0x0000000000000004
while the correct one should be:
remquof(0x7bb33336, 0x63000000) = 1476395008, 0x00000000
remquo(0xbff0000000000003, 0x3ff0000000000003) = -1, 0x8000000000000000
remquo(0x9120000000000001, 0x0000000000000005) = -1288490189, 0x0000000000000001

Fixed in this patch.

original id of the change: I540b348cd10a539f3b39b1753945c893c4c7ec46
Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com>
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>

picked from
https://android-review.googlesource.com/#/c/33341/

fix whitespaces
bionic: fixed the race condition in dlmalloc_usable_size()

Currently there is a race condition in dlmalloc_usage_size():
    if (cinuse(p))
      return chunksize(p) - overhead_for(p);
overhead_for(p) will return 2 bytes if p is mmaped, otherwise 1 byte.
\#define is_mmapped(p)\
  (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))

If p is re-allocated by other thread and filled with data, then
(p)->head and (p)->prev_foot could be arbitary value and overhead_for(p)
could return a wrong value which leads to dlmalloc_usable_size() return
a wrong value eventually.

mspace_walk_heap() has the simliar issue.

Fixed them by adding protection to prevent p from re-allocated
when accessing (p)->head and (p)->prev_foot.

original id of the change is I4e3ea5cb2938aad1eef353cf6b661555a4ced44e
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Fix possible file descriptor leaking

Original code returns w/o closing the file descriptor
Close the descriptors and free the direct object before
return to avoid leaking

original id of the change I09204a8e989d041a12d6a6a00d1138b958f68a8f

picked from:
https://android-review.googlesource.com/#/c/23191/
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
memcmp: prefetch optimizing for ARM Cortex-A8/A9

Taken from ICS: http://review.cyanogenmod.com/#change,11309

Change-Id: If77b8cfdc0ab943db4534f060b82b05581ae071f
Merge "bionic: fixed the race condition in dlmalloc_usable_size()" into gingerbread
Merge "Fix possible file descriptor leaking" into gingerbread
Merge "libm: fix invalid result of function remquo/remquof" into gingerbread
Merge remote-tracking branch 'cm/gingerbread' into gingerbread