4 use Config qw(%Config);
5 use ExtUtils::MakeMaker;
8 @extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
11 if (defined($Config{ccname})) {
12 if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
13 # VAX compiler optimizer even as late as v6.4 gets stuck
14 push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
19 push(@extra, 'INSTALLDIRS' => 'perl') if $] >= 5.008;
20 push @extra, 'LICENSE' => 'perl' if eval($ExtUtils::MakeMaker::VERSION) >= "6.30";
23 'NAME' => 'Digest::MD5',
24 'VERSION_FROM' => 'MD5.pm',
25 'PREREQ_PM' => { 'File::Spec' => 0,
26 'Digest::base' => '1.00',
30 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
35 sub free_u32_alignment
38 if (exists $Config{d_u32align}) {
39 print "Perl's config says that U32 access must ";
40 print "not " unless $Config{d_u32align};
41 print "be aligned.\n";
42 return !$Config{d_u32align};
45 if ($^O eq 'VMS' || $^O eq 'MSWin32') {
46 print "Assumes that $^O implies free alignment for U32 access.\n";
50 if ($^O eq 'hpux' && $Config{osvers} < 11.0) {
51 print "Will not test for free alignment on older HP-UX.\n";
55 print "Testing alignment requirements for U32... ";
56 open(ALIGN_TEST, ">u32align.c") or die "$!";
57 print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
58 /*--------------------------------------------------------------*/
59 /* This program allocates a buffer of U8 (char) and then tries */
60 /* to access it through a U32 pointer at every offset. The */
61 /* program is expected to die with a bus error/seg fault for */
62 /* machines that do not support unaligned integer read/write */
63 /*--------------------------------------------------------------*/
73 int main(int argc, char** argv, char** env)
75 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
76 U8 buf[] = "\0\0\0\1\0\0\0\0";
80 if (sizeof(U32) != 4) {
81 printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
87 for (i = 0; i < 4; i++) {
89 if (! ((*up == 1 << (8*i)) || /* big-endian */
90 (*up == 1 << (8*(3-i))) /* little-endian */
94 printf("read failed (%x)\n", *up);
100 for (i = 0; i < 4; i++) {
101 up = (U32*)(buf + i);
104 printf("write failed (%x)\n", *up);
109 printf("no restrictions\n");
112 printf("unusual byteorder, playing safe\n");
117 /*--------------------------------------------------------------*/
120 my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
121 my $exe = "u32align$Config{exe_ext}";
122 $cc_cmd .= " -o $exe";
124 $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
126 print "Can't compile test program. Will ensure alignment to play safe.\n\n";
127 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
131 $rc = system("./$exe");
132 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
137 (my $cp = $rc) >>= 8;
138 print "Test program exit status was $cp\n";
142 unlink("core") && print "Core dump deleted\n";
144 print "signal $rc\n" if $rc && $rc < 0x80;