Squashed commit of the following:

commit c68d109b0d2f25987c2b8eb9fbbcb1c980ad488e
Author: Evan McClain <aeroevan@gmail.com>
Date:   Mon Nov 21 19:42:24 2011 -0500

    Add a few missed endif's

    Change-Id: I47889d325490f5704637b050ae3f08ac6690691b
    Signed-off-by: Evan McClain <aeroevan@gmail.com>

commit ca03dfc845aee82bc9b133260d0736dd356d81ee
Author: Evan McClain <aeroevan@gmail.com>
Date:   Sat Nov 5 01:56:56 2011 -0400

    Add a static mutex for /dev/socket/dnsproxyd

    This prevents several threads from trying to read and write to this
    socket at the same time.

    This fixes a race condition between these libc functions and netd which
    would cause data connections to get stuck in the TEMP_FAILURE_RETRY
    loops if these functions are called at the same time.

    Patch Set 2: Use pthread_mutex_lock instead of trylock to more closely
    match the TEMP_FAILURE_RETRY that was there originally.

    Patch Set 3: Move dnsproxyd_lock.h out of include/net since netd doesn't
    need it.

    Patch Set 4: A few fixes thanks to Yuliyan Lesev.

    Change-Id: I1531b0baf5688b1ef57b21e768bb9c74906f02c9
    Signed-off-by: Evan McClain <aeroevan@gmail.com>

commit fde7f08dbdd17429d94fa944f12f15196f74184b
Author: Jim Huang <jserv@0xlab.org>
Date:   Wed Nov 2 00:44:16 2011 +0100

    bionic: remove V5 instruction for V6 targets (memcpy)

    Instructions in memcpy that are only needed for ARMV5 targets
    are now conditionally compiled for those targets.

    Change-Id: I0c327f73dd8ed62ba2c7ce8ed49129bc39118380

commit b213269f0c77bb7ef4eafde0e7a978c4a98af34f
Author: Jim Huang <jserv@0xlab.org>
Date:   Sun Oct 2 17:34:13 2011 +0800

    sha1: Use bswap* to optimize byte order

    bionic libc already makes use of ARMv6+ rev/rev16 instruction for
    endian conversion, and this patch rewrites some parts of SHA1
    implementations with swap32 and swap64 routines, which is known to
    bring performance improvements.

    The reference sha1bench on Nexus S:

    [before]
    Rounds: 100000, size: 6250K, time: 1.183s, speed: 5.16  MB/s

    [after]
    Rounds: 100000, size: 6250K, time: 1.025s, speed: 5.957 MB/sB

    Change-Id: Iefd7054f9700fe4aa9a8fb3b4b047504abf2a8bd

commit 02f3cdf8986f6e23d7e6ca528132d4d317bbd888
Author: Jim Huang <jserv@0xlab.org>
Date:   Sun Oct 2 01:56:48 2011 +0800

    sha1: code cleanup and use modern C syntax

    - Remove out-of-date workaround (SPARC64_GCC_WORKAROUND)
    - Use C99 prototype and stdint type

    Change-Id: Ic389eaf213b45b2ea922af03fdaf2004225df693

commit b6e5d258b089c7b12ea602ab5e66aafa78e0bcdb
Author: Jim Huang <jserv@0xlab.org>
Date:   Tue Sep 20 04:34:11 2011 +0800

    res_send: Avoid spurious close()s and (rare) failure

    When looping over the current list of sockets we are connected to,
    use getpeername() not getsockname() to find out who the remote
    end is.  This change avoids spurious close() and (rare) failure.

    ISC bug #18625 and fixed in libbind 6.0

    Change-Id: Ic2b84301a6b850afff5e1588d9fdcca944eb2ae6

commit 64f8c6f9f035570242b3fca64f1800d0d46dca9f
Author: Jim Huang <jserv@0xlab.org>
Date:   Wed Sep 7 02:43:02 2011 +0800

    Use GCC's __attribute__((const)) to reduce code size

    __attribute__((const)) is mainly intended for the compiler to optimize
    away repeated calls to a function that the compiler knows will return
    the same value repeatedly.

    By adding __attribute__((const)), the compiler can choose to call the
    function just once and cache the return value.  Therefore, this yields
    code size reduction.

    Here are the reference results by arm-eabi-size on crespo device:

    [original]
       text    data     bss     dec     hex filename
     257543   10040   45916  313499   4c89b

    [__attribute__ const]
       text    data     bss     dec     hex filename
     257255   10040   45916  313211   4c77b

    Change-Id: I6936b21475d2c54ad02c954b41714f3911474559

commit f3cbde71b399d574e7b8cbee7b2890d6236f5351
Author: Jim Huang <jserv@0xlab.org>
Date:   Sun Sep 18 07:37:25 2011 +0800

    dlmalloc: Use more efficient ARMv7 implementation for macro compute_bit2idx

    The macro compute_bit2idx(X, I) was definied as "I = ffs(X)-1".  This
    equals to the operation __builtin_ctz(X), and using the new bit-reversal
    instruction would have been better for ARMv7:
        rbit    r0, r0
        clz     r0, r0

    This patch re-implements macro compute_bit2idx by using the above ARMv7
    specific instructions to be more efficient.

    Reference: http://hardwarebug.org/2010/01/14/beware-the-builtins/

    Change-Id: I7cd49da327329c5d75e5e75a557fd115a0c7c0e2

commit 3a1ee14e19de665a7bd27e2c300ebf3958676f2f
Author: Jim Huang <jserv@0xlab.org>
Date:   Mon Sep 5 11:26:20 2011 +0800

    execvp: bcopy() is deprecated. Use memcpy() instead

    The function bcopy() is marked as LEGACY in POSIX.1-2001 and removed in
    POSIX.1-2008. memcpy (POSIX.1-2001) is its recommended replacement.

    Change-Id: I96ec407f89cacb39166a55a6c59e5acbbc473a71

commit edefbfce9464ebbefbe5fd5958c68567d5958fe0
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu Aug 11 04:48:29 2011 +0200

    Enable use of clz instruction in ffs function for all ARMv5+

    Enable use of faster code in ffs using clz instruction for
    other architectures than ARMv5.
    Also enables usage of ffs function in dlmalloc.

    Based on Change: Ifdc42db by c.bejram <christian.bejram@stericsson.com>

    Note: this ffs.S code is old, and the whole block could be deleted
          because android doesnt have support for ARMv4 SoCs

    Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>

commit 91af304e1e70b0672c35697defabaec776a73913
Author: Emilio López <turl@tuxfamily.org>
Date:   Thu Aug 4 16:15:56 2011 +0000

    Define PROP_MSG_SETPROP_SYNC

    Change-Id: Ia6ef7acb3d47d3ffa012d32745403ed1750593a5

commit ccd669524fcaff2427c6cbcaf78df82eaca42da4
Author: Sunita Nadampalli <sunitan@ti.com>
Date:   Thu Feb 10 00:26:48 2011 -0600

    bionic v4l2 header changes for zorder

    Description# v4l2 header window structure is extended for zorder support.
    This patch is a port from Froyo branch.

    Change-Id: Ic8b2223e721f65d5e20d34269573d38850b28b7a
    Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

commit 04d6983b6c44410d492cbd81ee1e024fcc782efd
Author: David Gottardo <d-gottardo@ti.com>
Date:   Tue Apr 12 14:16:50 2011 +0200

    Add ARM7 memory copy optimized (without NEON) version for OMAP4

    ARM7 optimized memcpy method from Bionic has better performances on the ARM
    The neon version is still used on ARM Cortex A8 (OMAP3).

    Patch Set 5: Added the Apache license per Eric Thomas's instructions
    Patch Set 6: Changing the date of the copyright and changing to "Texas Instruments"

    Change-Id: I531177c6f806ad6e43d61f7e4b26662acd019e41
    Signed-off-by: Barry Woodward <b-woodward@ti.com>

    Reverting back to NEON memcpy and adding a NOP at the end for errata

    This patch reverts back to the NEON version of the memcpy and uses the same
    method that we have used for deactivating the NEON unit upon return for other
    components (by adding a NOP).

    Change-Id: Ia524f704547fc00844a4997056378dcabaecb094
    Signed-off-by: Barry Woodward <b-woodward@ti.com>

commit 713aa7565b5ba8da1a0245c862da3cdc81af2ee4
Author: kallt_kaffe <kallt_kaffe@apedroid.com>
Date:   Thu Jun 30 15:55:09 2011 +0100

    bionic: Add VMSPLIT_2G support.

    Added VMSPLIT_2G support.

    Change-Id: Ic774271f21d2c45d04f239a3665308dd4db59fee

commit 3953ce1212397323d48aa914cfa96c7c82b140f0
Author: Giulio Cervera <giulio.cervera@gmail.com>
Date:   Wed May 4 16:18:54 2011 +0200

    bionic: updated headers for libaudio-msm7x30

    Change-Id: I95db35a18c943d92863d7b3f8a43860f0a84690d

commit 27a79dbb66a30683d193659a1b00bb5308c3e0a1
Author: Steve Kondik <shade@chemlab.org>
Date:   Sat Apr 9 16:13:23 2011 -0400

    Update msm_q6vdec header to match new decoder.

    Change-Id: I57dd78d3a381bbabbb68a0099ad3bfcfd0ce587d

commit 420055cbdea8dd8d081a3c10b11ba28456138914
Author: Giulio Cervera <giulio.cervera@gmail.com>
Date:   Thu Apr 7 15:39:24 2011 +0200

    bionic: add aic3254 and msm_audio_aac header

    Change-Id: I97d7e70a8768ae9e832d9d01c7bb8f44fb3a4b35

commit 930ea9b7d7660bc332190f690977f1f6c71d175b
Author: Steve Kondik <shade@chemlab.org>
Date:   Mon Mar 21 17:05:27 2011 -0400

    bionic: Update PMEM and VIDC headers

    Change-Id: I03702ec15266f7e652c66ef909d77403929f576d

commit ddb688e20a02634af4608c3c0c0a95c409f73374
Author: Jim Huang <jserv@0xlab.org>
Date:   Tue Aug 10 17:23:39 2010 +0800

    bionic: Add ARM optimized strcpy()

    Reference results of the experiments on Qualcomm MSM7x25 (524MHz):

    [original C code]
                 prc thr   usecs/call      samples   errors cnt/samp
    size
    strcpy_1k      1   1     14.56159           99        0     1000
    1024

    [ARM optimized code]
                 prc thr   usecs/call      samples   errors cnt/samp
    size
    strcpy_1k      1   1      3.46653           99        0     1000
    1024

    The work was derived from ARM Ltd.

    Change-Id: I906ac53bb7a7285e14693c77d3ce8d4ed6f98bfd

commit 148ae77c0a977916f11fbfbabee4df476a335a4b
Author: Simo Melenius <smelenius@nvidia.com>
Date:   Wed Mar 17 12:54:32 2010 +0200

    Posix-compliance: raise() didn't work with threads

    Albeit we have threads, Bionic only implemented the first case from
    raise() man page (see below). Thus, signal was always delivered to the
    main thread which is what you get from getpid():

    DESCRIPTION
           The raise() function sends a signal to the calling process or
           thread. In a single-threaded program it is equivalent to

               kill(getpid(), sig);

           In a multithreaded program it is equivalent to

               pthread_kill(pthread_self(), sig);

           If the signal causes a handler to be called, raise() will only
           return after the signal handler has returned.

    Change-Id: Idb4f51608578584595a73be4ba5dbc3c3d508b48
    Reviewed-on: http://git-master/r/871
    Reviewed-by: Antti Hatala <ahatala@nvidia.com>
    Tested-by: Antti Hatala <ahatala@nvidia.com>

commit 0425aa0f3695509baf4db54b4a510a0109128ebf
Author: Gary King <gking@nvidia.com>
Date:   Thu Mar 4 16:06:41 2010 -0800

    [bionic] implement work around for tegra errata 657451

    tegra 2 processors have a bug in the register read path of bit 20 of
    the CP15 c13, 3 register (used for software thread local storage)

    the kernel work-around for this bug is to mux the value from bit 20
    into bit 0; since the TLS value used by Android is an aligned address,
    bit 0 is known to be available.

    Change-Id: If70afa52585d327f9dd5eca479c14ca92532ddd8
    Reviewed-on: http://git-master/r/773
    Reviewed-by: Gary King <gking@nvidia.com>
    Tested-by: Gary King <gking@nvidia.com>

commit b684f828c7fbde335f460bcb32ae798136334997
Author: Gary King <gking@nvidia.com>
Date:   Wed Nov 18 13:50:29 2009 -0800

    bionic: use correct TLS code path

    bionic_tls.h provides two code paths for accessing the exposed kernel TLS
    variable, depending on the kernel configuration used, and uses a preprocessor
    define to select the correct path. this commit ensures that the linker
    specifies the preprocessor symbol correctly

    Change-Id: I8b21f430a13fd09dd76232e13e53909e477a0ac7

commit 335fa60a6d2db5b5c02f1c0540060fda4d75a4de
Author: Steve Kondik <shade@chemlab.org>
Date:   Sat Nov 20 02:14:51 2010 -0500

    bionic: Add NASTY_PTHREAD_CREATE_HACK

    This is a workaround for bad linkage of proprietary libs on certain
    devices. Thanks to Zinx for tracking it down.

    Change-Id: Ice2da9c02c3c84b9ed417e623b248a87b8f9678e

commit f3a291b93c8f750e495199328f91555a234f7f03
Author: Bradley Froehle <brad.froehle@gmail.com>
Date:   Mon Oct 18 17:38:37 2010 -0700

    msm_mdp.h: ifdef the reference to sharpening_strength

    The sharpening_strength field in mdp_blit_req is only in the
    staging/msm version of msm_mdp.h, not in the video/msm version
    which is the version currently being compiled in all of the
    kernels.

    As a result, I've wrapped the sharpening_strength field in a
    CONFIG_MSM_MDP40 ifdef.  Note, however, it may be more appropriate
    to instead check if MDP_BLIT_REQ_VERSION >= 2.

    This fixes the issue of error messages similar to:
      E/copybit (  146): copyBits failed (Invalid argument)
      D/copybit (  146): 0: src={w=320, h=480, f=0, rect={0,338,13,73}}
      D/copybit (  146):     dst={w=320, h=480, f=0, rect={0,338,13,73}}
      D/copybit (  146):     flags=00020000
      D/copybit (  146): 1: src={w=320, h=480, f=0, rect={307,338,13,73}}
      D/copybit (  146):     dst={w=320, h=480, f=0, rect={307,338,13,73}}
      D/copybit (  146):     flags=00020000
      D/copybit (  146): 2: src={w=320, h=480, f=0, rect={0,411,320,69}}
      D/copybit (  146):     dst={w=320, h=480, f=0, rect={0,411,320,69}}
      D/copybit (  146):     flags=00020000
      E/libagl  (  146): copybit failed (Unknown error: -22)
    which are triggered, for example, by dragging down the status bar.

    Change-Id: I20e7696442e888ea1ac0c80ef1e2cc22f08028aa

commit a476149732d62e5f0e36c38d1164b3d11bccd4d1
Author: Steve Kondik <shade@chemlab.org>
Date:   Fri Oct 15 16:37:31 2010 -0400

    bionic: Add msm_audio_7X30 header file

    Change-Id: I2d717dd63ebccad9d7a993b01993201b0eebd9e1

commit 4aac5e0a1670ceaaee0f0b206dd05d1c1d4f0254
Author: Steve Kondik <shade@chemlab.org>
Date:   Thu Sep 30 19:56:27 2010 -0400

    7x30: Update msm_mdp.h header from CodeAurora/HTC

    Change-Id: Iea2ce3162651ed1e8be2ef8f2983a7df01323b4e

commit 22536aa2406e7694940906c271738be063c2346e
Author: Naomi Luis <nluis@codeaurora.org>
Date:   Wed Jul 7 23:17:28 2010 -0700

    bionic: Add msm_rotator.h

    Add the msm_rotator header file to match the rotator driver header file
    used on the msm7x30 target.

    Change-Id: I208219e79c9ec5878c6078cb4cfb8b242a2f6a67

commit 10098e12bd81fd0d650cb72efa1ffe664b8a7032
Author: Steve Kondik <shade@chemlab.org>
Date:   Tue Nov 16 18:06:31 2010 -0500

    bionic: Add akm8975 header

    Change-Id: I5c491a47ebc8d2e7721ce068b4bb3f6c6058fcad

commit cba9cf905a873a7a2d356e491d4080a5bda5cff4
Author: Koushik Dutta <koushd@gmail.com>
Date:   Mon Jun 28 09:07:05 2010 -0700

    mark this as cyanogen bionic for busybox

    Change-Id: I112ae59ca5e4d153d4851d8f80838cd22b03dc98

commit 8bf694b200fb3558f5d39d64a125390a0c3feca8
Author: Steve Kondik <shade@chemlab.org>
Date:   Mon Apr 19 10:37:03 2010 -0400

    Additions necessary for busybox

    Change-Id: I46f67991858ca1399f6b28a3a5c286b7f3ef0888

Change-Id: I022bee7279bbdfee0e99a6ea048f8d405e5b98d0
Signed-off-by: Evan McClain <aeroevan@gmail.com>

Conflicts:

	libc/Android.mk
	libc/bionic/dlmalloc.c
timezone: data file should be 32 bit aligned

The zoneinfo.dat file is memory mapped and then read as an int array.
On some platforms this is causing alignment errors (SIGBUS) because
the records are not 32 bit aligned.

Change-Id: Ieea8ef07e49ef86d139c52ebfccf4159c0ebd886
Revert "don't hide _nres, necessary for nslookup in busybox."

This reverts commit 0aa56a2ed38e470259b0fcbfc7ba4387149b81db.
merge cyanogen/ics

Change-Id: I1acde90b767cae6ed4c865ad9d66f6d9322f5e97
Merge remote-tracking branch 'aosp/ics-mr1-release' into ics

Conflicts:
	libc/zoneinfo/zoneinfo.dat
	libc/zoneinfo/zoneinfo.idx

	resolved with aosp/master
videodev2: added V4L2_CID_CACHEABLE

Change-Id: Ia8b7b71034a7328deac9923ef2467e69dc5e4cb2
fix ARMv7 optimized strlen() usage condition

Change-Id: Ia2ab059b092f80c02d95ca95d3062954c0ad1023
timezone: update to tzdata2012b and fix ARMv5/6 SIGBUS

The update to Android 4.0.4 updated the timezone data file to once again not be 32
bit aligned, causing SIGBUS on ARMv5/6. See previous comment in commit 9cc174f2.

Change-Id: Ia58065a70402e17ce74f7902b69612c432cc73da
Fix struct members named __unused

__unused is a macro expanding either to __attribute__((__unused__)) or
nothing so an identifier may never be called __unused. This changes them
to be named __unused1, according to other naming, instead.

Change-Id: I3ca45b43b3d4be9e8285a246b652b5fe8bea75b8
getopt(): fix missing carriage return on bad parameters

This affect all command line tools which show the usage on stdout
after an invalid parameter error (printed on stderr)

Change-Id: I8e2cb3fda241ab989dc42055f15082f8b3ba1397
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Add unshare system call

Adds a C function for the unshare system call supported by Linux since
2.6.16.

Change-Id: I32df4075d875e9f5b5ed716cd7b02cdf82c64526
libc/linker: Reduce diff with cm mainline

introduced by 7ced56200441acdb35bc8507b90b56e2030818ee

The libc syscalls should not be altered, to keep compat.

Change-Id: Iee29ef634afe5524c595c09707f1f8d7f472709c
linker: return to mainline, revert _gnu_hash_lookup

Change-Id: Ie551b7aab7c71e10f24dca7b579eeb623f98a3c8
Avoid multiple dns lookups for the same query

If two or more rapid dns requests for the same server are done
from different threads it turns into separate dns reques, if
the response of the request isn't found in the cache.

This patch avoid multiple request for the same server by
letting subsequents request wait until the first request
has finished.

Change-Id: Ic72ea0e7d3964a4164eddf866feb4357ec4dfe54
Remove expired dns cache entries before removing oldest

A suggestion how to make a smarter delete function when the cache
is full. First look through the entire cache and remove all entries
which have expired. If none use the old solution and just remove
the last entry in the MRU list.

Change-Id: I5f997ab35290a55dc6e1ddf37d725759edf83d36
Remove the meaningless on Linux if_dl.h header.

This was misleading 'configure' into thinking we actually support AF_LINK,
but we're Linux, so we don't, and we never implemented the functions we
declared here either.

Reported to AOSP by Jun-ya Kato.

(cherry-pick of 5056f1fad1187cd67729bb04ba72397d78256f03.)

Change-Id: Ic67f674d2221497c8166994812bb5fc7f0831066
Add the posix_memalign(3) function to bionic

The posix_memalign(3) function is very similar to the traditional
memalign(3) function, but with better error reporting and a guarantee
that the memory it allocates can be freed.  In bionic, memalign(3)
allocated memory can be freed, so posix_memalign(3) is just a wrapper
around memalign(3).

Change-Id: I62ee908aa5ba6b887d8446a00d8298d080a6a299
Merge remote-tracking branch 'eppy/ics' into ics

Conflicts:
	libc/bionic/dlmalloc.c
	libc/kernel/common/linux/android_pmem.h
	libc/netbsd/net/getaddrinfo.c
	libc/netbsd/net/getnameinfo.c