4 use Config qw(%Config);
5 use ExtUtils::MakeMaker;
7 my $PERL_CORE = grep $_ eq "PERL_CORE=1", @ARGV;
10 @extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
13 if (defined($Config{ccname})) {
14 if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
15 # VAX compiler optimizer even as late as v6.4 gets stuck
16 push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
21 push(@extra, 'INSTALLDIRS' => 'perl') if $] >= 5.008;
22 push(@extra, 'MAN3PODS' => {}) if $PERL_CORE; # Pods built by installman.
23 push @extra, 'LICENSE' => 'perl' if eval($ExtUtils::MakeMaker::VERSION) >= "6.30";
26 'NAME' => 'Digest::MD5',
27 'VERSION_FROM' => 'MD5.pm',
28 'PREREQ_PM' => { 'File::Spec' => 0,
29 'Digest::base' => '1.00',
33 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
38 sub free_u32_alignment
41 if (exists $Config{d_u32align}) {
42 print "Perl's config says that U32 access must ";
43 print "not " unless $Config{d_u32align};
44 print "be aligned.\n";
45 return !$Config{d_u32align};
48 if ($^O eq 'VMS' || $^O eq 'MSWin32') {
49 print "Assumes that $^O implies free alignment for U32 access.\n";
53 if ($^O eq 'hpux' && $Config{osvers} < 11.0) {
54 print "Will not test for free alignment on older HP-UX.\n";
58 print "Testing alignment requirements for U32... ";
59 open(ALIGN_TEST, ">u32align.c") or die "$!";
60 print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
61 /*--------------------------------------------------------------*/
62 /* This program allocates a buffer of U8 (char) and then tries */
63 /* to access it through a U32 pointer at every offset. The */
64 /* program is expected to die with a bus error/seg fault for */
65 /* machines that do not support unaligned integer read/write */
66 /*--------------------------------------------------------------*/
76 int main(int argc, char** argv, char** env)
78 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
79 U8 buf[] = "\0\0\0\1\0\0\0\0";
83 if (sizeof(U32) != 4) {
84 printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
90 for (i = 0; i < 4; i++) {
92 if (! ((*up == 1 << (8*i)) || /* big-endian */
93 (*up == 1 << (8*(3-i))) /* little-endian */
97 printf("read failed (%x)\n", *up);
103 for (i = 0; i < 4; i++) {
104 up = (U32*)(buf + i);
107 printf("write failed (%x)\n", *up);
112 printf("no restrictions\n");
115 printf("unusual byteorder, playing safe\n");
120 /*--------------------------------------------------------------*/
123 my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
124 my $exe = "u32align$Config{exe_ext}";
125 $cc_cmd .= " -o $exe";
127 $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
129 print "Can't compile test program. Will ensure alignment to play safe.\n\n";
130 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
134 $rc = system("./$exe");
135 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
140 (my $cp = $rc) >>= 8;
141 print "Test program exit status was $cp\n";
145 unlink("core") && print "Core dump deleted\n";
147 print "signal $rc\n" if $rc && $rc < 0x80;