From 43982ed49962526f7f042bcd9c5eb05ab4e586de Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 24 Jan 2026 05:21:10 +0100 Subject: httpd: code shrink via "split-globals" trick function old new delta httpd_main 957 968 +11 log_and_exit 25 26 +1 send_headers 712 708 -4 handle_incoming_and_exit 2292 2285 -7 sigalrm_handler 102 93 -9 parse_conf 1332 1323 -9 send_cgi_and_exit 803 790 -13 cgi_io_loop_and_exit 656 635 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/6 up/down: 12/-63) Total: -51 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/libbb.h') diff --git a/include/libbb.h b/include/libbb.h index 8d252d455..17c9bc785 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -457,6 +457,11 @@ void *xmmap_anon(size_t size) FAST_FUNC; //sparc64,alpha,openrisc: fixed 8k pages #endif +#if defined(__x86_64__) || defined(i386) +/* 0x7f would be better, but it causes alignment problems */ +# define ARCH_GLOBAL_PTR_OFF 0x80 +#endif + #if defined BB_ARCH_FIXED_PAGESIZE # define IF_VARIABLE_ARCH_PAGESIZE(...) /*nothing*/ # define bb_getpagesize() BB_ARCH_FIXED_PAGESIZE @@ -2423,6 +2428,16 @@ void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC; } \ } while (0) +#if defined(ARCH_GLOBAL_PTR_OFF) +# define SET_OFFSET_PTR_TO_GLOBALS(x) \ + ASSIGN_CONST_PTR(&ptr_to_globals, (char*)(x) + ARCH_GLOBAL_PTR_OFF) +# define OFFSET_PTR_TO_GLOBALS \ + ((struct globals*)((char*)ptr_to_globals - ARCH_GLOBAL_PTR_OFF)) +#else +# define SET_OFFSET_PTR_TO_GLOBALS(x) SET_PTR_TO_GLOBALS(x) +# define OFFSET_PTR_TO_GLOBALS ptr_to_globals +#endif + /* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it, * use bb_default_login_shell and following defines. -- cgit v1.2.3-55-g6feb