Add pipe2 and O_CLOEXEC to the libcore POSIX API.

@hide right now, but we should expose these at some point.

Bug: 18719692
Change-Id: I0a73606cf089ed307d1ab2916a7df28b3c45aaf0
Fix native registration.

I thought I'd tested my previous change but hadn't.

Change-Id: Ie121b571cc2f767dd4bbe10291a56fe31496e6cc
Fix poll to never return EINTR.

Bug: 18759467
Change-Id: Ia5b97a55318b5990ad6b80d15641223aa4fb06f5

Conflicts:
	luni/src/main/native/libcore_io_Posix.cpp
Don't TEMP_FAILURE_RETRY calls that can't fail.

It turns out that while GCC doesn't care, clang is unhappy with us
because it notices that we're comparing an unsigned value (like a uid_t)
against -1:

  libcore/luni/src/main/native/libcore_io_Posix.cpp:727:12: error: comparison
  of integers of different signs: 'typeof (getegid())' (aka 'unsigned int')
  and 'int' [-Werror,-Wsign-compare]
    return TEMP_FAILURE_RETRY(getegid());
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bug: 18759467
Change-Id: If71b11cbdd0cda2b8efcc1706eb49856c3770bb8
Update ByteBuffer positions in Posix.* functions.

Also add tests in libcore.io.OsTest and update (and simplify)
callers that were updating the position themselves.

bug: 18641009

(cherry picked from commit f3b61eaf1931ae8393e54202a717334a4971ebdf)

Change-Id: I8a810b2dfde7c13278807381bdfe7f532a3481a0
When connecting to a SOCKS proxy, use the resolved IP

Noticed while inspecting the code. In HttpURLConnection a similar
change was made recently (commit
797fdc6cc6bf16372e9464f189b535148f944ce9).

Previously if the Proxy was specified with a resolved
InetSocketAddress (i.e. one with a specific IP address already
determined) the hostname would still be used to work out an IP
address to connect to. For host names with multiple IPs the host
connected to could be a different one than the one specified.

Now if the InetAddress has been resolved it will be used. In the
case where the InetAddress is bad this may delay DNS / resolution
errors to later in the connection process. It will, however, avoid
the "connect to a different host" issue, and avoid a reverse DNS
lookup here when the host is not yet known.

Change-Id: I46df5c38942f2d356ba2fd4541e0269021fd6496
Fix InetSocketAddress.getHostString(): return the name if available

getHostString() would return the IP address in one of the three
scenarios possible:

1) InetSocketAddress created with a name - already worked, name returned.
2) InetSocketAddress create with an InetAddress with only an address - already worked,
  address returned.
3) InetSocketAddress create with an InetAddress with an address and name: would return
the address.

Change-Id: Id9d1addda5cef589ac56db5397e00e842cf8c5d7