|
21 | 21 | #include <zlib.h> |
22 | 22 | #include <zstd.h> |
23 | 23 |
|
| 24 | +#include <bit> |
24 | 25 | #include <cstring> |
25 | 26 | #include <new> |
26 | 27 |
|
@@ -1465,9 +1466,7 @@ chd_flac_compressor::chd_flac_compressor(chd_file &chd, uint32_t hunkbytes, bool |
1465 | 1466 | : chd_compressor(chd, hunkbytes, lossy) |
1466 | 1467 | { |
1467 | 1468 | // determine whether we want native or swapped samples |
1468 | | - uint16_t native_endian = 0; |
1469 | | - *reinterpret_cast<uint8_t *>(&native_endian) = 1; |
1470 | | - m_big_endian = (native_endian == 0x100); |
| 1469 | + m_big_endian = (std::endian::native == std::endian::big); |
1471 | 1470 |
|
1472 | 1471 | // configure the encoder |
1473 | 1472 | m_encoder.set_sample_rate(44100); |
@@ -1542,9 +1541,7 @@ chd_flac_decompressor::chd_flac_decompressor(chd_file &chd, uint32_t hunkbytes, |
1542 | 1541 | : chd_decompressor(chd, hunkbytes, lossy) |
1543 | 1542 | { |
1544 | 1543 | // determine whether we want native or swapped samples |
1545 | | - uint16_t native_endian = 0; |
1546 | | - *reinterpret_cast<uint8_t *>(&native_endian) = 1; |
1547 | | - m_big_endian = (native_endian == 0x100); |
| 1544 | + m_big_endian = (std::endian::native == std::endian::big); |
1548 | 1545 | } |
1549 | 1546 |
|
1550 | 1547 |
|
@@ -1593,9 +1590,7 @@ chd_cd_flac_compressor::chd_cd_flac_compressor(chd_file &chd, uint32_t hunkbytes |
1593 | 1590 | throw std::error_condition(chd_file::error::CODEC_ERROR); |
1594 | 1591 |
|
1595 | 1592 | // determine whether we want native or swapped samples |
1596 | | - uint16_t native_endian = 0; |
1597 | | - *reinterpret_cast<uint8_t *>(&native_endian) = 1; |
1598 | | - m_swap_endian = (native_endian == 1); |
| 1593 | + m_swap_endian = (std::endian::native == std::endian::little); |
1599 | 1594 |
|
1600 | 1595 | // configure the encoder |
1601 | 1596 | m_encoder.set_sample_rate(44100); |
@@ -1722,9 +1717,7 @@ chd_cd_flac_decompressor::chd_cd_flac_decompressor(chd_file &chd, uint32_t hunkb |
1722 | 1717 | throw std::error_condition(chd_file::error::CODEC_ERROR); |
1723 | 1718 |
|
1724 | 1719 | // determine whether we want native or swapped samples |
1725 | | - uint16_t native_endian = 0; |
1726 | | - *reinterpret_cast<uint8_t *>(&native_endian) = 1; |
1727 | | - m_swap_endian = (native_endian == 1); |
| 1720 | + m_swap_endian = (std::endian::native == std::endian::little); |
1728 | 1721 |
|
1729 | 1722 | // init the inflater |
1730 | 1723 | m_inflater.next_in = (Bytef *)this; // bogus, but that's ok |
|
0 commit comments