Skip to content

Commit 6ad6b07

Browse files
committed
compat UPDATE find byteswap correctly
1 parent 6f2910f commit 6ad6b07

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CMakeModules/UseCompat.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ macro(USE_COMPAT)
6161

6262
check_include_file("alloca.h" HAVE_ALLOCA_H)
6363

64+
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
65+
6466
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
6567
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
6668
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1)

compat/compat.h.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
# include <alloca.h>
2727
#endif
2828

29-
#if defined (__APPLE__) || defined (_WIN32)
29+
#cmakedefine HAVE_BYTESWAP_H
30+
#ifdef HAVE_BYTESWAP_H
31+
# include <byteswap.h>
32+
#else
3033
# define bswap_32 __builtin_bswap32
3134
# define bswap64 __builtin_bswap64
32-
#else
33-
# include <byteswap.h>
3435
#endif
3536

3637
#include <limits.h>

0 commit comments

Comments
 (0)