atomic: make atomic_store_ptr type-aware
(cherry picked from commit cc96f92a570e05636a20fdd15d4616b127bb9ecc)