diff options
Diffstat (limited to 'src/microhttpd/mhd_bithelpers.h')
-rw-r--r-- | src/microhttpd/mhd_bithelpers.h | 152 |
1 files changed, 78 insertions, 74 deletions
diff --git a/src/microhttpd/mhd_bithelpers.h b/src/microhttpd/mhd_bithelpers.h index ac2a13ce..34e49d15 100644 --- a/src/microhttpd/mhd_bithelpers.h +++ b/src/microhttpd/mhd_bithelpers.h | |||
@@ -28,7 +28,8 @@ | |||
28 | 28 | ||
29 | #include "mhd_byteorder.h" | 29 | #include "mhd_byteorder.h" |
30 | #include <stdint.h> | 30 | #include <stdint.h> |
31 | #if defined(_MSC_FULL_VER) && (!defined(__clang__) || (defined(__c2__) && defined(__OPTIMIZE__))) | 31 | #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ |
32 | defined(__OPTIMIZE__))) | ||
32 | /* Declarations for VC & Clang/C2 built-ins */ | 33 | /* Declarations for VC & Clang/C2 built-ins */ |
33 | #include <intrin.h> | 34 | #include <intrin.h> |
34 | #endif /* _MSC_FULL_VER */ | 35 | #endif /* _MSC_FULL_VER */ |
@@ -41,48 +42,50 @@ | |||
41 | 42 | ||
42 | #ifdef MHD_HAVE___BUILTIN_BSWAP32 | 43 | #ifdef MHD_HAVE___BUILTIN_BSWAP32 |
43 | #define _MHD_BYTES_SWAP32(value32) \ | 44 | #define _MHD_BYTES_SWAP32(value32) \ |
44 | ((uint32_t)__builtin_bswap32((uint32_t)value32)) | 45 | ((uint32_t) __builtin_bswap32 ((uint32_t) value32)) |
45 | #elif defined(_MSC_FULL_VER) && (!defined(__clang__) || (defined(__c2__) && defined(__OPTIMIZE__))) | 46 | #elif defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ |
47 | defined(__OPTIMIZE__))) | ||
46 | /* Clang/C2 may not inline this function if optimizations are turned off. */ | 48 | /* Clang/C2 may not inline this function if optimizations are turned off. */ |
47 | #ifndef __clang__ | 49 | #ifndef __clang__ |
48 | #pragma intrinsic(_byteswap_ulong) | 50 | #pragma intrinsic(_byteswap_ulong) |
49 | #endif /* ! __clang__ */ | 51 | #endif /* ! __clang__ */ |
50 | #define _MHD_BYTES_SWAP32(value32) \ | 52 | #define _MHD_BYTES_SWAP32(value32) \ |
51 | ((uint32_t)_byteswap_ulong((uint32_t)value32)) | 53 | ((uint32_t) _byteswap_ulong ((uint32_t) value32)) |
52 | #elif __has_builtin(__builtin_bswap32) | 54 | #elif __has_builtin (__builtin_bswap32) |
53 | #define _MHD_BYTES_SWAP32(value32) \ | 55 | #define _MHD_BYTES_SWAP32(value32) \ |
54 | ((uint32_t)__builtin_bswap32((uint32_t)value32)) | 56 | ((uint32_t) __builtin_bswap32 ((uint32_t) value32)) |
55 | #else /* ! __has_builtin(__builtin_bswap32) */ | 57 | #else /* ! __has_builtin(__builtin_bswap32) */ |
56 | #define _MHD_BYTES_SWAP32(value32) \ | 58 | #define _MHD_BYTES_SWAP32(value32) \ |
57 | ( (((uint32_t)(value32)) << 24) | \ | 59 | ( (((uint32_t) (value32)) << 24) \ |
58 | ((((uint32_t)(value32)) & ((uint32_t)0x0000FF00)) << 8) | \ | 60 | | ((((uint32_t) (value32)) & ((uint32_t) 0x0000FF00)) << 8) \ |
59 | ((((uint32_t)(value32)) & ((uint32_t)0x00FF0000)) >> 8) | \ | 61 | | ((((uint32_t) (value32)) & ((uint32_t) 0x00FF0000)) >> 8) \ |
60 | (((uint32_t)(value32)) >> 24) ) | 62 | | (((uint32_t) (value32)) >> 24) ) |
61 | #endif /* ! __has_builtin(__builtin_bswap32) */ | 63 | #endif /* ! __has_builtin(__builtin_bswap32) */ |
62 | 64 | ||
63 | #ifdef MHD_HAVE___BUILTIN_BSWAP64 | 65 | #ifdef MHD_HAVE___BUILTIN_BSWAP64 |
64 | #define _MHD_BYTES_SWAP64(value64) \ | 66 | #define _MHD_BYTES_SWAP64(value64) \ |
65 | ((uint64_t)__builtin_bswap64((uint64_t)value64)) | 67 | ((uint64_t) __builtin_bswap64 ((uint64_t) value64)) |
66 | #elif defined(_MSC_FULL_VER) && (!defined(__clang__) || (defined(__c2__) && defined(__OPTIMIZE__))) | 68 | #elif defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ |
69 | defined(__OPTIMIZE__))) | ||
67 | /* Clang/C2 may not inline this function if optimizations are turned off. */ | 70 | /* Clang/C2 may not inline this function if optimizations are turned off. */ |
68 | #ifndef __clang__ | 71 | #ifndef __clang__ |
69 | #pragma intrinsic(_byteswap_uint64) | 72 | #pragma intrinsic(_byteswap_uint64) |
70 | #endif /* ! __clang__ */ | 73 | #endif /* ! __clang__ */ |
71 | #define _MHD_BYTES_SWAP64(value64) \ | 74 | #define _MHD_BYTES_SWAP64(value64) \ |
72 | ((uint64_t)_byteswap_uint64((uint64_t)value64)) | 75 | ((uint64_t) _byteswap_uint64 ((uint64_t) value64)) |
73 | #elif __has_builtin(__builtin_bswap64) | 76 | #elif __has_builtin (__builtin_bswap64) |
74 | #define _MHD_BYTES_SWAP64(value64) \ | 77 | #define _MHD_BYTES_SWAP64(value64) \ |
75 | ((uint64_t)__builtin_bswap64((uint64_t)value64)) | 78 | ((uint64_t) __builtin_bswap64 ((uint64_t) value64)) |
76 | #else /* ! __has_builtin(__builtin_bswap64) */ | 79 | #else /* ! __has_builtin(__builtin_bswap64) */ |
77 | #define _MHD_BYTES_SWAP64(value64) \ | 80 | #define _MHD_BYTES_SWAP64(value64) \ |
78 | ( (((uint64_t)(value64)) << 56) | \ | 81 | ( (((uint64_t) (value64)) << 56) \ |
79 | ((((uint64_t)(value64)) & ((uint64_t)0x000000000000FF00)) << 40) | \ | 82 | | ((((uint64_t) (value64)) & ((uint64_t) 0x000000000000FF00)) << 40) \ |
80 | ((((uint64_t)(value64)) & ((uint64_t)0x0000000000FF0000)) << 24) | \ | 83 | | ((((uint64_t) (value64)) & ((uint64_t) 0x0000000000FF0000)) << 24) \ |
81 | ((((uint64_t)(value64)) & ((uint64_t)0x00000000FF000000)) << 8) | \ | 84 | | ((((uint64_t) (value64)) & ((uint64_t) 0x00000000FF000000)) << 8) \ |
82 | ((((uint64_t)(value64)) & ((uint64_t)0x000000FF00000000)) >> 8) | \ | 85 | | ((((uint64_t) (value64)) & ((uint64_t) 0x000000FF00000000)) >> 8) \ |
83 | ((((uint64_t)(value64)) & ((uint64_t)0x0000FF0000000000)) >> 24) | \ | 86 | | ((((uint64_t) (value64)) & ((uint64_t) 0x0000FF0000000000)) >> 24) \ |
84 | ((((uint64_t)(value64)) & ((uint64_t)0x00FF000000000000)) >> 40) | \ | 87 | | ((((uint64_t) (value64)) & ((uint64_t) 0x00FF000000000000)) >> 40) \ |
85 | (((uint64_t)(value64)) >> 56) ) | 88 | | (((uint64_t) (value64)) >> 56) ) |
86 | #endif /* ! __has_builtin(__builtin_bswap64) */ | 89 | #endif /* ! __has_builtin(__builtin_bswap64) */ |
87 | 90 | ||
88 | 91 | ||
@@ -92,22 +95,22 @@ | |||
92 | */ | 95 | */ |
93 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | 96 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN |
94 | #define _MHD_PUT_64BIT_LE(addr, value64) \ | 97 | #define _MHD_PUT_64BIT_LE(addr, value64) \ |
95 | ((*(uint64_t*)(addr)) = (uint64_t)(value64)) | 98 | ((*(uint64_t*) (addr)) = (uint64_t) (value64)) |
96 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | 99 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN |
97 | #define _MHD_PUT_64BIT_LE(addr, value64) \ | 100 | #define _MHD_PUT_64BIT_LE(addr, value64) \ |
98 | ((*(uint64_t*)(addr)) = _MHD_BYTES_SWAP64(value64)) | 101 | ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) |
99 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 102 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
100 | /* Endianess was not detected or non-standard like PDP-endian */ | 103 | /* Endianess was not detected or non-standard like PDP-endian */ |
101 | #define _MHD_PUT_64BIT_LE(addr, value64) do { \ | 104 | #define _MHD_PUT_64BIT_LE(addr, value64) do { \ |
102 | ((uint8_t*)(addr))[0] = (uint8_t)((uint64_t)(value64)); \ | 105 | ((uint8_t*) (addr))[0] = (uint8_t) ((uint64_t) (value64)); \ |
103 | ((uint8_t*)(addr))[1] = (uint8_t)(((uint64_t)(value64)) >> 8); \ | 106 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 8); \ |
104 | ((uint8_t*)(addr))[2] = (uint8_t)(((uint64_t)(value64)) >> 16); \ | 107 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 16); \ |
105 | ((uint8_t*)(addr))[3] = (uint8_t)(((uint64_t)(value64)) >> 24); \ | 108 | ((uint8_t*) (addr))[3] = (uint8_t) (((uint64_t) (value64)) >> 24); \ |
106 | ((uint8_t*)(addr))[4] = (uint8_t)(((uint64_t)(value64)) >> 32); \ | 109 | ((uint8_t*) (addr))[4] = (uint8_t) (((uint64_t) (value64)) >> 32); \ |
107 | ((uint8_t*)(addr))[5] = (uint8_t)(((uint64_t)(value64)) >> 40); \ | 110 | ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 40); \ |
108 | ((uint8_t*)(addr))[6] = (uint8_t)(((uint64_t)(value64)) >> 48); \ | 111 | ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 48); \ |
109 | ((uint8_t*)(addr))[7] = (uint8_t)(((uint64_t)(value64)) >> 56); \ | 112 | ((uint8_t*) (addr))[7] = (uint8_t) (((uint64_t) (value64)) >> 56); \ |
110 | } while (0) | 113 | } while (0) |
111 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 114 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
112 | 115 | ||
113 | /* _MHD_PUT_32BIT_LE (addr, value32) | 116 | /* _MHD_PUT_32BIT_LE (addr, value32) |
@@ -116,18 +119,18 @@ | |||
116 | */ | 119 | */ |
117 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | 120 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN |
118 | #define _MHD_PUT_32BIT_LE(addr,value32) \ | 121 | #define _MHD_PUT_32BIT_LE(addr,value32) \ |
119 | ((*(uint32_t*)(addr)) = (uint32_t)(value32)) | 122 | ((*(uint32_t*) (addr)) = (uint32_t) (value32)) |
120 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | 123 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN |
121 | #define _MHD_PUT_32BIT_LE(addr, value32) \ | 124 | #define _MHD_PUT_32BIT_LE(addr, value32) \ |
122 | ((*(uint32_t*)(addr)) = _MHD_BYTES_SWAP32(value32)) | 125 | ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) |
123 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 126 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
124 | /* Endianess was not detected or non-standard like PDP-endian */ | 127 | /* Endianess was not detected or non-standard like PDP-endian */ |
125 | #define _MHD_PUT_32BIT_LE(addr, value32) do { \ | 128 | #define _MHD_PUT_32BIT_LE(addr, value32) do { \ |
126 | ((uint8_t*)(addr))[0] = (uint8_t)((uint32_t)(value32)); \ | 129 | ((uint8_t*) (addr))[0] = (uint8_t) ((uint32_t) (value32)); \ |
127 | ((uint8_t*)(addr))[1] = (uint8_t)(((uint32_t)(value32)) >> 8); \ | 130 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 8); \ |
128 | ((uint8_t*)(addr))[2] = (uint8_t)(((uint32_t)(value32)) >> 16); \ | 131 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 16); \ |
129 | ((uint8_t*)(addr))[3] = (uint8_t)(((uint32_t)(value32)) >> 24); \ | 132 | ((uint8_t*) (addr))[3] = (uint8_t) (((uint32_t) (value32)) >> 24); \ |
130 | } while (0) | 133 | } while (0) |
131 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 134 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
132 | 135 | ||
133 | /* _MHD_GET_32BIT_LE (addr) | 136 | /* _MHD_GET_32BIT_LE (addr) |
@@ -136,17 +139,17 @@ | |||
136 | */ | 139 | */ |
137 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | 140 | #if _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN |
138 | #define _MHD_GET_32BIT_LE(addr) \ | 141 | #define _MHD_GET_32BIT_LE(addr) \ |
139 | (*(const uint32_t*)(addr)) | 142 | (*(const uint32_t*) (addr)) |
140 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | 143 | #elif _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN |
141 | #define _MHD_GET_32BIT_LE(addr) \ | 144 | #define _MHD_GET_32BIT_LE(addr) \ |
142 | _MHD_BYTES_SWAP32(*(const uint32_t*)(addr)) | 145 | _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) |
143 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 146 | #else /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
144 | /* Endianess was not detected or non-standard like PDP-endian */ | 147 | /* Endianess was not detected or non-standard like PDP-endian */ |
145 | #define _MHD_GET_32BIT_LE(addr) \ | 148 | #define _MHD_GET_32BIT_LE(addr) \ |
146 | ( ( (uint32_t)(((const uint8_t*)addr)[0])) | \ | 149 | ( ( (uint32_t) (((const uint8_t*) addr)[0])) \ |
147 | (((uint32_t)(((const uint8_t*)addr)[1])) << 8) | \ | 150 | | (((uint32_t) (((const uint8_t*) addr)[1])) << 8) \ |
148 | (((uint32_t)(((const uint8_t*)addr)[2])) << 16) | \ | 151 | | (((uint32_t) (((const uint8_t*) addr)[2])) << 16) \ |
149 | (((uint32_t)(((const uint8_t*)addr)[3])) << 24) ) | 152 | | (((uint32_t) (((const uint8_t*) addr)[3])) << 24) ) |
150 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ | 153 | #endif /* _MHD_BYTE_ORDER != _MHD_BIG_ENDIAN */ |
151 | 154 | ||
152 | 155 | ||
@@ -156,22 +159,22 @@ | |||
156 | */ | 159 | */ |
157 | #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | 160 | #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN |
158 | #define _MHD_PUT_64BIT_BE(addr, value64) \ | 161 | #define _MHD_PUT_64BIT_BE(addr, value64) \ |
159 | ((*(uint64_t*)(addr)) = (uint64_t)(value64)) | 162 | ((*(uint64_t*) (addr)) = (uint64_t) (value64)) |
160 | #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | 163 | #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN |
161 | #define _MHD_PUT_64BIT_BE(addr, value64) \ | 164 | #define _MHD_PUT_64BIT_BE(addr, value64) \ |
162 | ((*(uint64_t*)(addr)) = _MHD_BYTES_SWAP64(value64)) | 165 | ((*(uint64_t*) (addr)) = _MHD_BYTES_SWAP64 (value64)) |
163 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 166 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
164 | /* Endianess was not detected or non-standard like PDP-endian */ | 167 | /* Endianess was not detected or non-standard like PDP-endian */ |
165 | #define _MHD_PUT_64BIT_BE(addr, value64) do { \ | 168 | #define _MHD_PUT_64BIT_BE(addr, value64) do { \ |
166 | ((uint8_t*)(addr))[7] = (uint8_t)((uint64_t)(value64)); \ | 169 | ((uint8_t*) (addr))[7] = (uint8_t) ((uint64_t) (value64)); \ |
167 | ((uint8_t*)(addr))[6] = (uint8_t)(((uint64_t)(value64)) >> 8); \ | 170 | ((uint8_t*) (addr))[6] = (uint8_t) (((uint64_t) (value64)) >> 8); \ |
168 | ((uint8_t*)(addr))[5] = (uint8_t)(((uint64_t)(value64)) >> 16); \ | 171 | ((uint8_t*) (addr))[5] = (uint8_t) (((uint64_t) (value64)) >> 16); \ |
169 | ((uint8_t*)(addr))[4] = (uint8_t)(((uint64_t)(value64)) >> 24); \ | 172 | ((uint8_t*) (addr))[4] = (uint8_t) (((uint64_t) (value64)) >> 24); \ |
170 | ((uint8_t*)(addr))[3] = (uint8_t)(((uint64_t)(value64)) >> 32); \ | 173 | ((uint8_t*) (addr))[3] = (uint8_t) (((uint64_t) (value64)) >> 32); \ |
171 | ((uint8_t*)(addr))[2] = (uint8_t)(((uint64_t)(value64)) >> 40); \ | 174 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint64_t) (value64)) >> 40); \ |
172 | ((uint8_t*)(addr))[1] = (uint8_t)(((uint64_t)(value64)) >> 48); \ | 175 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint64_t) (value64)) >> 48); \ |
173 | ((uint8_t*)(addr))[0] = (uint8_t)(((uint64_t)(value64)) >> 56); \ | 176 | ((uint8_t*) (addr))[0] = (uint8_t) (((uint64_t) (value64)) >> 56); \ |
174 | } while (0) | 177 | } while (0) |
175 | #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 178 | #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
176 | 179 | ||
177 | /* _MHD_PUT_32BIT_BE (addr, value32) | 180 | /* _MHD_PUT_32BIT_BE (addr, value32) |
@@ -180,18 +183,18 @@ | |||
180 | */ | 183 | */ |
181 | #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | 184 | #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN |
182 | #define _MHD_PUT_32BIT_BE(addr, value32) \ | 185 | #define _MHD_PUT_32BIT_BE(addr, value32) \ |
183 | ((*(uint32_t*)(addr)) = (uint32_t)(value32)) | 186 | ((*(uint32_t*) (addr)) = (uint32_t) (value32)) |
184 | #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | 187 | #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN |
185 | #define _MHD_PUT_32BIT_BE(addr, value32) \ | 188 | #define _MHD_PUT_32BIT_BE(addr, value32) \ |
186 | ((*(uint32_t*)(addr)) = _MHD_BYTES_SWAP32(value32)) | 189 | ((*(uint32_t*) (addr)) = _MHD_BYTES_SWAP32 (value32)) |
187 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 190 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
188 | /* Endianess was not detected or non-standard like PDP-endian */ | 191 | /* Endianess was not detected or non-standard like PDP-endian */ |
189 | #define _MHD_PUT_32BIT_BE(addr, value32) do { \ | 192 | #define _MHD_PUT_32BIT_BE(addr, value32) do { \ |
190 | ((uint8_t*)(addr))[3] = (uint8_t)((uint32_t)(value32)); \ | 193 | ((uint8_t*) (addr))[3] = (uint8_t) ((uint32_t) (value32)); \ |
191 | ((uint8_t*)(addr))[2] = (uint8_t)(((uint32_t)(value32)) >> 8); \ | 194 | ((uint8_t*) (addr))[2] = (uint8_t) (((uint32_t) (value32)) >> 8); \ |
192 | ((uint8_t*)(addr))[1] = (uint8_t)(((uint32_t)(value32)) >> 16); \ | 195 | ((uint8_t*) (addr))[1] = (uint8_t) (((uint32_t) (value32)) >> 16); \ |
193 | ((uint8_t*)(addr))[0] = (uint8_t)(((uint32_t)(value32)) >> 24); \ | 196 | ((uint8_t*) (addr))[0] = (uint8_t) (((uint32_t) (value32)) >> 24); \ |
194 | } while (0) | 197 | } while (0) |
195 | #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 198 | #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
196 | 199 | ||
197 | /* _MHD_GET_32BIT_BE (addr) | 200 | /* _MHD_GET_32BIT_BE (addr) |
@@ -200,17 +203,17 @@ | |||
200 | */ | 203 | */ |
201 | #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN | 204 | #if _MHD_BYTE_ORDER == _MHD_BIG_ENDIAN |
202 | #define _MHD_GET_32BIT_BE(addr) \ | 205 | #define _MHD_GET_32BIT_BE(addr) \ |
203 | (*(const uint32_t*)(addr)) | 206 | (*(const uint32_t*) (addr)) |
204 | #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN | 207 | #elif _MHD_BYTE_ORDER == _MHD_LITTLE_ENDIAN |
205 | #define _MHD_GET_32BIT_BE(addr) \ | 208 | #define _MHD_GET_32BIT_BE(addr) \ |
206 | _MHD_BYTES_SWAP32(*(const uint32_t*)(addr)) | 209 | _MHD_BYTES_SWAP32 (*(const uint32_t*) (addr)) |
207 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 210 | #else /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
208 | /* Endianess was not detected or non-standard like PDP-endian */ | 211 | /* Endianess was not detected or non-standard like PDP-endian */ |
209 | #define _MHD_GET_32BIT_BE(addr) \ | 212 | #define _MHD_GET_32BIT_BE(addr) \ |
210 | ( (((uint32_t)(((const uint8_t*)addr)[0])) << 24) | \ | 213 | ( (((uint32_t) (((const uint8_t*) addr)[0])) << 24) \ |
211 | (((uint32_t)(((const uint8_t*)addr)[1])) << 16) | \ | 214 | | (((uint32_t) (((const uint8_t*) addr)[1])) << 16) \ |
212 | (((uint32_t)(((const uint8_t*)addr)[2])) << 8) | \ | 215 | | (((uint32_t) (((const uint8_t*) addr)[2])) << 8) \ |
213 | ((uint32_t) (((const uint8_t*)addr)[3])) ) | 216 | | ((uint32_t) (((const uint8_t*) addr)[3])) ) |
214 | #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ | 217 | #endif /* _MHD_BYTE_ORDER != _MHD_LITTLE_ENDIAN */ |
215 | 218 | ||
216 | 219 | ||
@@ -218,17 +221,18 @@ | |||
218 | * Rotate right 32-bit value by number of bits. | 221 | * Rotate right 32-bit value by number of bits. |
219 | * bits parameter must be more than zero and must be less than 32. | 222 | * bits parameter must be more than zero and must be less than 32. |
220 | */ | 223 | */ |
221 | #if defined(_MSC_FULL_VER) && (!defined(__clang__) || (defined(__c2__) && defined(__OPTIMIZE__))) | 224 | #if defined(_MSC_FULL_VER) && (! defined(__clang__) || (defined(__c2__) && \ |
225 | defined(__OPTIMIZE__))) | ||
222 | /* Clang/C2 do not inline this function if optimizations are turned off. */ | 226 | /* Clang/C2 do not inline this function if optimizations are turned off. */ |
223 | #ifndef __clang__ | 227 | #ifndef __clang__ |
224 | #pragma intrinsic(_rotr) | 228 | #pragma intrinsic(_rotr) |
225 | #endif /* ! __clang__ */ | 229 | #endif /* ! __clang__ */ |
226 | #define _MHD_ROTR32(value32, bits) \ | 230 | #define _MHD_ROTR32(value32, bits) \ |
227 | ((uint32_t)_rotr((uint32_t)(value32),(bits))) | 231 | ((uint32_t) _rotr ((uint32_t) (value32),(bits))) |
228 | #else /* ! _MSC_FULL_VER */ | 232 | #else /* ! _MSC_FULL_VER */ |
229 | /* Defined in form which modern compiler could optimize. */ | 233 | /* Defined in form which modern compiler could optimize. */ |
230 | #define _MHD_ROTR32(value32, bits) \ | 234 | #define _MHD_ROTR32(value32, bits) \ |
231 | (((uint32_t)(value32)) >> (bits) | ((uint32_t)(value32)) << (32 - bits)) | 235 | (((uint32_t) (value32)) >> (bits) | ((uint32_t) (value32)) << (32 - bits)) |
232 | #endif /* ! _MSC_FULL_VER */ | 236 | #endif /* ! _MSC_FULL_VER */ |
233 | 237 | ||
234 | 238 | ||