unix: add atomic-ops.h

Add cmpxchgi(), cmpxchgl() and cpu_relax() functions that we can use
as simple primitives to build spinlocks out of.
unix: add spinlock.h

Add an atomic, non-blocking spinlock type.  The primary use case is to
have a mutex type that we can use while inside a signal handler.
unix: clean up uv_tty_set_mode() a little
unix: make uv_tty_reset_mode() async signal-safe

Make it possible to call uv_tty_reset_mode() from inside a signal
handler.  The primary motivation is to make it possible to restore
the TTY from inside a SIGINT or SIGTERM signal handler.

Fixes #954.
unix: use spinlock in signal handler in signal.c

Use a spinlock instead of a pipe to synchronize access to the signal
watcher tree.  Saves two file descriptors and fixes a file descriptor
leak when libuv.so is unloaded.

Closing the pipe fds from an __attribute__((destructor)) function would
accomplish the same thing except that the interaction of destructors and
threads is only weakly defined; it's anybody's guess what would happen
if main() exited when there are still threads using the signal pipe.

Fixes #875.