unix, windows: add thread-local storage API

Uses the pthread_key_{create,delete} and pthread_{get,set}specific
functions on UNIX platforms, Tls{Alloc,Free} and Tls{Get,Set}Value
on Windows.

Fixes #904.
windows: tweak Makefile.mingw for easier usage

Default CC to `gcc` instead of `cc` because at least on the mingw
installation I had there was no `cc` executable. This avoids having
to type `CC=gcc` in all the `make` commands.

Also append to `CFLAGS` instead of defining if not previously defined.
These flags are required to build libuv, so they should not be
overridden if other extra CFLAGS are supplied via the command
line as well.
windows: fix mingw build

On older mingw installations, DEVICE_TYPE isn't defined. This was
redefined in windows.h, but it was done after it was already attempted
to be used. This moves the #define for DEVICE_TYPE above the usage of
it in windows.h to prevent compilation failures.
unix: fix SIGCHLD processing in process.c

Quick for for joyent/libuv#887.