Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h22
-rw-r--r--include/platform.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 37732e14e..03f9c35f3 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -192,6 +192,28 @@ int klogctl(int type, char *b, int len);
# define BUFSIZ 4096
#endif
+#if __GNUC_PREREQ(5,0)
+/* Since musl is apparently unable to get it right and would use
+ * a function call to a single-instruction function of "bswap %eax",
+ * reroute to gcc builtins:
+ */
+# undef bswap_16
+# undef bswap_32
+# undef bswap_64
+# define bswap_16(x) __builtin_bswap16(x)
+# define bswap_32(x) __builtin_bswap32(x)
+# define bswap_64(x) __builtin_bswap64(x)
+# if BB_LITTLE_ENDIAN
+# undef ntohs
+# undef htons
+# undef ntohl
+# undef htonl
+# define ntohs(x) __builtin_bswap16(x)
+# define htons(x) __builtin_bswap16(x)
+# define ntohl(x) __builtin_bswap32(x)
+# define htonl(x) __builtin_bswap32(x)
+# endif
+#endif
/* Busybox does not use threads, we can speed up stdio. */
#ifdef HAVE_UNLOCKED_STDIO
diff --git a/include/platform.h b/include/platform.h
index 387b6f537..4633b2507 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -195,6 +195,7 @@
#endif
#if ULONG_MAX > 0xffffffff
+/* inline 64-bit bswap only on 64-bit arches */
# define bb_bswap_64(x) bswap_64(x)
#endif