fix memory barriers in atomic operations

Here are my changes for atomic.hpp, in case you need them for 1.57. 
Otherwise, please disregard the pull request completely...

/Lars