Skip to content

Commit 53f3689

Browse files
Roytakmichalvasko
authored andcommitted
compat UPDATE find byteswap correctly
1 parent bdc0f22 commit 53f3689

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ endif()
341341
# link compat
342342
use_compat()
343343

344+
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
345+
add_compile_definitions(__EXTENSIONS__)
346+
endif()
347+
344348
# create static libyang library
345349
if(NOT BUILD_SHARED_LIBS)
346350
add_definitions(-DSTATIC)

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)