1
0
mirror of https://github.com/fumiama/base16384.git synced 2026-06-10 13:40:26 +08:00

fix on windows

This commit is contained in:
fumiama
2021-12-12 00:49:12 +08:00
parent eeea555ad9
commit 9589f8d578
4 changed files with 58 additions and 7 deletions

View File

@@ -18,6 +18,22 @@
# define htobe16(x) ntohs(x)
# define htobe32(x) htonl(x)
# define htobe64(x) htonll(x)
#elif defined(__WIN64__)
#ifdef WORDS_BIGENDIAN
# define be16toh(x) (x)
# define be32toh(x) (x)
# define be64toh(x) (x)
# define htobe16(x) (x)
# define htobe32(x) (x)
# define htobe64(x) (x)
#else
# define be16toh(x) __builtin_bswap16(x)
# define be32toh(x) __builtin_bswap32(x)
# define be64toh(x) __builtin_bswap64(x)
# define htobe16(x) __builtin_bswap16(x)
# define htobe32(x) __builtin_bswap32(x)
# define htobe64(x) __builtin_bswap64(x)
#endif
#endif
#include "base14.h"
@@ -86,7 +102,7 @@ LENDAT* encode(const uint8_t* data, const int64_t len) {
}
}
sum += 0x004e004e004e004e;
#if BYTE_ORDER == BIG_ENDIAN
#ifdef WORDS_BIGENDIAN
vals[n] = __builtin_bswap64(sum);
#else
vals[n] = sum;
@@ -141,7 +157,7 @@ LENDAT* decode(const uint8_t* data, const int64_t len) {
}
if(offset--) {
//这里有读取越界
#if BYTE_ORDER == BIG_ENDIAN
#ifdef WORDS_BIGENDIAN
register uint64_t sum = __builtin_bswap64(vals[n]) - 0x000000000000004e;
#else
register uint64_t sum = vals[n] - 0x000000000000004e;