From: Jarkko Hietaniemi Date: Fri, 8 Mar 2002 17:50:21 +0000 (+0000) Subject: Nice porting script from Sarathy. Well, less nice X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb304ec8d8e029b37ee317ef1c3ab3a4f3743b3b;p=p5sagit%2Fp5-mst-13.2.git Nice porting script from Sarathy. Well, less nice in the sense that it shows the looong road ahead. p4raw-id: //depot/perl@15111 --- diff --git a/MANIFEST b/MANIFEST index 1a7e8f5..1afa04f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2056,6 +2056,7 @@ Porting/config.sh Sample config.sh Porting/config_H Sample config.h Porting/Contract Social contract for contributed modules in Perl core Porting/findvars Find occurrences of words +Porting/findrfuncs Find reentrant variants of functions used in an executable Porting/fixCORE Find and fix modules that generate warnings Porting/fixvars Find undeclared variables with C compiler and fix em Porting/genlog Generate formatted changelogs by querying p4d diff --git a/Porting/findrfuncs b/Porting/findrfuncs new file mode 100644 index 0000000..0e1d3d0 --- /dev/null +++ b/Porting/findrfuncs @@ -0,0 +1,81 @@ +#!/usr/bin/perl -w + +# +# findrfuncs: find reentrant variants of functions used in an executable. +# Requires a functional "nm -u". Searches headers in /usr/include +# to find available *_r functions and looks for non-reentrant +# variants used in the supplied executable. +# +# Gurusamy Sarathy +# gsar@ActiveState.com +# +# Hacked to automatically find the executable and shared objects. +# --jhi + +use strict; +use File::Find; + +my @EXES; +my $NMU = 'nm -u'; +my @INCDIRS = qw(/usr/include); +my $SO = 'so'; +my $EXE = ''; + +if (open(CONFIG, "config.sh")) { + local $/; + my $CONFIG = ; + $SO = $1 if $CONFIG =~ /^so='(\w+)'/m; + $EXE = $1 if $CONFIG =~ /^_exe='\.(\w+)'/m; +} + +push @EXES, "perl$EXE"; + +find(sub {push @EXES, $File::Find::name if /.$SO$/}, '.' ); + +push @EXES, @ARGV; + +if ($^O eq 'dec_osf') { + $NMU = 'nm -Bu'; +} + +my %rfuncs; +my @syms; +find(sub { + return unless -f $File::Find::name; + open my $F, "<$File::Find::name" + or die "Can't open $File::Find::name: $!"; + my $line; + while (defined ($line = <$F>)) { + if ($line =~ /\b(\w+_r)\b/) { + #warn "$1 => $File::Find::name\n"; + $rfuncs{$1} = $File::Find::name; + } + } + close $F; + }, @INCDIRS); + +# delete bogus symbols grepped out of comments and such +delete $rfuncs{setlocale_r} if $^O eq 'linux'; + +for my $exe (@EXES) { + for my $sym (`$NMU $exe`) { + chomp $sym; + $sym =~ s/^\s+[Uu]\s+//; + $sym =~ s/^\s+//; + next if /\s/; + $sym =~ s/\@.*\z//; # remove @@GLIBC_2.0 etc + # warn "#### $sym\n"; + if (exists $rfuncs{"${sym}_r"}) { + push @syms, $sym; + } + } + + if (@syms) { + print "\nFollowing symbols in $exe have reentrant versions:\n"; + for my $sym (@syms) { + print "$sym => $sym" . "_r (in file " . $rfuncs{"${sym}_r"} . ")\n"; + } + } + @syms = (); +} + diff --git a/Porting/makerel b/Porting/makerel index 3bfb855..2024915 100644 --- a/Porting/makerel +++ b/Porting/makerel @@ -96,8 +96,13 @@ my @exe = qw( vms/ext/Stdio/test.pl vms/ext/filespec.t x2p/*.SH - Porting/patchls + Porting/findrfuncs + Porting/genlog Porting/makerel + Porting/p4d2p + Porting/p4desc + Porting/patchls + Porting/*.pl mpeix/nm mpeix/relink );