Add a fully implementation of endian.h#2
Conversation
…eturn ENOSYS; add more comment to explain the code
|
Nice work overall - the three-tier compiler detection and manual fallback bswap are solid. A few things are worth addressing before i merge: [bug] Macro argument not consistently parenthesized in manual bswap fallback In the // e.g. __bswap32(a | b) expands to:
(uint32_t)((((uint32_t)(a | b) >> 24) & 0xff) | ...)
// ^^^^^^^ fine here, but not guaranteed safe everywhereEvery occurrence of [bug] Defining these without an #ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endifor use a private namespace alias (e.g. [robustness] No fallback If a compiler defines #if (__LIBC_BYTE_ORDER == LITTLE_ENDIAN)
// ...
#elif (__LIBC_BYTE_ORDER == BIG_ENDIAN)
// ...
#else
#error "Unrecognised byte order — please add support for this target"
#endif |
|
Thanks for ur reply, btw I have university entrance exam and graduation exam so Ima work on the fix a bit late ❤️ |
Add a fully implementation of endian.h
Overview
Functions & Macros