diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-04-19 22:35:15 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-04-19 22:35:15 +0300 |
commit | f5970c7804f6bb6f5d99172e048d7a126657b570 (patch) | |
tree | e961f3f3628345840dcf11c51ec2bae34aa252b7 /src/microhttpd/mhd_bithelpers.h | |
parent | a50b4d566f089ae46402a6f38096a0ff9c50eae2 (diff) | |
download | libmicrohttpd-f5970c7804f6bb6f5d99172e048d7a126657b570.tar.gz libmicrohttpd-f5970c7804f6bb6f5d99172e048d7a126657b570.zip |
mhd_bithelpers.h: define _MHD_GET_32BIT_LE() and use it in md5.c
Diffstat (limited to 'src/microhttpd/mhd_bithelpers.h')
-rw-r--r-- | src/microhttpd/mhd_bithelpers.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_bithelpers.h b/src/microhttpd/mhd_bithelpers.h index fa09f92a..6c4f0fea 100644 --- a/src/microhttpd/mhd_bithelpers.h +++ b/src/microhttpd/mhd_bithelpers.h | |||
@@ -101,6 +101,25 @@ | |||
101 | } while (0) | 101 | } while (0) |
102 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 102 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
103 | 103 | ||
104 | /* _MHD_GET_32BIT_LE (addr) | ||
105 | * get little-endian 32-bit value storied at addr | ||
106 | * and return it in native-endian mode. | ||
107 | */ | ||
108 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | ||
109 | #define _MHD_GET_32BIT_LE(addr) \ | ||
110 | (*(uint32_t*)(addr)) | ||
111 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | ||
112 | #define _MHD_GET_32BIT_LE(addr) \ | ||
113 | _MHD_BYTES_SWAP32(*(uint32_t*)(addr)) | ||
114 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | ||
115 | /* Endianess was not detected or non-standard like PDP-endian */ | ||
116 | #define _MHD_GET_32BIT_LE(addr) \ | ||
117 | ( ( (uint32_t)(((uint8_t*)addr)[0])) | \ | ||
118 | (((uint32_t)(((uint8_t*)addr)[1])) << 8) | \ | ||
119 | (((uint32_t)(((uint8_t*)addr)[2])) << 16) | \ | ||
120 | (((uint32_t)(((uint8_t*)addr)[3])) << 24) ) | ||
121 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | ||
122 | |||
104 | 123 | ||
105 | /* _MHD_PUT_64BIT_BE (addr, value64) | 124 | /* _MHD_PUT_64BIT_BE (addr, value64) |
106 | * put native-endian 64-bit value64 to addr | 125 | * put native-endian 64-bit value64 to addr |