1N/A#
1N/A# CDDL HEADER START
1N/A#
1N/A# The contents of this file are subject to the terms of the
1N/A# Common Development and Distribution License, Version 1.0 only
1N/A# (the "License"). You may not use this file except in compliance
1N/A# with the License.
1N/A#
1N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A# or http://www.opensolaris.org/os/licensing.
1N/A# See the License for the specific language governing permissions
1N/A# and limitations under the License.
1N/A#
1N/A# When distributing Covered Code, include this CDDL HEADER in each
1N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A# If applicable, add the following below this CDDL HEADER, with the
1N/A# fields enclosed by brackets "[]" replaced with your own identifying
1N/A# information: Portions Copyright [yyyy] [name of copyright owner]
1N/A#
1N/A# CDDL HEADER END
1N/A#
1N/A#!perl -w
1N/A
1N/ABEGIN { require 5.004 }
1N/Ause strict;
1N/Ause Config qw(%Config);
1N/Ause ExtUtils::MakeMaker;
1N/A
1N/Amy $PERL_CORE = grep $_ eq "PERL_CORE=1", @ARGV;
1N/A
1N/Amy @extra;
1N/A@extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
1N/A
1N/Aif ($^O eq 'VMS') {
1N/A if (defined($Config{ccname})) {
1N/A if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
1N/A # VAX compiler optimizer even as late as v6.4 gets stuck
1N/A push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
1N/A }
1N/A }
1N/A}
1N/A
1N/Apush(@extra, 'INSTALLDIRS' => 'perl') if $] >= 5.008;
1N/Apush(@extra, 'MAN3PODS' => {}) if $PERL_CORE; # Pods built by installman.
1N/A
1N/AWriteMakefile(
1N/A 'NAME' => 'Digest::MD5',
1N/A 'VERSION_FROM' => 'MD5.pm',
1N/A 'PREREQ_PM' => { 'File::Spec' => 0,
1N/A 'Digest::base' => '1.00',
1N/A },
1N/A @extra,
1N/A 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
1N/A);
1N/A
1N/A
1N/A
1N/Asub free_u32_alignment
1N/A{
1N/A $|=1;
1N/A if (exists $Config{d_u32align}) {
1N/A print "Perl's config says that U32 access must ";
1N/A print "not " unless $Config{d_u32align};
1N/A print "be aligned.\n";
1N/A return !$Config{d_u32align};
1N/A }
1N/A
1N/A if ($^O eq 'VMS' || $^O eq 'MSWin32') {
1N/A print "Assumes that $^O implies free alignment for U32 access.\n";
1N/A return 1;
1N/A }
1N/A
1N/A if ($^O eq 'hpux' && $Config{osvers} < 11.0) {
1N/A print "Will not test for free alignment on older HP-UX.\n";
1N/A return 0;
1N/A }
1N/A
1N/A print "Testing alignment requirements for U32... ";
1N/A open(ALIGN_TEST, ">u32align.c") or die "$!";
1N/A print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
1N/A/*--------------------------------------------------------------*/
1N/A/* This program allocates a buffer of U8 (char) and then tries */
1N/A/* to access it through a U32 pointer at every offset. The */
1N/A/* program is expected to die with a bus error/seg fault for */
1N/A/* machines that do not support unaligned integer read/write */
1N/A/*--------------------------------------------------------------*/
1N/A
1N/A#include <stdio.h>
1N/A#include "EXTERN.h"
1N/A#include "perl.h"
1N/A
1N/A#ifdef printf
1N/A #undef printf
1N/A#endif
1N/A
1N/Aint main(int argc, char** argv, char** env)
1N/A{
1N/A#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
1N/A U8 buf[] = "\0\0\0\1\0\0\0\0";
1N/A U32 *up;
1N/A int i;
1N/A
1N/A if (sizeof(U32) != 4) {
1N/A printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
1N/A exit(1);
1N/A }
1N/A
1N/A fflush(stdout);
1N/A
1N/A for (i = 0; i < 4; i++) {
1N/A up = (U32*)(buf + i);
1N/A if (! ((*up == 1 << (8*i)) || /* big-endian */
1N/A (*up == 1 << (8*(3-i))) /* little-endian */
1N/A )
1N/A )
1N/A {
1N/A printf("read failed (%x)\n", *up);
1N/A exit(2);
1N/A }
1N/A }
1N/A
1N/A /* write test */
1N/A for (i = 0; i < 4; i++) {
1N/A up = (U32*)(buf + i);
1N/A *up = 0xBeef;
1N/A if (*up != 0xBeef) {
1N/A printf("write failed (%x)\n", *up);
1N/A exit(3);
1N/A }
1N/A }
1N/A
1N/A printf("no restrictions\n");
1N/A exit(0);
1N/A#else
1N/A printf("unusual byteorder, playing safe\n");
1N/A exit(1);
1N/A#endif
1N/A return 0;
1N/A}
1N/A/*--------------------------------------------------------------*/
1N/AEOT
1N/A
1N/A my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
1N/A my $exe = "u32align$Config{exe_ext}";
1N/A $cc_cmd .= " -o $exe";
1N/A my $rc;
1N/A $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
1N/A if ($rc) {
1N/A print "Can't compile test program. Will ensure alignment to play safe.\n\n";
1N/A unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
1N/A return 0;
1N/A }
1N/A
1N/A $rc = system("./$exe");
1N/A unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
1N/A
1N/A return 1 unless $rc;
1N/A
1N/A if ($rc > 0x80) {
1N/A $rc >>= 8;
1N/A print "Test program exit status was $rc\n";
1N/A } else {
1N/A if ($rc & 0x80) {
1N/A $rc &= ~0x80;
1N/A print "Core dump deleted\n";
1N/A unlink("core");
1N/A }
1N/A print "signal $rc\n";
1N/A }
1N/A return 0;
1N/A}