svn commit: trunk/busybox: archival include libbb

vda at busybox.net vda at busybox.net
Thu Mar 15 19:48:38 UTC 2007


Author: vda
Date: 2007-03-15 12:48:35 -0700 (Thu, 15 Mar 2007)
New Revision: 18121

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


Modified:
   trunk/busybox/archival/gzip.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/messages.c


Changeset:
Modified: trunk/busybox/archival/gzip.c
===================================================================
--- trunk/busybox/archival/gzip.c	2007-03-15 19:46:43 UTC (rev 18120)
+++ trunk/busybox/archival/gzip.c	2007-03-15 19:48:35 UTC (rev 18121)
@@ -2045,8 +2045,8 @@
 	}
 #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;

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-03-15 19:46:43 UTC (rev 18120)
+++ trunk/busybox/include/libbb.h	2007-03-15 19:48:35 UTC (rev 18121)
@@ -804,7 +804,10 @@
 /* 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.

Modified: trunk/busybox/libbb/messages.c
===================================================================
--- trunk/busybox/libbb/messages.c	2007-03-15 19:46:43 UTC (rev 18120)
+++ trunk/busybox/libbb/messages.c	2007-03-15 19:48:35 UTC (rev 18121)
@@ -57,4 +57,5 @@
 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")));




More information about the busybox-cvs mailing list