Skip to content

Commit

Permalink
Use faster byte swapping when compiling with MSVC
Browse files Browse the repository at this point in the history
When compiling with MSVC on x86-compatible, use an intrinsic for byte swapping.
In contrast to the GCC path, we do not prefer inline assembly here as it is not
supported for the x64 platform.

Signed-off-by: Sebastian Schuberth <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
sschuberth authored and gitster committed Oct 30, 2009
1 parent cd0f8e6 commit 0fcabde
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions compat/bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ static inline uint32_t default_swab32(uint32_t val)
} \
__res; })

#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))

#include <stdlib.h>

#define bswap32(x) _byteswap_ulong(x)

#endif

#ifdef bswap32

#undef ntohl
#undef htonl
#define ntohl(x) bswap32(x)
Expand Down

0 comments on commit 0fcabde

Please sign in to comment.