Commit | Line | Data |
ee7ea0b1 |
1 | #!perl -w |
2 | |
3357b1b1 |
3 | use strict; |
4 | use Config qw(%Config); |
5 | use ExtUtils::MakeMaker; |
6 | |
ee7ea0b1 |
7 | my $PERL_CORE = grep $_ eq "PERL_CORE=1", @ARGV; |
8 | |
3357b1b1 |
9 | my @extra; |
9a03235d |
10 | @extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment(); |
92dc3567 |
11 | |
55315086 |
12 | if ($^O eq 'VMS') { |
13 | if (defined($Config{ccname})) { |
614d5782 |
14 | if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) { |
15 | # VAX compiler optimizer even as late as v6.4 gets stuck |
9a03235d |
16 | push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)"); |
55315086 |
17 | } |
18 | } |
19 | } |
3357b1b1 |
20 | |
77e6095e |
21 | push(@extra, 'INSTALLDIRS' => 'perl') if $] >= 5.008; |
ee7ea0b1 |
22 | push(@extra, 'MAN3PODS' => {}) if $PERL_CORE; # Pods built by installman. |
47a7661d |
23 | push @extra, 'LICENSE' => 'perl' if $ExtUtils::MakeMaker::VERSION >= "6.30"; |
9a03235d |
24 | |
3357b1b1 |
25 | WriteMakefile( |
26 | 'NAME' => 'Digest::MD5', |
27 | 'VERSION_FROM' => 'MD5.pm', |
ee7ea0b1 |
28 | 'PREREQ_PM' => { 'File::Spec' => 0, |
29 | 'Digest::base' => '1.00', |
47a7661d |
30 | 'XSLoader' => 0, |
ee7ea0b1 |
31 | }, |
3357b1b1 |
32 | @extra, |
33 | 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, |
34 | ); |
3357b1b1 |
35 | |
9a03235d |
36 | |
37 | |
38 | sub free_u32_alignment |
39 | { |
ee7ea0b1 |
40 | $|=1; |
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}; |
46 | } |
47 | |
48 | if ($^O eq 'VMS' || $^O eq 'MSWin32') { |
49 | print "Assumes that $^O implies free alignment for U32 access.\n"; |
50 | return 1; |
51 | } |
52 | |
53 | if ($^O eq 'hpux' && $Config{osvers} < 11.0) { |
54 | print "Will not test for free alignment on older HP-UX.\n"; |
55 | return 0; |
56 | } |
57 | |
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 | /*--------------------------------------------------------------*/ |
67 | |
68 | #include <stdio.h> |
69 | #include "EXTERN.h" |
70 | #include "perl.h" |
71 | |
72 | #ifdef printf |
73 | #undef printf |
74 | #endif |
75 | |
76 | int main(int argc, char** argv, char** env) |
77 | { |
78 | #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321 |
79 | U8 buf[] = "\0\0\0\1\0\0\0\0"; |
80 | U32 *up; |
81 | int i; |
82 | |
83 | if (sizeof(U32) != 4) { |
84 | printf("sizeof(U32) is not 4, but %d\n", sizeof(U32)); |
85 | exit(1); |
86 | } |
87 | |
88 | fflush(stdout); |
89 | |
90 | for (i = 0; i < 4; i++) { |
91 | up = (U32*)(buf + i); |
92 | if (! ((*up == 1 << (8*i)) || /* big-endian */ |
93 | (*up == 1 << (8*(3-i))) /* little-endian */ |
94 | ) |
95 | ) |
96 | { |
97 | printf("read failed (%x)\n", *up); |
98 | exit(2); |
99 | } |
100 | } |
101 | |
102 | /* write test */ |
103 | for (i = 0; i < 4; i++) { |
104 | up = (U32*)(buf + i); |
105 | *up = 0xBeef; |
106 | if (*up != 0xBeef) { |
107 | printf("write failed (%x)\n", *up); |
108 | exit(3); |
109 | } |
110 | } |
111 | |
112 | printf("no restrictions\n"); |
113 | exit(0); |
114 | #else |
115 | printf("unusual byteorder, playing safe\n"); |
116 | exit(1); |
117 | #endif |
118 | return 0; |
119 | } |
120 | /*--------------------------------------------------------------*/ |
121 | EOT |
122 | |
123 | my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE"; |
124 | my $exe = "u32align$Config{exe_ext}"; |
125 | $cc_cmd .= " -o $exe"; |
126 | my $rc; |
127 | $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}"); |
128 | if ($rc) { |
129 | print "Can't compile test program. Will ensure alignment to play safe.\n\n"; |
130 | unlink("u32align.c", $exe, "u32align$Config{obj_ext}"); |
131 | return 0; |
132 | } |
133 | |
134 | $rc = system("./$exe"); |
135 | unlink("u32align.c", $exe, "u32align$Config{obj_ext}"); |
136 | |
137 | return 1 unless $rc; |
138 | |
139 | if ($rc > 0x80) { |
6e770d9c |
140 | (my $cp = $rc) >>= 8; |
141 | print "Test program exit status was $cp\n"; |
142 | } |
143 | if ($rc & 0x80) { |
144 | $rc &= ~0x80; |
145 | unlink("core") && print "Core dump deleted\n"; |
ee7ea0b1 |
146 | } |
6e770d9c |
147 | print "signal $rc\n" if $rc && $rc < 0x80; |
9a03235d |
148 | return 0; |
149 | } |