← Commit list

bff32ce4d

Denis Vlasenko
Denis Vlasenko
2007-03-15
FAILED Duration: 12s

Subject

gzip: Improve ptr_to_globals trick, allowing gcc to optimize better. -480 bytes.

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

archival/gzip.c+2 -2
@@ -2045,8 +2045,8 @@ int gzip_main(int argc, char **argv)
}
#endif
- ptr_to_globals = xzalloc(sizeof(struct globals) + sizeof(struct globals2));
- ptr_to_globals++;
+ PTR_TO_GLOBALS = xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+ + sizeof(struct globals);
G2.l_desc.dyn_tree = G2.dyn_ltree;
G2.l_desc.static_tree = G2.static_ltree;
G2.l_desc.extra_bits = extra_lbits;
include/libbb.h+4 -1
@@ -804,7 +804,10 @@ extern char bb_common_bufsiz1[BUFSIZ+1];
/* This struct is deliberately not defined. */
/* See docs/keep_data_small.txt */
struct globals;
-extern struct globals *ptr_to_globals;
+/* Magic prevents this from going into rodata */
+/* If you want to assign a value, use PTR_TO_GLOBALS = xxx */
+extern struct globals *const ptr_to_globals;
+#define PTR_TO_GLOBALS (*(struct globals**)&ptr_to_globals)
/* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it,
* use bb_default_login_shell and following defines.
libbb/messages.c+2 -1
@@ -57,4 +57,5 @@ WTMP_FILE;
char bb_common_bufsiz1[BUFSIZ+1];
struct globals;
-struct globals *ptr_to_globals;
+/* Make it reside in R/W memory: */
+struct globals *const ptr_to_globals __attribute__ ((section (".data")));