From 9ff50b869780aba131dc9b542ccd0f1a3959e920 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 18 Oct 2010 11:40:26 +0200 Subject: *: deinline SWAP_xE64 on 32-bit CPUs. Wins !90 bytes both on 32 and 64 bits Signed-off-by: Denys Vlasenko --- include/libbb.h | 7 +++++-- include/platform.h | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index b16157d..c161ed7 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -37,8 +37,6 @@ #include #include #include -/* Try to pull in PATH_MAX */ -#include #include #ifdef HAVE_MNTENT_H # include @@ -254,6 +252,11 @@ extern int *const bb_errno; #define errno (*bb_errno) #endif +#if !(ULONG_MAX > 0xffffffff) +/* Only 32-bit CPUs need this, 64-bit ones use inlined version */ +uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; +#endif + unsigned long long monotonic_ns(void) FAST_FUNC; unsigned long long monotonic_us(void) FAST_FUNC; unsigned long long monotonic_ms(void) FAST_FUNC; diff --git a/include/platform.h b/include/platform.h index c255a17..b5c6685 100644 --- a/include/platform.h +++ b/include/platform.h @@ -150,6 +150,7 @@ /* ---- Endian Detection ------------------------------------ */ +#include #if defined(__digital__) && defined(__unix__) # include #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ @@ -189,6 +190,10 @@ # error "Can't determine endianness" #endif +#if ULONG_MAX > 0xffffffff +# define bb_bswap_64(x) bswap_64(x) +#endif + /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */ #if BB_BIG_ENDIAN # define SWAP_BE16(x) (x) @@ -196,13 +201,13 @@ # define SWAP_BE64(x) (x) # define SWAP_LE16(x) bswap_16(x) # define SWAP_LE32(x) bswap_32(x) -# define SWAP_LE64(x) bswap_64(x) +# define SWAP_LE64(x) bb_bswap_64(x) # define IF_BIG_ENDIAN(...) __VA_ARGS__ # define IF_LITTLE_ENDIAN(...) #else # define SWAP_BE16(x) bswap_16(x) # define SWAP_BE32(x) bswap_32(x) -# define SWAP_BE64(x) bswap_64(x) +# define SWAP_BE64(x) bb_bswap_64(x) # define SWAP_LE16(x) (x) # define SWAP_LE32(x) (x) # define SWAP_LE64(x) (x) -- cgit v1.1