@@ -646,7 +646,9 @@ struct winsize {
646646# endif /* WORDS_BIGENDIAN */
647647#endif /* BYTE_ORDER */
648648
649- #ifndef HAVE_ENDIAN_H
649+ #if (defined(HAVE_DECL_LE32TOH ) && HAVE_DECL_LE32TOH == 0 ) || \
650+ (defined(HAVE_DECL_LE64TOH ) && HAVE_DECL_LE64TOH == 0 ) || \
651+ (defined(HAVE_DECL_HTOLE64 ) && HAVE_DECL_HTOLE64 == 0 )
650652# define openssh_swap32 (v ) \
651653 (uint32_t)(((uint32_t)(v) & 0xff) << 24 | \
652654 ((uint32_t)(v) & 0xff00) << 8 | \
@@ -662,13 +664,25 @@ struct winsize {
662664 ((uint64_t)(v) & 0xff000000000000ULL) >> 40 | \
663665 ((uint64_t)(v) & 0xff00000000000000ULL) >> 56)
664666# ifdef WORDS_BIGENDIAN
665- # define le32toh (v ) (openssh_swap32(v))
666- # define le64toh (v ) (openssh_swap64(v))
667- # define htole64 (v ) (openssh_swap64(v))
667+ # if defined(HAVE_DECL_LE32TOH ) && HAVE_DECL_LE32TOH == 0
668+ # define le32toh (v ) (openssh_swap32(v))
669+ # endif
670+ # if defined(HAVE_DECL_LE64TOH ) && HAVE_DECL_LE64TOH == 0
671+ # define le64toh (v ) (openssh_swap64(v))
672+ # endif
673+ # if defined(HAVE_DECL_HTOLE64 ) && HAVE_DECL_HTOLE64 == 0
674+ # define htole64 (v ) (openssh_swap64(v))
675+ # endif
668676# else
669- # define le32toh (v ) ((uint32_t)v)
670- # define le64toh (v ) ((uint64_t)v)
671- # define htole64 (v ) ((uint64_t)v)
677+ # if defined(HAVE_DECL_LE32TOH ) && HAVE_DECL_LE32TOH == 0
678+ # define le32toh (v ) ((uint32_t)v)
679+ # endif
680+ # if defined(HAVE_DECL_LE64TOH ) && HAVE_DECL_LE64TOH == 0
681+ # define le64toh (v ) ((uint64_t)v)
682+ # endif
683+ # if defined(HAVE_DECL_HTOLE64 ) && HAVE_DECL_HTOLE64 == 0
684+ # define htole64 (v ) ((uint64_t)v)
685+ # endif
672686# endif
673687#endif
674688
0 commit comments