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