mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-27 20:48:29 +00:00
Fix endianness issues in unit test
This commit is contained in:
1 parent
b5355307a3
commit
88097f1829
7 files changed
+41
-73
No files matched your search
+15
-17
@@ -2802,18 +2802,16 @@ void mg_hexdump(const void *buf, size_t len) {
|
||||
#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5
|
||||
|
||||
static void mg_byte_reverse(unsigned char *buf, unsigned longs) {
|
||||
/* Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN */
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
do {
|
||||
uint32_t t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32_t *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
#else
|
||||
(void) buf;
|
||||
(void) longs;
|
||||
#endif
|
||||
if (MG_BIG_ENDIAN) {
|
||||
do {
|
||||
uint32_t t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32_t *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
} else {
|
||||
(void) buf, (void) longs; // Little endian. Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
@@ -3646,11 +3644,11 @@ union char64long16 {
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
static uint32_t blk0(union char64long16 *block, int i) {
|
||||
/* Forrest: SHA expect BIG_ENDIAN, swap if LITTLE_ENDIAN */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
block->l[i] =
|
||||
(rol(block->l[i], 24) & 0xFF00FF00) | (rol(block->l[i], 8) & 0x00FF00FF);
|
||||
#endif
|
||||
if (MG_BIG_ENDIAN) {
|
||||
} else {
|
||||
block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) |
|
||||
(rol(block->l[i], 8) & 0x00FF00FF);
|
||||
}
|
||||
return block->l[i];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user