3 BEGIN { require 5.004 }
5 use Config qw(%Config);
6 use ExtUtils::MakeMaker;
9 @extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
12 if (defined($Config{ccname})) {
13 if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
14 # VAX compiler optimizer even as late as v6.4 gets stuck
15 push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
20 push(@extra, 'INSTALLDIRS' => 'perl') if $] >= 5.008;
23 'NAME' => 'Digest::MD5',
24 'VERSION_FROM' => 'MD5.pm',
25 'PREREQ_PM' => { 'File::Spec' => 0,
26 'Digest::base' => '1.00',
29 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
34 sub free_u32_alignment
37 print "Testing alignment requirements for U32... ";
38 return 1 if $^O eq 'VMS';
39 return 1 if $^O eq 'MSWin32';
41 open(ALIGN_TEST, ">u32align.c") or die "$!";
42 print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
43 /*--------------------------------------------------------------*/
44 /* This program allocates a buffer of U8 (char) and then tries */
45 /* to access it through a U32 pointer at every offset. The */
46 /* program is expected to die with a bus error/seg fault for */
47 /* machines that do not support unaligned integer read/write */
48 /*--------------------------------------------------------------*/
58 int main(int argc, char** argv, char** env)
60 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
61 U8 buf[] = "\0\0\0\1\0\0\0\0";
65 if (sizeof(U32) != 4) {
66 printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
72 for (i = 0; i < 4; i++) {
74 if (! ((*up == 1 << (8*i)) || /* big-endian */
75 (*up == 1 << (8*(3-i))) /* little-endian */
79 printf("read failed (%x)\n", *up);
85 for (i = 0; i < 4; i++) {
89 printf("write failed (%x)\n", *up);
94 printf("no restrictions\n");
97 printf("unusual byteorder, playing safe\n");
102 /*--------------------------------------------------------------*/
105 my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
106 my $exe = "u32align$Config{exe_ext}";
107 $cc_cmd .= " -o $exe";
109 $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
111 print "Can't compile test program. Will ensure alignment to play safe.\n\n";
112 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
116 $rc = system("./$exe");
117 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
123 print "Test program exit status was $rc\n";
127 print "Core dump deleted\n";
130 print "signal $rc\n";