diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-08 17:50:21 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-03-08 17:50:21 +0000 |
commit | bb304ec8d8e029b37ee317ef1c3ab3a4f3743b3b (patch) | |
tree | bd3fa789f77f13ff1e91a005e45e26874aec28bf /Porting | |
parent | c29a771d3f5d4c2b623f61b706064fd8db958f3a (diff) | |
download | perl-bb304ec8d8e029b37ee317ef1c3ab3a4f3743b3b.tar.gz |
Nice porting script from Sarathy. Well, less nice
in the sense that it shows the looong road ahead.
p4raw-id: //depot/perl@15111
Diffstat (limited to 'Porting')
-rw-r--r-- | Porting/findrfuncs | 81 | ||||
-rw-r--r-- | Porting/makerel | 7 |
2 files changed, 87 insertions, 1 deletions
diff --git a/Porting/findrfuncs b/Porting/findrfuncs new file mode 100644 index 0000000000..0e1d3d0ecb --- /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 = <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 3bfb855655..2024915bbb 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 ); |