Fix build on FreeBSD 8.2

Hi guys

There are two issues on FreeBSD at least 8.2. First `ms_atomic.h` check for `HAVE_GCC_ATOMIC_BUILTINS` which is happened undefined on my amazon FreeBSD-8.2-RELEASE instance.

```diff
-#elif HAVE_GCC_ATOMIC_BUILTINS
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
```

The second fix uses atomic operations from `<machine/atomic.h>` on FreeBSD.

Thanks