From c59e8fd6cb9af2505341139f9db1a5cc579b9c0f Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 7 Oct 2011 15:33:31 +0200 Subject: [PATCH] In bisect-runner.pl, "patch" ext/IPC/SysV/SysV.xs to the current SHMLBA code. For some historical revisions, it's not good enough simply taking out the first #include , because other code changes in that area can break the build. Instead, replace any old version of that #ifdef forest with the current code. Additionally, do this editing unconditionally, even if the target is "miniperl". Skipping it on target "miniperl" causes surprises if one is trying to debug the build by getting bisect-runner.pl to build to miniperl (or skip), and then using make lib/auto/IPC/SysV/SysV.so as the test case. This adds an edit_file() function. Move apply_patch() next to it, to group related functions together. --- Porting/bisect-runner.pl | 89 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 28 deletions(-) diff --git a/Porting/bisect-runner.pl b/Porting/bisect-runner.pl index 22137ab..db498da 100755 --- a/Porting/bisect-runner.pl +++ b/Porting/bisect-runner.pl @@ -389,6 +389,28 @@ sub extract_from_file { return; } +sub edit_file { + my ($file, $munger) = @_; + local $/; + open my $fh, '<', $file or die "Can't open $file: $!"; + my $orig = <$fh>; + die "Can't read $file: $!" unless defined $orig && close $fh; + my $new = $munger->($orig); + return if $new eq $orig; + open $fh, '>', $file or die "Can't open $file: $!"; + print $fh $new or die "Can't print to $file: $!"; + close $fh or die "Can't close $file: $!"; +} + +sub apply_patch { + my $patch = shift; + + my ($file) = $patch =~ qr!^diff.*a/(\S+) b/\1!; + open my $fh, '|-', 'patch', '-p1' or die "Can't run patch: $!"; + print $fh $patch; + close $fh or die "Can't patch $file: $?, $!"; +} + sub clean { if ($options{clean}) { # Needed, because files that are build products in this checked out @@ -454,15 +476,6 @@ sub match_and_exit { 'no matches for', $match); } -sub apply_patch { - my $patch = shift; - - my ($file) = $patch =~ qr!^diff.*a/(\S+) b/\1!; - open my $fh, '|-', 'patch', '-p1' or die "Can't run patch: $!"; - print $fh $patch; - close $fh or die "Can't patch $file: $?, $!"; -} - # Not going to assume that system perl is yet new enough to have autodie system 'git clean -dxf +#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) +#ifndef HAS_SEM +# include +#endif +# ifdef HAS_MSG +# include +# endif +# ifdef HAS_SHM +# if defined(PERL_SCO) || defined(PERL_ISC) +# include /* SHMLBA */ +# endif +# include +# ifndef HAS_SHMAT_PROTOTYPE + extern Shmat_t shmat (int, char *, int); +# endif +# if defined(HAS_SYSCONF) && defined(_SC_PAGESIZE) +# undef SHMLBA /* not static: determined at boot time */ +# define SHMLBA sysconf(_SC_PAGESIZE) +# elif defined(HAS_GETPAGESIZE) +# undef SHMLBA /* not static: determined at boot time */ +# define SHMLBA getpagesize() +# endif +# endif +#endif +EOFIX + $xs =~ s! +#include +.* +(#ifdef newCONSTSUB|/\* Required)!$fixed$1!ms; + return $xs; + }); +} + # Parallel build for miniperl is safe system "make $j miniperl )$!)) { - apply_patch(<<"EOPATCH"); -diff --git a/ext/IPC/SysV/SysV.xs b/ext/IPC/SysV/SysV.xs -index 35a8fde..62a7965 100644 ---- a/ext/IPC/SysV/SysV.xs -+++ b/ext/IPC/SysV/SysV.xs -\@\@ -4,7 +4,6 \@\@ - - #include - #ifdef __linux__ --$line - #endif - #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) - #ifndef HAS_SEM -EOPATCH - } system "make $j $real_target