📄 buildiface
字号:
# Build the special routines&build_specials;## This block can be used to create the Makefile## This isn't quite right. mpicxx.h isn't a regular kind of source file.$filename = "Makefile.sm";open ( MAKEFD, ">${filename}.new" ) || die "Cannot create ${filename}.new";print MAKEFD "# DO NOT EDIT\n# This file created by buildiface $arg_string\n";# This line is unfortunately necessary to ensure that a working# autoconf is used.print MAKEFD "smvar_do_dependencies = ignore\n";&print_line( MAKEFD, "mpi_sources = ", 80, "\\\n\t", 8 );for ($i=0; $i<=$#files; $i++) { $name = $files[$i]; &print_line( MAKEFD, "$name ", 80, "\\\n\t", 8 );}&print_endline( MAKEFD );# No profile library for C++. All routines call the MPI, not PMPI, routines.my $otherSources = "";if ($doCoverage) { $otherSources .= " mpicovsimple.cxx"; $otherHeaders .= " \${srcdir}/mpicxxcov.h \${srcdir}/mpicovsimple.h";}print MAKEFD "MPICXXLIBNAME = \@MPICXXLIBNAME\@\n";print MAKEFD "lib\${MPICXXLIBNAME}_a_DIR = ROOTDIR/lib\lib\${MPICXXLIBNAME}_a_SOURCES = \${mpi_sources} $otherSources\\INCLUDES = -I../../include -I\${top_srcdir}/src/include -I\$(master_top_srcdir)/src/include \maintainerclean-local:\\trm -f \${mpi_sources}\install_INCLUDE = mpicxx.h $otherHeaders\n"; # Add the documentation print MAKEFD "# Documentation sourcesdoc_sources = mpicxx.txtDOCDESTDIRS = html:www/www1,man:man/man1,latex:doc/refmandoc_HTML_SOURCES = \${doc_sources}doc_MAN_SOURCES = \${doc_sources}doc_LATEX_SOURCES = \${doc_sources}";# Since configure copies mpicxx to the bin dir, we need to remove it# in a distclean step. print MAKEFD "distclean-local:\n";print MAKEFD "\trm -f ../../../bin/mpicxx\n";print MAKEFD "\trm -f ../../../src/include/mpicxx.h\n";if ($doCoverage) { print MAKEFD "\trm -f ../../../src/include/mpicovsimple.h\n"; print MAKEFD "\trm -f ../../../src/include/mpicxxcov.h\n";}## Special targets for building the coverage supportif ($doCoverage) { print MAKEFD "mpicovsimple.o: mpicovsimple.cxx mpicovsimple.h\n"; print MAKEFD "\t\$(CXX_COMPILE) -c -DCOVERAGE_DIR='\"\@builddir\@\"' \${srcdir}/mpicovsimple.cxx\n";}close( MAKEFD );&ReplaceIfDifferent( $filename, "${filename}.new" );## ------------------------------------------------------------------------# Procedures# print_line( FD, line, count, continue, continuelen )# Print line to FD; if line size > count, output continue string and# continue. Use print_endline to finish a linesub print_line { my $FD = $_[0]; my $line = $_[1]; my $count = $_[2]; my $continue = $_[3]; my $continue_len = $_[4]; $linelen = length( $line ); #print "linelen = $linelen, print_line_len = $print_line_len\n"; if ($print_line_len + $linelen > $count) { print $FD $continue; $print_line_len = $continue_len; } print $FD $line; $print_line_len += $linelen;}sub print_endline { my $FD = $_[0]; print $FD "\n"; $print_line_len = 0;}# Print the header of the file, containing the definitions etc.sub print_header { print $OUTFD "/* -*- Mode: C++; c-basic-offset:4 ; -*- */\/* \ * (C) 2001 by Argonne National Laboratory.\ * See COPYRIGHT in top-level directory.\ *\ * This file is automatically generated by buildiface $arg_string\ * DO NOT EDIT\ *//* style: c++ header */\\n";}# Print checks for names that might be defined but that conflict with# MPIsub printDefineChecks { # Add a test for definitions that will cause problems # Unfortunately, #warning isn't part of standard C, so we can't use # it. print $OUTFD "#ifdef MPI#error \"You cannot define MPI; that name is reserved for the MPI namespace\"#endif\n"; # Let the user define MPICH_IGNORE_CXX_SEEK to both # suppress the check for SEEK_SET etc. and to suppress the definition # of the values. print $OUTFD "// There is a name conflict between stdio.h and the MPI C++ binding // with respect to the names SEEK_SET, SEEK_CUR, and SEEK_END. MPI// wants these in the MPI namespace, but stdio.h will #define these// to integer values. #undef'ing these can cause obscure problems// with other include files (such as iostream), so we instead use// #error to indicate a fatal error. Users can either #undef // the names before including mpi.h or include mpi.h *before* stdio.h// or iostream. \n"; print $OUTFD "#ifndef MPICH_IGNORE_CXX_SEEK#ifdef SEEK_SET#error \"SEEK_SET is #defined but must not be for the C++ binding of MPI\"//#undef SEEK_SET#endif#ifdef SEEK_CUR#error \"SEEK_CUR is #defined but must not be for the C++ binding of MPI\"//#undef SEEK_CUR#endif#ifdef SEEK_END//#undef SEEK_END#error \"SEEK_END is #defined but must not be for the C++ binding of MPI\"#endif#endif\n\n";}# Print the arguments for the routine DEFINITION.# TODO : Remove any output parameters. This is stored in info by position # if an integer or type (if a string). If 0, there is no return objectsub print_args { my $OUTFD = $_[0]; my @parms = split(/\s*,\s*/, $_[1] ); # the original parameter list my $class_type = $_[2]; # Is this a Comm, Info, or othe # class? Use to find the position # of the "this" entry in the C # version of the routine. my $arginfo = $_[3]; # Value of <class>_hash{routine)} my $count = 1; my $last_args = ""; $first = 1; my $args_printed = 0; my $is_static = 0; # set to true if function is static &debugPrint( $routine, "In print_args" ); my $special_args = "::"; if ($arginfo =~ /^static:/) { $arginfo =~ s/^static://; $is_static = 1; } if ($arginfo =~ /(^[^:]+):(.*)/) { $returnarg = $1; $special_args = ":".$2.":"; # makes the numbers :\d+:... &debugPrint( $routine, "Routine $routine special args $special_args" ); } # Special case: if the only parm is "void", remove it from the list print STDERR "Nparms = $#parms, parms = " . join(',',@parms) . "\n" if $gDebug; if ($#parms == 0 && $parms[0] eq "void") { &debugPrint( $routine, "Setting nparms to -1" ); $#parms = -1; } # class_pos is the position of the class variable in the argument list. # If specified by parm type, we must find it $class_pos = -1; if ($class_pos == -1 && $class_type ne "" && !$is_static) { &debugPrint( $routine, "Looking for class $class_type" ); $class_pos = 0; $pos = 1; foreach $parm (@parms) { if ($parm =~ /$class_type/) { # Found the type; set the position of the class variable $class_pos = $pos; last; } $pos++; } } # Output the list print $OUTFD "( "; foreach $parm (@parms) { $pos_check = ":" . $count . ":"; print "parm = :$parm:\n" if $gDebug; # Check whether this argument has special processing # Otherwise, apply standardized rules (currently, this # is used only to prepend a qualifier, such as "const"). if ($special_args =~ /$pos_check/) { if (&DoSpecialArgProcessing( $OUTFD, $routine, $count, "methoddecl" ) ) { $args_printed ++; $count++; if ($first) { $first = 0; } next; } } # Match type to replacement if ($count == $class_pos || $count == $return_parm_pos) { &debugPrint( $routine, "Skipping parm $parm because of position or return" ); # Skip this arg in the definition ; } else { $args_printed ++; if ($first) { $first = 0; } else { print $OUTFD ", "; } if ($parm =~/\[/) { # Argument type is array, so we need to # a) place parameter correctly # Split into raw type and [] # Handle multidim arrays as well (Range_excl/incl) # Use \S* instead of the equivalent [^\s]*. # See ../f77/buildiface for an explanation if ($parm =~ /\s*(\S*)\s*(\[\s*\])(.*)/) { $basetype = $1; $foundbrack = $2; $extrabracks = $3; $otherdims = ""; } else { print STDERR "Internal error. Could not find basetype\n"; print STDERR "This may be a bug in perl in the handling of certain expressions\n"; } if ($extrabracks =~ /(\[[\d\s]*\])/) { $otherdims = $1; } print $OUTFD "$basetype v$count\[\]$otherdims"; } elsif ($parm =~ /\.\.\./) { # Special case for varargs. Only ints! print $OUTFD $parm; } else { # Convert C to C++ types $cxxtype = $parm; if ($cxxtype =~ /MPI_/) { $cxxtype =~ s/\*/\&/; } $cxxtype =~ s/MPI_//; print $OUTFD "${cxxtype} v$count"; } } $count++; } if ($args_printed == 0) { print $OUTFD "void"; } print $OUTFD " )";}# Count the number of parameters. Don't count MPI_xxx_IGNOREsub GetArgCount { my $args = $_[0]; # First, remove any special chars $args =~ s/,\s*%%\w*%%//g; my @parms = split(/\s*,\s*/,$args); return $#parms + 1;}# Print the arguments for the routine CALL. # Handle the special argumentssub print_call_args { my @parms = split(/\s*,\s*/, $_[1] ); my $OUTFD = $_[0]; my $class_type = $_[2]; # ?? my $arginfo = $_[3]; # Value of <class>_hash{routine)} my $count = 1; $first = 1; my $is_static = 0; if ($arginfo =~ /^static:/) { $is_static = 1; } print $OUTFD "( "; # Special case: if the only parm is "void", remove it from the list if ($#parms == 0 && $parms[0] eq "void") { $#parms = -1; } # class_pos is the position of the class variable in the argument list. # If specified by parm type, we must find it $class_pos = ""; if ($class_pos eq "" && !$is_static) { $class_pos = 1; foreach $parm (@parms) { if ($parm =~ /$class_type/) { last; } $class_pos++; } } my $lcclass = lc($fullclassname{$class}); my $shortclass = $class; # ??? FIXME my $lctopclass = $lcclass; # For derived classes, we sometimes need to know the name of the # top-most class, particularly for the "the_real_xxx" name. if (defined($mytopclass{$lcclass})) { $lctopclass = $mytopclass{$lcclass}; } print "$routine-$count\n" if $gDebug; foreach $parm (@parms) { if (!$first) { print $OUTFD ", "; } else { $first = 0; } # Special handling must preempt any other handling if (defined($funcArgMap{"${routine}-$count"}) || defined($funcArgMap{"${class}-${routine}-${count}"})) { &DoSpecialArgProcessing( $OUTFD, $routine, $count, "call" ); } elsif ($count == $return_parm_pos) { # We may need to pass the address of a temporary object # We'll unilateraly assume this for now # This must be first, so that it has a priority over the # class pos location. if ($parm =~ /MPI_/ && !($parm =~ /MPI_Offset/) && !($parm =~ /MPI_Aint/) ) { my $lctype = $real_return_type; # Convert class_type to the appropriate name $lctype = lc($lctype); if (defined($mytopclass{$lctype})) { $lctype = $mytopclass{$lctype}; } # Handle the MPIO_Request problem (temp until ROMIO uses # MPI_Requests) $cast = ""; if ($parm =~ /MPI_Request/ && $class eq "file") { $cast = "(MPIO_Request *)"; } print $OUTFD "$cast&(v$count.the_real_$lctype)"; } else { print $OUTFD "&v$count"; } } elsif ($count == $class_pos) { # Skip this arg in the definition if ($parm =~ /\*/) { print $OUTFD "($parm) &the_real_$lctopclass"; } else { print $OUTFD "($parm) the_real_$lctopclass"; } } elsif ($parm =~ /%%(.*)%%/) { print $OUTFD "$1"; } else { # Convert to/from object type as required. if (defined($argsneedcast{$parm})) { $argval = "v$count"; $callparm = $argsneedcast{$parm}; $callparm =~ s/ARG/$argval/; print $OUTFD &HandleObjectParm( $parm, $argval ); } else { print $OUTFD &HandleObjectParm( $parm, "v$count" ); } } $count++; } print $OUTFD " )";}# Print the option function attribute; this supports GCC, particularly # the __atribute__ weak option.sub print_attr { if ($do_weak) { print $OUTFD "FUNC_ATTRIBUTES\n"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -