Driver registry and other global API resources made thread safe

Added mutexes and atomics for Win32, Un*x and (partially) OS X.

Moved a2_GetTicks() and a2_GetMicros() into platform.h.

Added mutex synchronization for the driver registry.

Added global API resource management; an atomic reference
counter that counts API users, and logic to initialize and
clean up global state (reference time for a2_GetTicks(), mutex
for the driver registry etc) as needed.

Master states also count towards the API resource refcount,
rather than having its own counter.

Closes #83.