From 0b05a4e71e181fa47c319546fc9ad9fb1b3f6f24 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 6 Aug 2025 14:42:06 +0200 Subject: top,pmap: speed up /smaps parsing function old new delta procps_read_smaps 515 529 +14 procps_get_maps 685 665 -20 .rodata 105847 105820 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 14/-47) Total: -33 bytes Signed-off-by: Denys Vlasenko --- include/platform.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/platform.h b/include/platform.h index e10c5b558..a5b61757f 100644 --- a/include/platform.h +++ b/include/platform.h @@ -209,6 +209,8 @@ # define SWAP_LE64(x) bb_bswap_64(x) # define IF_BIG_ENDIAN(...) __VA_ARGS__ # define IF_LITTLE_ENDIAN(...) +/* How do bytes a,b,c,d (sequential in memory) look if fetched into uint32_t? */ +# define PACK32_BYTES(a,b,c,d) (uint32_t)((d)+((c)<<8)+((b)<<16)+((a)<<24)) #else # define SWAP_BE16(x) bswap_16(x) # define SWAP_BE32(x) bswap_32(x) @@ -218,6 +220,7 @@ # define SWAP_LE64(x) (x) # define IF_BIG_ENDIAN(...) # define IF_LITTLE_ENDIAN(...) __VA_ARGS__ +# define PACK32_BYTES(a,b,c,d) (uint32_t)((a)+((b)<<8)+((c)<<16)+((d)<<24)) #endif -- cgit v1.2.3-55-g6feb