diff options
| author | 2024-11-28 15:16:54 +0100 | |
|---|---|---|
| committer | 2024-11-28 15:16:54 +0100 | |
| commit | 8f24c4876a32b4f19e459bedd1fdbbc54cb0daa9 (patch) | |
| tree | 4316563019acbd85e277422afe5b687959f2e940 /src/bplist.c | |
| parent | 3a1404c2e87daff1eb45c3f21182b7ede7a7a82b (diff) | |
| download | libplist-8f24c4876a32b4f19e459bedd1fdbbc54cb0daa9.tar.gz libplist-8f24c4876a32b4f19e459bedd1fdbbc54cb0daa9.tar.bz2 | |
Switch from detecting little endian (common) to detecting big endian (rare)
This prevents a bug class where we bswap things when __LITTLE_ENDIAN__ is not defined.
Almost all modern systems are little endian, so detecting __BIG_ENDIAN__ is a better strategy.
Diffstat (limited to 'src/bplist.c')
| -rw-r--r-- | src/bplist.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/bplist.c b/src/bplist.c index 93f0bc6..1216974 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -168,15 +168,13 @@ union plist_uint_ptr | |||
| 168 | 168 | ||
| 169 | #define get_real_bytes(x) ((x) == (float) (x) ? sizeof(float) : sizeof(double)) | 169 | #define get_real_bytes(x) ((x) == (float) (x) ? sizeof(float) : sizeof(double)) |
| 170 | 170 | ||
| 171 | #if (defined(__LITTLE_ENDIAN__) \ | 171 | #if (defined(__BIG_ENDIAN__) && !defined(__FLOAT_WORD_ORDER__)) \ |
| 172 | && !defined(__FLOAT_WORD_ORDER__)) \ | 172 | || (defined(__FLOAT_WORD_ORDER__) && __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) |
| 173 | || (defined(__FLOAT_WORD_ORDER__) \ | ||
| 174 | && __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__) | ||
| 175 | #define float_bswap64(x) bswap64(x) | ||
| 176 | #define float_bswap32(x) bswap32(x) | ||
| 177 | #else | ||
| 178 | #define float_bswap64(x) (x) | 173 | #define float_bswap64(x) (x) |
| 179 | #define float_bswap32(x) (x) | 174 | #define float_bswap32(x) (x) |
| 175 | #else | ||
| 176 | #define float_bswap64(x) bswap64(x) | ||
| 177 | #define float_bswap32(x) bswap32(x) | ||
| 180 | #endif | 178 | #endif |
| 181 | 179 | ||
| 182 | #ifndef __has_builtin | 180 | #ifndef __has_builtin |
