diff options
-rw-r--r-- | src/include/gnunet_common.h | 24 | ||||
-rw-r--r-- | src/include/platform.h | 18 |
2 files changed, 30 insertions, 12 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 4dab71f7f..7477ca4c8 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -143,36 +143,36 @@ enum GNUNET_GenericReturnValue | |||
143 | */ | 143 | */ |
144 | 144 | ||
145 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 145 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
146 | #define GNUNET_htobe16(x) __bswap_16 (x) | 146 | #define GNUNET_htobe16(x) BYTE_SWAP_16 (x) |
147 | #define GNUNET_htole16(x) (x) | 147 | #define GNUNET_htole16(x) (x) |
148 | #define GNUNET_be16toh(x) __bswap_16 (x) | 148 | #define GNUNET_be16toh(x) BYTE_SWAP_16 (x) |
149 | #define GNUNET_le16toh(x) (x) | 149 | #define GNUNET_le16toh(x) (x) |
150 | 150 | ||
151 | #define GNUNET_htobe32(x) __bswap_32 (x) | 151 | #define GNUNET_htobe32(x) BYTE_SWAP_32 (x) |
152 | #define GNUNET_htole32(x) (x) | 152 | #define GNUNET_htole32(x) (x) |
153 | #define GNUNET_be32toh(x) __bswap_32 (x) | 153 | #define GNUNET_be32toh(x) BYTE_SWAP_32 (x) |
154 | #define GNUNET_le32toh(x) (x) | 154 | #define GNUNET_le32toh(x) (x) |
155 | 155 | ||
156 | #define GNUNET_htobe64(x) __bswap_64 (x) | 156 | #define GNUNET_htobe64(x) BYTE_SWAP_64 (x) |
157 | #define GNUNET_htole64(x) (x) | 157 | #define GNUNET_htole64(x) (x) |
158 | #define GNUNET_be64toh(x) __bswap_64 (x) | 158 | #define GNUNET_be64toh(x) BYTE_SWAP_64 (x) |
159 | #define GNUNET_le64toh(x) (x) | 159 | #define GNUNET_le64toh(x) (x) |
160 | #endif | 160 | #endif |
161 | #if __BYTE_ORDER == __BIG_ENDIAN | 161 | #if __BYTE_ORDER == __BIG_ENDIAN |
162 | #define GNUNET_htobe16(x) (x) | 162 | #define GNUNET_htobe16(x) (x) |
163 | #define GNUNET_htole16(x) __bswap_16 (x) | 163 | #define GNUNET_htole16(x) BYTE_SWAP_16 (x) |
164 | #define GNUNET_be16toh(x) (x) | 164 | #define GNUNET_be16toh(x) (x) |
165 | #define GNUNET_le16toh(x) __bswap_16 (x) | 165 | #define GNUNET_le16toh(x) BYTE_SWAP_16 (x) |
166 | 166 | ||
167 | #define GNUNET_htobe32(x) (x) | 167 | #define GNUNET_htobe32(x) (x) |
168 | #define GNUNET_htole32(x) __bswap_32 (x) | 168 | #define GNUNET_htole32(x) BYTE_SWAP_32 (x) |
169 | #define GNUNET_be32toh(x) (x) | 169 | #define GNUNET_be32toh(x) (x) |
170 | #define GNUNET_le32toh(x) __bswap_32 (x) | 170 | #define GNUNET_le32toh(x) BYTE_SWAP_32 (x) |
171 | 171 | ||
172 | #define GNUNET_htobe64(x) (x) | 172 | #define GNUNET_htobe64(x) (x) |
173 | #define GNUNET_htole64(x) __bswap_64 (x) | 173 | #define GNUNET_htole64(x) BYTE_SWAP_64 (x) |
174 | #define GNUNET_be64toh(x) (x) | 174 | #define GNUNET_be64toh(x) (x) |
175 | #define GNUNET_le64toh(x) __bswap_64 (x) | 175 | #define GNUNET_le64toh(x) BYTE_SWAP_64 (x) |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | 178 | ||
diff --git a/src/include/platform.h b/src/include/platform.h index 32bb637f1..da70893a7 100644 --- a/src/include/platform.h +++ b/src/include/platform.h | |||
@@ -199,6 +199,24 @@ | |||
199 | #undef HAVE_MREMAP | 199 | #undef HAVE_MREMAP |
200 | #endif | 200 | #endif |
201 | 201 | ||
202 | #if defined(__linux__) | ||
203 | #define BYTE_SWAP_16(x) __bswap_16 (x) | ||
204 | #define BYTE_SWAP_32(x) __bswap_32 (x) | ||
205 | #define BYTE_SWAP_64(x) __bswap_64 (x) | ||
206 | #else | ||
207 | #define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8)) | ||
208 | |||
209 | #define BYTE_SWAP_32(x) \ | ||
210 | ((((x) & 0x000000ffU) << 24) | (((x) & 0x0000ff00U) << 8) \ | ||
211 | | (((x) & 0x00ff0000U) >> 8) | (((x) & 0xff000000U) >> 24)) | ||
212 | |||
213 | #define BYTE_SWAP_64(x) \ | ||
214 | ((((x) & 0x00000000000000ffUL) << 56) | (((x) & 0x000000000000ff00UL) << 40) \ | ||
215 | | (((x) & 0x0000000000ff0000UL) << 24) | (((x) & 0x00000000ff000000UL) << 8) \ | ||
216 | | (((x) & 0x000000ff00000000UL) >> 8) | (((x) & 0x0000ff0000000000UL) >> 24) \ | ||
217 | | (((x) & 0x00ff000000000000UL) >> 40) | (((x) & 0xff00000000000000UL) >> \ | ||
218 | 56)) | ||
219 | #endif | ||
202 | 220 | ||
203 | #if ! HAVE_ATOLL | 221 | #if ! HAVE_ATOLL |
204 | long long | 222 | long long |