unix: make uv_tty_reset_mode() async signal-safe

Make uv_tty_reset_mode() async signal-safe and add some atomic operations and a spinlock type while we're here.

Suggested reviewer: @sam-github?