Skip to content

Commit d40aa59

Browse files
sebastianasgitster
authored andcommitted
bswap.h: define GIT_LITTLE_ENDIAN on MSVC as little endian
The Microsoft Visual C++ (MSVC) compiler (as of Visual Studio 2022 version 17.13.6) does not define __BYTE_ORDER__ and its C-library does not define __BYTE_ORDER. The compiler is supported only ao arm64 and x86 which are all little endian. Define GIT_BYTE_ORDER on msvc as little endian to avoid further checks. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 228273b commit d40aa59

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compat/bswap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ static inline uint64_t git_bswap64(uint64_t x)
8181
#define bswap32(x) _byteswap_ulong(x)
8282
#define bswap64(x) _byteswap_uint64(x)
8383

84+
#define GIT_LITTLE_ENDIAN 1234
85+
#define GIT_BIG_ENDIAN 4321
86+
#define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
87+
8488
#endif
8589

8690
#if defined(bswap32)
@@ -122,7 +126,7 @@ static inline uint64_t git_bswap64(uint64_t x)
122126
# define GIT_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
123127
# define GIT_BIG_ENDIAN __ORDER_BIG_ENDIAN__
124128

125-
#else
129+
#elif !defined(GIT_BYTE_ORDER)
126130

127131
# define GIT_BIG_ENDIAN 4321
128132
# define GIT_LITTLE_ENDIAN 1234

0 commit comments

Comments
 (0)