Skip to content

Commit ff77ddc

Browse files
ribbonsmkj
authored andcommitted
Fix build when htole64 macro is in (sys/)endian.h
Currently, if htole64 is available on a platform as a macro in endian.h or sys/endian.h the AC_CHECK_DECL check does not detect them as these files are not included in the test. As those two headers are however included in the build this causes the declarations of the compat functions to be mangled by the undetected macros and fail to compile. Resolve this by passing conditional includes of endian.h and sys/endian.h to the includes parameter of the AC_CHECK_DECL macro so that the htole64 macro is detected correctly.
1 parent e2f854c commit ff77ddc

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

configure

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7620,7 +7620,15 @@ then :
76207620

76217621
fi
76227622

7623-
ac_fn_check_decl "$LINENO" "htole64" "ac_cv_have_decl_htole64" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS"
7623+
ac_fn_check_decl "$LINENO" "htole64" "ac_cv_have_decl_htole64" "
7624+
#ifdef HAVE_ENDIAN_H
7625+
#include <endian.h>
7626+
#endif
7627+
#ifdef HAVE_SYS_ENDIAN_H
7628+
#include <sys/endian.h>
7629+
#endif
7630+
7631+
" "$ac_c_undeclared_builtin_options" "CFLAGS"
76247632
if test "x$ac_cv_have_decl_htole64" = xyes
76257633
then :
76267634

configure.ac

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,14 @@ AC_CHECK_FUNCS(htole64)
553553
AC_CHECK_DECL(htole64,
554554
[
555555
AC_DEFINE(HAVE_DECL_HTOLE64,1,htole64 is a macro)
556-
],,)
556+
],,[
557+
#ifdef HAVE_ENDIAN_H
558+
#include <endian.h>
559+
#endif
560+
#ifdef HAVE_SYS_ENDIAN_H
561+
#include <sys/endian.h>
562+
#endif
563+
])
557564

558565
# POSIX monotonic time
559566
AC_CHECK_FUNCS(clock_gettime)

0 commit comments

Comments
 (0)