1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-27 06:12:15 +00:00

util: prevent optimizer from removing endian-swapped writes

This commit is contained in:
Michael Scire 2022-05-08 15:32:59 -07:00
parent 187745abd5
commit 7557b7eb92

View file

@ -144,12 +144,12 @@ namespace ams::util {
template<std::integral T> template<std::integral T>
constexpr ALWAYS_INLINE void StoreBigEndian(T *ptr, T val) { constexpr ALWAYS_INLINE void StoreBigEndian(T *ptr, T val) {
*ptr = ConvertToBigEndian<T>(val); *static_cast<volatile T *>(ptr) = ConvertToBigEndian<T>(val);
} }
template<std::integral T> template<std::integral T>
constexpr ALWAYS_INLINE void StoreLittleEndian(T *ptr, T val) { constexpr ALWAYS_INLINE void StoreLittleEndian(T *ptr, T val) {
*ptr = ConvertToLittleEndian<T>(val); *static_cast<volatile T *>(ptr) = ConvertToLittleEndian<T>(val);
} }
} }