[openssh-commits] [openssh] branch master updated: htole64() etc for systems without endian.h
git+noreply at mindrot.org
git+noreply at mindrot.org
Sun Oct 27 13:28:38 AEDT 2024
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
The following commit(s) were added to refs/heads/master by this push:
new ef7c26cd htole64() etc for systems without endian.h
ef7c26cd is described below
commit ef7c26cd2f0f9a8222f851d1e551f6dfd3113f8b
Author: Damien Miller <djm at mindrot.org>
AuthorDate: Sun Oct 27 13:28:11 2024 +1100
htole64() etc for systems without endian.h
---
configure.ac | 1 -
defines.h | 26 ++++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 97e4ee57..4e0539fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2008,7 +2008,6 @@ AC_CHECK_FUNCS([ \
strtoll \
strtoul \
strtoull \
- swap32 \
sysconf \
tcgetpgrp \
timegm \
diff --git a/defines.h b/defines.h
index ed860e78..b02f2942 100644
--- a/defines.h
+++ b/defines.h
@@ -646,6 +646,32 @@ struct winsize {
# endif /* WORDS_BIGENDIAN */
#endif /* BYTE_ORDER */
+#ifndef HAVE_ENDIAN_H
+# define openssh_swap32(v) \
+ (uint32_t)(((uint32_t)(v) & 0xff) << 24 | \
+ ((uint32_t)(v) & 0xff00) << 8 | \
+ ((uint32_t)(v) & 0xff0000) >> 8 | \
+ ((uint32_t)(v) & 0xff000000) >> 24)
+# define openssh_swap64(v) \
+ (__uint64_t)((((__uint64_t)(v) & 0xff) << 56) | \
+ ((__uint64_t)(v) & 0xff00ULL) << 40 | \
+ ((__uint64_t)(v) & 0xff0000ULL) << 24 | \
+ ((__uint64_t)(v) & 0xff000000ULL) << 8 | \
+ ((__uint64_t)(v) & 0xff00000000ULL) >> 8 | \
+ ((__uint64_t)(v) & 0xff0000000000ULL) >> 24 | \
+ ((__uint64_t)(v) & 0xff000000000000ULL) >> 40 | \
+ ((__uint64_t)(v) & 0xff00000000000000ULL) >> 56)
+# ifdef WORDS_BIGENDIAN
+# define le32toh(v) (openssh_swap32(v))
+# define le64toh(v) (openssh_swap64(v))
+# define htole64(v) (openssh_swap64(v))
+# else
+# define le32toh(v) ((uint32_t)v)
+# define le64toh(v) ((uint64_t)v)
+# define htole64(v) ((uint64_t)v)
+# endif
+#endif
+
/* Function replacement / compatibility hacks */
#if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO))
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list