Index: examples/assembly/md5sum.imc
===================================================================
RCS file: /cvs/public/parrot/examples/assembly/md5sum.imc,v
retrieving revision 1.1
diff -c -r1.1 md5sum.imc
*** examples/assembly/md5sum.imc 22 Mar 2005 10:15:40 -0000 1.1
--- examples/assembly/md5sum.imc 28 Mar 2005 10:59:44 -0000
***************
*** 1,7 ****
# Parrot md5sum; Nick Glencross <ni...@glencros.demon.co.uk>
#
! # Based on md5.c, from md5sum
! # written by Ulrich Drepper <drep...@gnu.ai.mit.edu>, 1995.
=head1 NAME
--- 1,7 ----
# Parrot md5sum; Nick Glencross <ni...@glencros.demon.co.uk>
+ # Improvements from Leo
#
! # Harness for the library/Digest/MD5.imc library
=head1 NAME
***************
*** 15,31 ****
Behave very much like md5sum(1).
=cut
###########################################################################
!
! # Main Harness to show that it works
.sub _main @MAIN
.param pmc args
! .local int size
load_bytecode "library/Digest/MD5.imc"
# Argument count
$I0 = args
--- 15,33 ----
Behave very much like md5sum(1).
+ Running parrot with -j will give a significant performance boost (often
+ about ten-fold).
+
=cut
###########################################################################
! # Main Harness to demonstrate MD5.imc
.sub _main @MAIN
.param pmc args
! .local int size
load_bytecode "library/Digest/MD5.imc"
# Argument count
$I0 = args
***************
*** 46,52 ****
if $I1 > $I0 goto iter_done
$S0 = args[$I1]
.include "stat.pasm"
! # get size of file
stat size, $S0, .STAT_FILESIZE
open $P0, $S0, "<"
defined $I2, $P0
--- 48,54 ----
if $I1 > $I0 goto iter_done
$S0 = args[$I1]
.include "stat.pasm"
! # Get size of file
stat size, $S0, .STAT_FILESIZE
open $P0, $S0, "<"
defined $I2, $P0
Index: runtime/parrot/library/Digest/MD5.imc
===================================================================
RCS file: /cvs/public/parrot/runtime/parrot/library/Digest/MD5.imc,v
retrieving revision 1.1
diff -c -r1.1 MD5.imc
*** runtime/parrot/library/Digest/MD5.imc 22 Mar 2005 10:15:42 -0000 1.1
--- runtime/parrot/library/Digest/MD5.imc 28 Mar 2005 10:59:46 -0000
***************
*** 1,4 ****
--- 1,5 ----
# Parrot md5sum; Nick Glencross <ni...@glencros.demon.co.uk>
+ # Improvements from Leo
#
# Based on md5.c, from md5sum
# written by Ulrich Drepper <drep...@gnu.ai.mit.edu>, 1995.
***************
*** 36,42 ****
=item * Might work on 64 bit platforms
! =item * Might not work on big endian systems
=back
--- 37,43 ----
=item * Might work on 64 bit platforms
! =item * Might not work on big endian systems (confirmed)
=back
***************
*** 95,100 ****
--- 96,102 ----
_md5_process_buffer (context, buffer)
.return(context)
+
.end
***************
*** 275,281 ****
shift = 8*subcounter
word = word << shift
if endian goto endian_ok2
! .swap (word)
endian_ok2:
buffer[slow_counter] = word
--- 277,283 ----
shift = 8*subcounter
word = word << shift
if endian goto endian_ok2
! .swap (word)
endian_ok2:
buffer[slow_counter] = word
***************
*** 300,314 ****
.param pmc context
.param pmc buffer
! .local int A
! .local int B
! .local int C
! .local int D
!
! .local int A_save
! .local int B_save
! .local int C_save
! .local int D_save
.local int tmp, idx, len
--- 302,309 ----
.param pmc context
.param pmc buffer
! .local int A, B, C, D
! .local int A_save, B_save, C_save, D_save
.local int tmp, idx, len
***************
*** 413,419 ****
context[2] = C
context[3] = D
! # _print_vals (A,B,C,D)
# print "\n"
.end
--- 408,414 ----
context[2] = C
context[3] = D
! # print_vals (A,B,C,D)
# print "\n"
.end
***************
*** 470,475 ****
--- 465,471 ----
dont_swap:
_print_vals (A,B,C,D)
+
.end
###########################################################################
***************
*** 501,506 ****
--- 497,503 ----
print_buffer_done:
print "\n"
+
.end
###########################################################################
***************
*** 523,526 ****
--- 520,524 ----
sprintf $S0, $S1, $P0
.return($S0)
+
.end
Index: t/library/md5.t
===================================================================
RCS file: /cvs/public/parrot/t/library/md5.t,v
retrieving revision 1.1
diff -c -r1.1 md5.t
*** t/library/md5.t 22 Mar 2005 10:15:44 -0000 1.1
--- t/library/md5.t 28 Mar 2005 10:59:47 -0000
***************
*** 6,24 ****
# $ echo -n Hello World! | md5sum
# a0f32c7d31302c1427285b1a0fcbb015 -
use strict;
! use Parrot::Test tests => 3;
use Parrot::Config;
- my $bigendian = $PConfig{bigendian};
my $intsize = $PConfig{intsize};
SKIP: {
if ($bigendian || $intsize != 4)
{
! skip('MD5 only known to work on small endian 32 bit processors', 3)
}
--- 6,27 ----
# $ echo -n Hello World! | md5sum
# a0f32c7d31302c1427285b1a0fcbb015 -
+ # As well as testing the MD5 library itself, it is useful for spotting
+ # regressisions in the parrot VM, JIT and GC
+
use strict;
! use Parrot::Test tests => 4;
use Parrot::Config;
my $intsize = $PConfig{intsize};
+ my $bigendian = $PConfig{bigendian};
SKIP: {
if ($bigendian || $intsize != 4)
{
! skip('MD5 only known to work on small endian 32 bit processors', 4)
}
***************
*** 53,58 ****
--- 56,63 ----
ed076287532e86365e841e92bfc50d8c
OUT
+
+
pir_output_is(<<'CODE', <<'OUT', "Funny chars");
.sub _main
load_bytecode "library/Digest/MD5.imc"
***************
*** 78,83 ****
--- 83,89 ----
;
}
(
+ "",
"0",
"01",
"012",
***************
*** 200,205 ****
--- 206,212 ----
end
.end
CODE
+ d41d8cd98f00b204e9800998ecf8427e
cfcd208495d565ef66e7dff9f98764da
96a3be3cf272e017046d1b2674a52bd3
d2490f048dc3b77a457e3e450ab4eb38
***************
*** 312,315 ****
--- 319,338 ----
09e32555adc12a6f2c8fed9a459935af
6c27622d1d5365e4abfd02f2eccfd8f9
OUT
+
+
+ my $text = "Hello Parrot World! " x 50_000;
+
+ pir_output_is(<<CODE, <<'OUT', "REALLY long string");
+ .sub _main
+ load_bytecode "library/Digest/MD5.imc"
+ \$P0 = _md5sum ("$text")
+ _md5_print (\$P0)
+ print "\\n"
+ end
+ .end
+ CODE
+ 840e4dec51660b1f52473e0b0b9545f5
+ OUT
+
}