#! /usr/bin/env perl # # (C) 2014 by Argonne National Laboratory. # See COPYRIGHT in top-level directory. # use warnings; use strict; # Check to make sure the file was passed in as a parameter if ($#ARGV != 0) { print "Usage: buildiface \n"; exit 1; } open(FD, $ARGV[0]) || die "Could not open file " . $ARGV[0]; while () { if (/\/\*\s*Begin Prototypes/) { last; } } my $eol = 1; my $fullline = ""; my $tab = " "; my $retarg; my $routine; my $args; my @arglist; my $fname; my $cdesc_routine; my $x; my $y; my @argbits; my $num_dtypes; my @dtype_bind; my $io_header; my $make_exists = 0; open(OUTFD, ">all_romio_symbols.c") || die "Could not open file all_romio_symbols.c"; print OUTFD < #include "mpi.h" void MPIR_All_romio_symbols(void); void MPIR_All_romio_symbols(void) { #ifdef MPI_MODE_RDONLY EOT while () { if (/\/\*\s*End Prototypes/) { last; } if (/\/\*\s*Begin Skip Prototypes/) { while () { if (/\/\*\s*End Skip Prototypes/) { last; } } } # If we found a semi-colon at the end, that's the end of the line. # This is not perfect (e.g., does not work when a single line has # multiple semi-colon separated statements), but should be good # enough for the MPICH mpi.h file if (/.*;/) { $eol = 1; } else { $eol = 0; } chomp($_); $fullline .= "$_"; if ($eol == 0) { next; } # We got the entire prototype in a single line # parse out comments $fullline =~ s+/\*.*\*/++g; # parse out attributes $fullline =~ s/MPICH_ATTR_POINTER_WITH_TYPE_TAG\(.*\)//g; # cleanup pointer format $fullline =~ s/\s*\*/* /g; # parse out unnecessary spaces $fullline =~ s/^\s*//g; $fullline =~ s/\s*$//g; $fullline =~ s/\s*;/;/g; $fullline =~ s/\s\s*/ /g; # split the line into the return type, routine name, and arguments $fullline =~ m/([^ ]*) ([^(]*)\((.*)\)/; $retarg = $1; $routine = $2; $args = $3; # cleanup args $args =~ s/^\s*//g; $args =~ s/\s*$//g; @arglist = split(/,/, $args); for ($x = 0; $x <= $#arglist; $x++) { $arglist[$x] =~ s/^\s*//g; $arglist[$x] =~ s/\s*$//g; } print OUTFD "${tab}{\n"; for ($x = 0; $x <= $#arglist; $x++) { print OUTFD "${tab}${tab}$arglist[$x]"; if ($arglist[$x] =~ /\*/) { print OUTFD " = NULL;\n"; } elsif ($arglist[$x] =~ /MPI_Comm/) { print OUTFD " = MPI_COMM_NULL;\n"; } elsif ($arglist[$x] =~ /MPI_Info/) { print OUTFD " = MPI_INFO_NULL;\n"; } elsif ($arglist[$x] =~ /MPI_File/) { print OUTFD " = MPI_FILE_NULL;\n"; } elsif ($arglist[$x] =~ /MPI_Datatype/) { print OUTFD " = MPI_DATATYPE_NULL;\n"; } elsif ($arglist[$x] =~ /MPI_Errhandler/) { print OUTFD " = MPI_ERRHANDLER_NULL;\n"; } elsif ($arglist[$x] =~ /MPI_Offset/) { print OUTFD " = 0;\n"; } elsif ($arglist[$x] =~ /int/) { print OUTFD " = 0;\n"; } else { print "$arglist[$x]\n"; print OUTFD ";\n"; } } print OUTFD "\n${tab}${tab}$routine("; for ($x = 0; $x <= $#arglist; $x++) { @argbits = split(/ /, $arglist[$x]); if ($x < $#arglist) { print OUTFD "$argbits[$#argbits], "; } else { print OUTFD "$argbits[$#argbits]);\n"; } } print OUTFD "${tab}}\n\n"; $fullline = ""; } # A few symbols are not in mpio.h print OUTFD <