Skip to content

Commit

Permalink
define endian functions on win32 (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Feb 1, 2025
1 parent be99fec commit 018d952
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib/fcitx-utils/endian_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)

#elif defined(_WIN32)
#include <cstdlib>

#define htobe16(x) _byteswap_ushort(x)
#define htole16(x) (x)
#define be16toh(x) _byteswap_ushort(x)
#define le16toh(x) (x)

#define htobe32(x) _byteswap_ulong(x)
#define htole32(x) (x)
#define be32toh(x) _byteswap_ulong(x)
#define le32toh(x) (x)

#define htobe64(x) _byteswap_uint64(x)
#define htole64(x) (x)
#define be64toh(x) _byteswap_uint64(x)
#define le64toh(x) (x)
#else
#include <sys/endian.h> // IWYU pragma: export
#endif
Expand Down

0 comments on commit 018d952

Please sign in to comment.