test: simplify test-ip6-addr.c

Drop the callback-driven approach in favor of a simple loop. Reduces
the line count and makes the flow of execution a little easier to
follow.
unix, windows: fix ipv6 link-local address parsing

uv_ip6_addr() copies the address part to a temporary buffer when it
contains a link-local suffix ('<address>%<interface>'). Before this
commit, it didn't zero-terminate the address properly: it put the nul
byte at the end of the temporary buffer rather than at the end of the
address string, meaning the buffer looked like this:

    <address> <garbage> '\0'

Fixes the following valgrind warning:

    ==16170== Conditional jump or move depends on uninitialised value(s)
    ==16170==    at 0x43602C: inet_pton6 (inet.c:228)
    ==16170==    by 0x435CE1: uv_inet_pton (inet.c:163)
    ==16170==    by 0x436FD0: uv_ip6_addr (uv-common.c:175)
    ==16170==    by 0x434717: test_ip6_addr_scope (test-ip6-addr.c:89)
    ==16170==    by 0x43455B: call_iface_info_cb (test-ip6-addr.c:45)
    ==16170==    by 0x43462B: foreach_ip6_interface (test-ip6-addr.c:59)
    ==16170==    by 0x434791: run_test_ip6_addr_link_local (test-ip6-add
    ==16170==    by 0x4061E8: run_test_part (runner.c:396)
    ==16170==    by 0x404F4B: main (run-tests.c:58)
    ==16170==
    ==16170== Conditional jump or move depends on uninitialised value(s)
    ==16170==    at 0x4C2AD8A: __GI_strchr (mc_replace_strmem.c:224)
    ==16170==    by 0x435ECB: inet_pton6 (inet.c:231)
    ==16170==    by 0x435CE1: uv_inet_pton (inet.c:163)
    ==16170==    by 0x436FD0: uv_ip6_addr (uv-common.c:175)
    ==16170==    by 0x434717: test_ip6_addr_scope (test-ip6-addr.c:89)
    ==16170==    by 0x43455B: call_iface_info_cb (test-ip6-addr.c:45)
    ==16170==    by 0x43462B: foreach_ip6_interface (test-ip6-addr.c:59)
    ==16170==    by 0x434791: run_test_ip6_addr_link_local (test-ip6-add
    ==16170==    by 0x4061E8: run_test_part (runner.c:396)
    ==16170==    by 0x404F4B: main (run-tests.c:58)

Fixes #890.
fsevents: FSEvents is most likely not thread-safe

Perform all operation with FSEventStream in the same thread, where it'll
be used.
windows: omit stdint.h, fix msvc 2008 build error

Don't include <stdint.h>, it's not available when compiling with MSVC
2008 and we don't need it in the first place - just cast the argument
to `char *` rather than `uintptr_t`.

Fixes #893.
2013.08.22, Version 0.11.8 (Unstable)

Changes since version 0.11.7:

* unix: fix missing return value warning in stream.c (Ben Noordhuis)

* build: serial-tests was added in automake v1.12 (Ben Noordhuis)

* windows: fix uninitialized local variable warning (Ben Noordhuis)

* windows: fix missing return value warning (Ben Noordhuis)

* build: fix string comparisons in autogen.sh (Ben Noordhuis)

* windows: move INLINE macro, remove UNUSED (Ben Noordhuis)

* unix: clean up __attribute__((quux)) usage (Ben Noordhuis)

* sunos: remove futimes() macro (Ben Noordhuis)

* unix: fix uv__signal_unlock() prototype (Ben Noordhuis)

* unix, windows: allow NULL async callback (Ben Noordhuis)

* build: apply dtrace -G to all object files (Timothy J. Fontaine)

* darwin: fix indentation in uv__hrtime() (Ben Noordhuis)

* darwin: create fsevents thread on demand (Ben Noordhuis)

* darwin: reduce fsevents thread stack size (Ben Noordhuis)

* darwin: call pthread_setname_np() if available (Ben Noordhuis)

* build: fix automake serial-tests check again (Ben Noordhuis)

* unix: retry waitpid() on EINTR (Ben Noordhuis)

* darwin: fix ios build error (Ben Noordhuis)

* darwin: fix ios compiler warning (Ben Noordhuis)

* test: simplify test-ip6-addr.c (Ben Noordhuis)

* unix, windows: fix ipv6 link-local address parsing (Ben Noordhuis)

* fsevents: FSEvents is most likely not thread-safe (Fedor Indutny)

* windows: omit stdint.h, fix msvc 2008 build error (Ben Noordhuis)
Now working on v0.11.9
2013.08.22, Version 0.10.14 (Stable)

Changes since version 0.10.13:

* unix: retry waitpid() on EINTR (Ben Noordhuis)
Now working on v0.10.15
fsevents: use shared FSEventStream

It seems that number of simultaneously opened FSEventStreams is
limited on OSX (i.e. you can have only fixed number of them on
one running system), getting past through this limit will cause
`FSEventStreamCreate` to return false and write following message
to stderr:

    (CarbonCore.framework) FSEventStreamStart: register_with_server:
    ERROR: f2d_register_rpc() => (null) (-21)

To prevent this, we must use only one shared FSEventStream with a
paths for all uv_fsevent_t handles, and then filter out events for
each handle using this paths again.

See https://github.com/joyent/node/issues/5463
darwin: create fsevents thread on demand

* Move CF run loop code to fsevents.c.

* Create the fsevents thread on demand rather than at startup.

* Remove use of ACCESS_ONCE. All accesses to loop->cf_loop are
  protected by full memory barriers so no reordering can take place.

Fixes #872.

Conflicts:
	src/unix/darwin.c
fsevents: FSEvents is most likely not thread-safe

Perform all operation with FSEventStream in the same thread, where it'll
be used.

Conflicts:
	src/unix/fsevents.c
fsevents: use shared FSEventStream

It seems that number of simultaneously opened FSEventStreams is
limited on OSX (i.e. you can have only fixed number of them on
one running system), getting past through this limit will cause
`FSEventStreamCreate` to return false and write following message
to stderr:

    (CarbonCore.framework) FSEventStreamStart: register_with_server:
    ERROR: f2d_register_rpc() => (null) (-21)

To prevent this, we must use only one shared FSEventStream with a
paths for all uv_fsevent_t handles, and then filter out events for
each handle using this paths again.

See https://github.com/joyent/node/issues/5463

Conflicts:
	include/uv-private/uv-darwin.h
	src/unix/fsevents.c
windows: make uv_spawn() failure more predictable

* It will now report some types of errors synchronously, to bring it on
  par with uv-unix. Fixes #865.

* Failure to find the target executable will now set up stdio pipes
  correctly, so the user can assume that when uv_spawn() returns 0 these
  pipes will never trigger asserts in libuv's guts.
process: make the 'status' parameter for exit_cb an int64_t

This means we no longer have to strip the high bit from the process exit
code on Windows, which is problematic because an unhandled SEH exception
can make a process exit with a status code that has the high bit set.
2013.08.24, Version 0.11.9 (Unstable)

Changes since version 0.11.8:

* fsevents: share FSEventStream between multiple FS watchers, which
  removes a limit on the maximum number of file watchers that can be
  created on OS X. (Fedor Indutny)

* process: the `exit_status` parameter for a uv_process_t's exit
  callback now is an int64_t, and no longer an int. (Bert Belder)

* process: make uv_spawn() return some types of errors immediately on
  windows, instead of passing the error code the the exit callback. This
  brings it on par with libuv's behavior on unix. (Bert Belder)
Now working on v0.11.10
2013.08.24, Version 0.10.15 (Stable)

Changes since version 0.10.14:

* fsevents: create FSEvents thread on demand (Ben Noordhuis)

* fsevents: use a single thread for interacting with FSEvents, because
  it's not thread-safe. (Fedor Indutny)

* fsevents: share FSEventStream between multiple FS watchers, which
  removes a limit on the maximum number of file watchers that can be
  created on OS X. (Fedor Indutny)
Now working on v0.10.16
linux: fix setsockopt(SO_REUSEPORT) error handling

Linux as of 3.9 has a SO_REUSEPORT option that is similar but not
identical to its BSD counterpart.

On the BSDs, it turns on SO_REUSEADDR _and_ makes it possible to share
the address and port across processes.

On Linux, it "merely" enables fair load distribution - port sharing
still requires that you set SO_REUSEADDR.

Fair distribution is a desirable trait but not an essential one.
We don't know in advance whether the kernel actually supports
SO_REUSEPORT so don't treat EINVAL or ENOPROTOOPT as errors.

As an aside, on the BSDs we now omit the setsockopt(SO_REUSEADDR)
system call because it's implied by SO_REUSEPORT.

Fixes #870.
windows: make uv_fs_chmod() report errors correctly

Before this patch libuv would attempt to use GetLastError() to retrieve
the cause of NtQueryInformationFile failure, but that's not how it
should be done.