summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenis Vlasenko2007-12-02 08:35:37 +0000
committerDenis Vlasenko2007-12-02 08:35:37 +0000
commitab801874f852312787c049272c20b14e06ed8195 (patch)
tree1cfd38cfe48ed6a6625ce559ab7f3e5778a980be /util-linux
parent8003e266edbc0ec62a586dd70dcc80dc13e2dbf0 (diff)
downloadbusybox-ab801874f852312787c049272c20b14e06ed8195.zip
busybox-ab801874f852312787c049272c20b14e06ed8195.tar.gz
attack the biggest stack users:
-mkfs_minix_main [busybox_unstripped]: 4288 -mkfs_minix_main [busybox_unstripped]: 4276 -grave [busybox_unstripped]: 4260 (bzip2 users too - not listed) price we pay in code size increase: mainSort 2458 2515 +57 grave 1005 1058 +53 sendMTFValues 2177 2195 +18 BZ2_blockSort 122 125 +3 mkfs_minix_main 3070 3022 -48 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 131/-48) Total: 83 bytes
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/mkfs_minix.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index de9dde3..35c0ccf 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -109,16 +109,22 @@ struct globals {
unsigned long req_nr_inodes;
unsigned currently_testing;
-
char root_block[BLOCK_SIZE];
char super_block_buffer[BLOCK_SIZE];
char boot_block_buffer[512];
unsigned short good_blocks_table[MAX_GOOD_BLOCKS];
/* check_blocks(): buffer[] was the biggest static in entire bbox */
char check_blocks_buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS];
-};
+ unsigned short ind_block1[BLOCK_SIZE >> 1];
+ unsigned short dind_block1[BLOCK_SIZE >> 1];
+ unsigned long ind_block2[BLOCK_SIZE >> 2];
+ unsigned long dind_block2[BLOCK_SIZE >> 2];
+};
#define G (*ptr_to_globals)
+#define INIT_G() do { \
+ PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
+} while (0)
static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n)
{
@@ -306,8 +312,12 @@ static void make_bad_inode(void)
struct minix1_inode *inode = &INODE_BUF1[MINIX_BAD_INO];
int i, j, zone;
int ind = 0, dind = 0;
+ /* moved to globals to reduce stack usage
unsigned short ind_block[BLOCK_SIZE >> 1];
unsigned short dind_block[BLOCK_SIZE >> 1];
+ */
+#define ind_block (G.ind_block1)
+#define dind_block (G.dind_block1)
#define NEXT_BAD (zone = next(zone))
@@ -351,6 +361,8 @@ static void make_bad_inode(void)
write_block(ind, (char *) ind_block);
if (dind)
write_block(dind, (char *) dind_block);
+#undef ind_block
+#undef dind_block
}
#if ENABLE_FEATURE_MINIX2
@@ -359,8 +371,12 @@ static void make_bad_inode2(void)
struct minix2_inode *inode = &INODE_BUF2[MINIX_BAD_INO];
int i, j, zone;
int ind = 0, dind = 0;
+ /* moved to globals to reduce stack usage
unsigned long ind_block[BLOCK_SIZE >> 2];
unsigned long dind_block[BLOCK_SIZE >> 2];
+ */
+#define ind_block (G.ind_block2)
+#define dind_block (G.dind_block2)
if (!G.badblocks)
return;
@@ -401,6 +417,8 @@ static void make_bad_inode2(void)
write_block(ind, (char *) ind_block);
if (dind)
write_block(dind, (char *) dind_block);
+#undef ind_block
+#undef dind_block
}
#else
void make_bad_inode2(void);
@@ -613,7 +631,7 @@ int mkfs_minix_main(int argc, char **argv)
char *str_i, *str_n;
char *listfile = NULL;
- PTR_TO_GLOBALS = xzalloc(sizeof(G));
+ INIT_G();
/* default (changed to 30, per Linus's suggestion, Sun Nov 21 08:05:07 1993) */
G.namelen = 30;
G.dirsize = 32;