Merge pull request #3070 from cesanta/hton

remove memcpy from htons/l and test load/save bigendian macros
This commit is contained in:
Sergio R. Caprile authored and GitHub committed 2025-03-08 14:46:46 -03:00
commit fbc231f33e
5 files changed
+71 -48

No files matched your search

-13
View File
@@ -19175,19 +19175,6 @@ char *mg_random_str(char *buf, size_t len) {
return buf;
}
uint32_t mg_ntohl(uint32_t net) {
uint8_t data[4] = {0, 0, 0, 0};
memcpy(&data, &net, sizeof(data));
return (((uint32_t) data[3]) << 0) | (((uint32_t) data[2]) << 8) |
(((uint32_t) data[1]) << 16) | (((uint32_t) data[0]) << 24);
}
uint16_t mg_ntohs(uint16_t net) {
uint8_t data[2] = {0, 0};
memcpy(&data, &net, sizeof(data));
return (uint16_t) ((uint16_t) data[1] | (((uint16_t) data[0]) << 8));
}
uint32_t mg_crc32(uint32_t crc, const char *buf, size_t len) {
static const uint32_t crclut[16] = {
// table for polynomial 0xEDB88320 (reflected)