Update git__swap thread helper

This makes git__swap use the __sync_lock_test_and_set primitive
with GCC and the InterlockedExchangePointer primitive with MSVC.
Previously is used compare_and_swap in a way that was probably
unintuitive for most thinking (i.e. it could fail to swap in the
value if another thread raced in).  Now it will always succeed
and the last thread to run in a race will win instead of the
first thread.

This also fixes up a little confusion between volatile void **
and void * volatile * that came up with the Win32 compiler.
Fix warnings on Win64
Merge pull request #1719 from libgit2/arrbee/threading-primitives

Update git__swap threading primitive
thread safe config with git_bufs
refcounting on bufs, ungh