X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e6e67305ecc66829721213aea23743f933b23b5d..f54458a7bb43175fc8e22322bf8b36dd5af06969:/src/smpi/smpif2c.in diff --git a/src/smpi/smpif2c.in b/src/smpi/smpif2c.in index 02330f352c..bdcbe867e2 100755 --- a/src/smpi/smpif2c.in +++ b/src/smpi/smpif2c.in @@ -16,6 +16,10 @@ foreach my $fortran (@ARGV) { die "F2C failed\n" if $?; open F2C,"<$output"; my $started = 0; + my $cutext = 0; + print $tmp "#ifndef INTEGER_STAR_8\n"; + print $tmp "#define INTEGER_STAR_8\n"; + print $tmp "#endif\n"; print $tmp "#include \n"; print $tmp "#include \n"; while() { @@ -25,20 +29,29 @@ foreach my $fortran (@ARGV) { } if($started) { if(/^} (.*?);/) { - $_ = "}* $1 = NULL;\n"; + $_ = "}* __attribute__((weak)) $1 = NULL;\n"; } elsif(/^#define\s*(\S*)\s*\(?([^.]*)(\..*?)?\)?$/) { - $_ = "#define $1 $2\[smpi_global_rank()\]"; + $_ = "#define $1 $2\[smpi_current_rank\]"; if(defined $3) { $_ .= $3; } $_ .= "\n"; - $_ .= "\nvoid __attribute__((constructor)) __preinit_$1(void) {\n if(!$2) $2 = malloc(smpi_global_size() * sizeof(*$2));\n}\n"; - $_ .= "\nvoid __attribute__((destructor)) __postfini_$1(void) {\n free($2);\n $2 = NULL;\n}\n"; + $_ .= "\nvoid __attribute__((weak,constructor)) __preinit_$1(void) {\n if(!$2) $2 = malloc(smpi_global_size() * sizeof(*$2));\n}\n"; + $_ .= "\nvoid __attribute__((weak,destructor)) __postfini_$1(void) {\n free($2);\n $2 = NULL;\n}\n"; } } if(/\/\* Table of constant values \*\// || /MAIN__/) { $started = 0; } + if(/extern \/\* Subroutine \*\//) { + $cutext = 1; + } + if($cutext) { + if(/;$/) { + $cutext = 0; + } + next; + } if(/\/* Main program alias \*\/\s*int\s+.*\s*\(\s*\)\s*{(.*)}/) { $_ = "int smpi_simulated_main(int argc, char** argv) { smpi_process_init(&argc, &argv); $1 }\n"; }