Skip to content

Commit 1baeb2c

Browse files
committed
adds the implementation of Swap32 for MSVC
1 parent 3c1e2c2 commit 1baeb2c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/common.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,15 @@ static constexpr uint32_t kUnicodeError = 0xFFFD;
6262

6363
namespace sentencepiece {
6464
namespace util {
65-
#ifndef OS_WIN
66-
inline uint32_t Swap32(uint32_t x) { return __builtin_bswap32(x); }
65+
66+
inline uint32_t Swap32(uint32_t x) {
67+
#ifdef OS_WIN
68+
return _byteswap_ulong(x);
69+
#else // OS_WIN
70+
return __builtin_bswap32(x);
6771
#endif // OS_WIN
72+
}
73+
6874
} // namespace util
6975

7076
constexpr bool is_bigendian() {

0 commit comments

Comments
 (0)