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 diff --git a/networking/ntpd.c b/networking/ntpd.c index 8cf8830c2..6bf6c4e07 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -577,7 +577,7 @@ sfp_to_d(s_fixedpt_t sfp) return ret; } #if ENABLE_FEATURE_NTPD_SERVER -static void +static NOINLINE void d_to_lfp(l_fixedpt_t *lfp, double d) { uint32_t intl;