This commit is contained in:
Kovid Goyal 2023-11-09 17:28:05 +05:30
parent 38c8100a76
commit 8dbea2a046
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -131,16 +131,18 @@ typedef struct byte_loader {
} byte_loader; } byte_loader;
static uint8_t static uint8_t
byte_loader_peek(const byte_loader *self) {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
byte_loader_peek(const byte_loader *self) { return self->m & 0xff; } return self->m & 0xff;
#define SHIFT_OP >> #define SHIFT_OP >>
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
// no idea if this correct needs testing // no idea if this is correct needs testing
return (self->m >> ((sizeof(self->m) - 1)*8)) & 0xff;
#define SHIFT_OP << #define SHIFT_OP <<
byte_loader_peek(const byte_loader *self) { return (self->m >> ((sizeof(self->m) - 1)*8)) & 0xff; }
#else #else
#error "Unsupported endianness" #error "Unsupported endianness"
#endif #endif
}
static void static void
byte_loader_init(byte_loader *self, const uint8_t *buf, unsigned int sz) { byte_loader_init(byte_loader *self, const uint8_t *buf, unsigned int sz) {