summaryrefslogtreecommitdiff
path: root/archival/bz/blocksort.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-12-02 08:35:37 +0000
committerDenis Vlasenko2007-12-02 08:35:37 +0000
commitab801874f852312787c049272c20b14e06ed8195 (patch)
tree1cfd38cfe48ed6a6625ce559ab7f3e5778a980be /archival/bz/blocksort.c
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 'archival/bz/blocksort.c')
-rw-r--r--archival/bz/blocksort.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/archival/bz/blocksort.c b/archival/bz/blocksort.c
index cddbfcb..0e73ffe 100644
--- a/archival/bz/blocksort.c
+++ b/archival/bz/blocksort.c
@@ -721,7 +721,8 @@ void mainQSort3(uint32_t* ptr,
#define CLEARMASK (~(SETMASK))
static NOINLINE
-void mainSort(uint32_t* ptr,
+void mainSort(EState* state,
+ uint32_t* ptr,
uint8_t* block,
uint16_t* quadrant,
uint32_t* ftab,
@@ -729,13 +730,18 @@ void mainSort(uint32_t* ptr,
int32_t* budget)
{
int32_t i, j, k, ss, sb;
- int32_t runningOrder[256];
- Bool bigDone[256];
- int32_t copyStart[256];
- int32_t copyEnd [256];
uint8_t c1;
int32_t numQSorted;
uint16_t s;
+ Bool bigDone[256];
+ /* bbox: moved to EState to save stack
+ int32_t runningOrder[256];
+ int32_t copyStart[256];
+ int32_t copyEnd [256];
+ */
+#define runningOrder (state->mainSort__runningOrder)
+#define copyStart (state->mainSort__copyStart)
+#define copyEnd (state->mainSort__copyEnd)
/*-- set up the 2-byte frequency table --*/
/* was: for (i = 65536; i >= 0; i--) ftab[i] = 0; */
@@ -985,6 +991,9 @@ void mainSort(uint32_t* ptr,
AssertH(((bbSize-1) >> shifts) <= 65535, 1002);
}
}
+#undef runningOrder
+#undef copyStart
+#undef copyEnd
}
#undef BIGFREQ
@@ -1041,7 +1050,7 @@ void BZ2_blockSort(EState* s)
*/
budget = nblock * ((wfact-1) / 3);
- mainSort(ptr, block, quadrant, ftab, nblock, &budget);
+ mainSort(s, ptr, block, quadrant, ftab, nblock, &budget);
if (budget < 0) {
fallbackSort(s->arr1, s->arr2, ftab, nblock);
}