What on earth happened to platform.h?
Denys Vlasenko
vda.linux at googlemail.com
Sun Oct 24 13:19:58 UTC 2010
On Sunday 24 October 2010 11:02, Rob Landley wrote:
> Attached is the sha1sum.c I wrote for toybox a few years back. (Never did
> quite get around to cleaning it up, extending it to support the various other
> shaXXXsum sizes, or implementing md5sum. My todo list runneth over.) But
> what I was going for was _simple_, and I confirmed it produced the right output
> on all the data I threw at it. It's 185 lines including the actual applet
> implementation and help text and everything. The busybox one is 900 lines for
> the engine.
Patch: -19 bytes on x86, sums 300 mbytes in 4 seconds instead of 5.4:
--
vda
--- sha1sum.c.orig
+++ sha1sum.c
@@ -58,34 +58,33 @@
{
int i, j, k, count;
uint32_t *block = this->buffer.i;
- uint32_t *rot[5], *temp;
+ uint32_t rot[5], temp;
// Copy context->state[] to working vars
for (i=0; i<5; i++) {
- this->oldstate[i] = this->state[i];
- rot[i] = this->state + i;
+ rot[i] = this->state[i];
}
// 4 rounds of 20 operations each.
for (i=count=0; i<4; i++) {
for (j=0; j<20; j++) {
uint32_t work;
- work = *rot[2] ^ *rot[3];
- if (!i) work = (work & *rot[1]) ^ *rot[3];
+ work = rot[2] ^ rot[3];
+ if (!i) work = (work & rot[1]) ^ rot[3];
else {
if (i==2)
- work = ((*rot[1]|*rot[2])&*rot[3])|(*rot[1]&*rot[2]);
- else work ^= *rot[1];
+ work = ((rot[1]|rot[2])&rot[3])|(rot[1]&rot[2]);
+ else work ^= rot[1];
}
if (!i && j<16) work += blk0(count);
else work += blk(count);
- *rot[4] += work + rol(*rot[0],5) + rconsts[i];
- *rot[1] = rol(*rot[1],30);
+ rot[4] += work + rol(rot[0],5) + rconsts[i];
+ rot[1] = rol(rot[1],30);
// Rotate by one for next time.
temp = rot[4];
for (k=4; k; k--) rot[k] = rot[k-1];
- *rot = temp;
+ rot[0] = temp;
count++;
}
}
More information about the busybox
mailing list