atomics: implement locked versions of the atomics for other platforms

When GCC doesn't support an atomic operation, it attempts to link to
an external implementation to provide the support. This just implements
a locked version of the atomics to get the support into the codebase