From b5eaacb9113f15ed517bdc3a4e5e28f577c5ca61 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 14 Sep 2015 15:11:43 -0500 Subject: [svn-r27775] Undo of r27655 Removes .pl extension from Perl scripts. This may be returned in the future, but it's best to keep the script names unchanged while we merge with the trunk. Tested on: h5committest --- MANIFEST | 26 +-- autogen.sh | 8 +- bin/bbrelease | 8 +- bin/checkapi | 67 +++++++ bin/checkapi.pl | 67 ------- bin/checkposix | 115 ++++++++++++ bin/checkposix.pl | 115 ------------ bin/cmakehdf5 | 2 +- bin/debug-ohdr | 40 ++++ bin/debug-ohdr.pl | 40 ---- bin/dependencies | 51 ++++++ bin/dependencies.pl | 51 ------ bin/distdep | 26 +++ bin/distdep.pl | 26 --- bin/errors | 140 ++++++++++++++ bin/errors.pl | 140 -------------- bin/h5vers | 446 +++++++++++++++++++++++++++++++++++++++++++++ bin/h5vers.pl | 446 --------------------------------------------- bin/iostats | 99 ++++++++++ bin/iostats.pl | 99 ---------- bin/make_err | 390 +++++++++++++++++++++++++++++++++++++++ bin/make_err.pl | 390 --------------------------------------- bin/make_overflow | 219 ++++++++++++++++++++++ bin/make_overflow.pl | 219 ---------------------- bin/make_vers | 505 +++++++++++++++++++++++++++++++++++++++++++++++++++ bin/make_vers.pl | 505 --------------------------------------------------- bin/release | 6 +- bin/snapshot | 4 +- bin/trace | 337 ++++++++++++++++++++++++++++++++++ bin/trace.pl | 337 ---------------------------------- 30 files changed, 2462 insertions(+), 2462 deletions(-) create mode 100755 bin/checkapi delete mode 100755 bin/checkapi.pl create mode 100755 bin/checkposix delete mode 100755 bin/checkposix.pl create mode 100755 bin/debug-ohdr delete mode 100755 bin/debug-ohdr.pl create mode 100755 bin/dependencies delete mode 100755 bin/dependencies.pl create mode 100755 bin/distdep delete mode 100755 bin/distdep.pl create mode 100755 bin/errors delete mode 100755 bin/errors.pl create mode 100755 bin/h5vers delete mode 100755 bin/h5vers.pl create mode 100755 bin/iostats delete mode 100755 bin/iostats.pl create mode 100755 bin/make_err delete mode 100755 bin/make_err.pl create mode 100755 bin/make_overflow delete mode 100755 bin/make_overflow.pl create mode 100755 bin/make_vers delete mode 100755 bin/make_vers.pl create mode 100755 bin/trace delete mode 100755 bin/trace.pl diff --git a/MANIFEST b/MANIFEST index 8810518..92b0b37 100644 --- a/MANIFEST +++ b/MANIFEST @@ -39,24 +39,24 @@ ./bin/COPYING ./bin/bbrelease _DO_NOT_DISTRIBUTE_ ./bin/buildhdf5 -./bin/checkapi.pl _DO_NOT_DISTRIBUTE_ -./bin/checkposix.pl _DO_NOT_DISTRIBUTE_ +./bin/checkapi _DO_NOT_DISTRIBUTE_ +./bin/checkposix _DO_NOT_DISTRIBUTE_ ./bin/chkconfigure _DO_NOT_DISTRIBUTE_ ./bin/chkcopyright _DO_NOT_DISTRIBUTE_ ./bin/chkmanifest ./bin/cmakehdf5 -./bin/debug-ohdr.pl _DO_NOT_DISTRIBUTE_ -./bin/dependencies.pl +./bin/debug-ohdr _DO_NOT_DISTRIBUTE_ +./bin/dependencies ./bin/deploy -./bin/distdep.pl -./bin/errors.pl _DO_NOT_DISTRIBUTE_ +./bin/distdep +./bin/errors _DO_NOT_DISTRIBUTE_ ./bin/gcov_script _DO_NOT_DISTRIBUTE_ -./bin/h5vers.pl -./bin/iostats.pl +./bin/h5vers +./bin/iostats ./bin/locate_sw -./bin/make_err.pl -./bin/make_overflow.pl -./bin/make_vers.pl +./bin/make_err +./bin/make_overflow +./bin/make_vers ./bin/makehelp ./bin/mkdirs ./bin/newer @@ -67,7 +67,7 @@ ./bin/snapshot ./bin/snapshot_version _DO_NOT_DISTRIBUTE_ ./bin/timekeeper _DO_NOT_DISTRIBUTE_ -./bin/trace.pl +./bin/trace ./bin/yodconfigure ./config/COPYING @@ -97,7 +97,7 @@ ./config/pgi-fflags ./config/pgi-flags ./config/powerpc-ibm-aix5.x -./config/solaris +./config/solaris2 ./config/x86_64-pc-cygwin ./config/site-specific/BlankForm diff --git a/autogen.sh b/autogen.sh index 2f5ee0e..5517c61 100755 --- a/autogen.sh +++ b/autogen.sh @@ -366,28 +366,28 @@ echo # have no effect on files that don't have HDF5 API macros in them. echo echo "Running trace script:" -bin/trace.pl src/H5*.c || exit 1 +bin/trace src/H5*.c || exit 1 # Run make_err # make_err automatically generates the H5E headers that create error message # types for HDF5. echo echo "Running error generation script:" -bin/make_err.pl src/H5err.txt || exit 1 +bin/make_err src/H5err.txt || exit 1 # Run make_vers # make_vers automatically generates the public headers that define the API version # macros for HDF5. echo echo "Running API version generation script:" -bin/make_vers.pl src/H5vers.txt || exit 1 +bin/make_vers src/H5vers.txt || exit 1 # Run make_overflow # make_overflow automatically generates macros for detecting overflows for type # conversion. echo echo "Running overflow macro generation script:" -bin/make_overflow.pl src/H5overflow.txt || exit 1 +bin/make_overflow src/H5overflow.txt || exit 1 # Run flex and bison # automatically generates hl/src/H5LTanalyze.c and hl/src/H5LTparse.c diff --git a/bin/bbrelease b/bin/bbrelease index a4f7ee0..1e3b88d 100755 --- a/bin/bbrelease +++ b/bin/bbrelease @@ -163,7 +163,7 @@ fi # Defaults DEST=releases -VERS=`perl bin/h5vers.pl` +VERS=`perl bin/h5vers` VERS_OLD= test "$VERS" || exit 1 verbose=yes @@ -183,7 +183,7 @@ RESTORE_VERSION() echo restoring version information back to $VERS_OLD rm -f config/lt_vers.am cp $tmpdir/lt_vers.am config/lt_vers.am - bin/h5vers.pl -s $VERS_OLD + bin/h5vers -s $VERS_OLD VERS_OLD= fi } @@ -252,7 +252,7 @@ if [ X$pmode = Xyes ]; then # (h5vers does not correctly handle just m.n.r-$today.) VERS=`echo $VERS | sed -e s/-.*//`-of$today echo Private release of $VERS - bin/h5vers.pl -s $VERS + bin/h5vers -s $VERS fi if [ X$revmode = Xyes ]; then @@ -266,7 +266,7 @@ if [ X$revmode = Xyes ]; then # (h5vers does not correctly handle just m.n.r-$today.) VERS=`echo $VERS | sed -e s/-.*//`-r$revision echo Private release of $VERS - bin/h5vers.pl -s $VERS + bin/h5vers -s $VERS HDF5_VERS=hdf5-$branch-r$revision # use a generic directory name for revision releases HDF5_IN_VERS=hdfsrc diff --git a/bin/checkapi b/bin/checkapi new file mode 100755 index 0000000..b4a08e8 --- /dev/null +++ b/bin/checkapi @@ -0,0 +1,67 @@ +#!/usr/bin/perl -w +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +require 5.003; + +# Purpose: insures that API functions aren't called internally. +# Usage: checkapi H5*.c +my $filename = ""; +my $lastname = ""; + +if(<>) { + while (<>) { + if($ARGV =~ /\//) { + ($filename) = ($ARGV =~ /^.*\/([A-Za-z0-9_]*)\.c$/); + } else { + ($filename) = ($ARGV =~ /([A-Za-z0-9_]*)\.c$/); + } + + if($filename =~ /H5FDmulti|H5FDstdio/) { + if($filename ne $lastname) { + print "$ARGV is exempt from checking\n"; + $lastname = $filename; + } + } else { + # Get rid of comments by removing the inside part. + s|/\*.*?\*/||g; + if ($in_comment) { + if (/\*\//) { + s|.*?\*/||; + $in_comment = 0; + } else { + $_="\n"; + } + } elsif (m|/\*|) { + s|/\*.*||; + $in_comment = 1; + } + + # Remove character strings + s/\\.//g; # remove escaped characters + s/\".*?\"//g; # remove string constants + + # Disregard the following hits + next if /^H5/; + next if /^\#/; + next if /FUNC_ENTER(_NOINIT)*/; + + next unless /(H5[A-Z]{1,2}[a-z]\w*)/; + print "$ARGV:$.: $1\n"; + } + } continue { + close ARGV if eof; # reset line number + } +} + diff --git a/bin/checkapi.pl b/bin/checkapi.pl deleted file mode 100755 index cc5b376..0000000 --- a/bin/checkapi.pl +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -require 5.003; - -# Purpose: insures that API functions aren't called internally. -# Usage: checkapi.pl H5*.c -my $filename = ""; -my $lastname = ""; - -if(<>) { - while (<>) { - if($ARGV =~ /\//) { - ($filename) = ($ARGV =~ /^.*\/([A-Za-z0-9_]*)\.c$/); - } else { - ($filename) = ($ARGV =~ /([A-Za-z0-9_]*)\.c$/); - } - - if($filename =~ /H5FDmulti|H5FDstdio/) { - if($filename ne $lastname) { - print "$ARGV is exempt from checking\n"; - $lastname = $filename; - } - } else { - # Get rid of comments by removing the inside part. - s|/\*.*?\*/||g; - if ($in_comment) { - if (/\*\//) { - s|.*?\*/||; - $in_comment = 0; - } else { - $_="\n"; - } - } elsif (m|/\*|) { - s|/\*.*||; - $in_comment = 1; - } - - # Remove character strings - s/\\.//g; # remove escaped characters - s/\".*?\"//g; # remove string constants - - # Disregard the following hits - next if /^H5/; - next if /^\#/; - next if /FUNC_ENTER(_NOINIT)*/; - - next unless /(H5[A-Z]{1,2}[a-z]\w*)/; - print "$ARGV:$.: $1\n"; - } - } continue { - close ARGV if eof; # reset line number - } -} - diff --git a/bin/checkposix b/bin/checkposix new file mode 100755 index 0000000..db47ff3 --- /dev/null +++ b/bin/checkposix @@ -0,0 +1,115 @@ +#!/usr/bin/perl -w +require 5.003; + +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Robb Matzke, matzke@llnl.gov +# 30 Aug 1997 +# +# Purpose: Given the names of C source files this script will print the +# file name, line number, and function name of any function that +# doesn't begin with the letter `h' or `H' as stipulated by the +# HDF5 programming style guide. +# +# Emacs users can run this script as the compile command and +# use `next-error' (usually bound to M-`) to find each name +# violation. + +if(<>) { + if($ARGV =~ /\//) { + ($filename) = ($ARGV =~ /^.*\/([A-Za-z0-9_]*)\.c$/); + } else { + ($filename) = ($ARGV =~ /([A-Za-z0-9_]*)\.c$/); + } + + if($filename =~ /H5FDmulti|H5FDstdio/) { + print "$ARGV is exempt from using Standard library macro wrappers\n"; + } else { + while (<>) { + + # Get rid of comments by removing the inside part. + s|/\*.*?\*/||g; + if ($in_comment) { + if (/\*\//) { + s|.*?\*/||; + $in_comment = 0; + } else { + $_="\n"; + } + } elsif (m|/\*|) { + s|/\*.*||; + $in_comment = 1; + } + + # Get rid of string constants if they begin and end on this line. + s/([\'\"])([^\1]|\\\1)*?\1/$1$1/g; + + # Get rid of preprocessor directives + s/^\#.*//; + + # Skip callbacks invoked as methods in a struct + next if $_ =~ /\b(\)?->|\.)\(?([a-z_A-Z]\w*)\s*\(/; + + # Now find all function calls on this line which don't start with 'H' + while (($name)=/\b([a-z_A-GI-Z]\w*)\s*\(/) { + $_ = $'; + + # Ignore C statements that look sort of like function + # calls. + next if $name =~ /^(if|for|offsetof|return|sizeof|switch|while|void)$/; + + # Ignore things that get misdetected because of the simplified + # parsing that takes place here. + next if $name =~ /^(int|herr_t|_term_interface)$/; + + # These are really HDF5 functions/macros even though they don't + # start with `h' or `H'. + next if $name =~ /^FUNC_(ENTER|LEAVE)(_(NO)?API|_PACKAGE|_STATIC)?(_NOFS|_NOCLEAR|_NOINIT)?(_NOFUNC|_TAG)?$/; + next if $name =~ /^(BEGIN|END)_FUNC$/; + next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)(_VAR)?$/; + next if $name =~ /^CI_(PRINT_STATS|INC_SRC|INC_DST)$/; + next if $name =~ /^(ABS|ADDR_OVERFLOW|ALL_MEMBERS|BOUND|CONSTR|DETECT_[I|F|M]|DOWN)$/; + next if $name =~ /^(MIN3?|MAX3?|NELMTS|POWER_OF_TWO|REGION_OVERFLOW)$/; + next if $name =~ /^(UNIQUE_MEMBERS)$/; + next if $name =~ /^addr_defined$/; + + # These functions/macros are exempt. + next if $name =~ /^(main|[fs]?printf|va_(start|arg|end))$/; + + # These are Windows system calls. Ignore them. + next if $name =~ /^(_get_osfhandle|GetFileInformationByHandle|SetFilePointer|GetLastError|SetEndOfFile)$/; + next if $name =~ /^(FindNextFile|FindClose|_tzset|Wgettimeofday|GetSystemTimeAsFileTime|Wgetlogin|GetUserName)$/; + + # These are MPI function calls. Ignore them. + next if $name =~ /^(MPI_|MPE_)/; + + # These are POSIX threads function calls. Ignore them. + next if $name =~ /^pthread_/; + + # These are Windows threads function calls. Ignore them. + next if $name =~ /^(_beginthread|(Initialize|Enter|Leave)CriticalSection|TlsAlloc)$/; + + # These are zlib & szlib function calls. Ignore them. + next if $name =~ /^(inflate|SZ_)/; + next if $name =~ /^compress2$/; + + print "$ARGV:$.: $name\n"; + } + + } continue { + close ARGV if eof; # reset line number + } + } +} diff --git a/bin/checkposix.pl b/bin/checkposix.pl deleted file mode 100755 index db47ff3..0000000 --- a/bin/checkposix.pl +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/perl -w -require 5.003; - -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -# Robb Matzke, matzke@llnl.gov -# 30 Aug 1997 -# -# Purpose: Given the names of C source files this script will print the -# file name, line number, and function name of any function that -# doesn't begin with the letter `h' or `H' as stipulated by the -# HDF5 programming style guide. -# -# Emacs users can run this script as the compile command and -# use `next-error' (usually bound to M-`) to find each name -# violation. - -if(<>) { - if($ARGV =~ /\//) { - ($filename) = ($ARGV =~ /^.*\/([A-Za-z0-9_]*)\.c$/); - } else { - ($filename) = ($ARGV =~ /([A-Za-z0-9_]*)\.c$/); - } - - if($filename =~ /H5FDmulti|H5FDstdio/) { - print "$ARGV is exempt from using Standard library macro wrappers\n"; - } else { - while (<>) { - - # Get rid of comments by removing the inside part. - s|/\*.*?\*/||g; - if ($in_comment) { - if (/\*\//) { - s|.*?\*/||; - $in_comment = 0; - } else { - $_="\n"; - } - } elsif (m|/\*|) { - s|/\*.*||; - $in_comment = 1; - } - - # Get rid of string constants if they begin and end on this line. - s/([\'\"])([^\1]|\\\1)*?\1/$1$1/g; - - # Get rid of preprocessor directives - s/^\#.*//; - - # Skip callbacks invoked as methods in a struct - next if $_ =~ /\b(\)?->|\.)\(?([a-z_A-Z]\w*)\s*\(/; - - # Now find all function calls on this line which don't start with 'H' - while (($name)=/\b([a-z_A-GI-Z]\w*)\s*\(/) { - $_ = $'; - - # Ignore C statements that look sort of like function - # calls. - next if $name =~ /^(if|for|offsetof|return|sizeof|switch|while|void)$/; - - # Ignore things that get misdetected because of the simplified - # parsing that takes place here. - next if $name =~ /^(int|herr_t|_term_interface)$/; - - # These are really HDF5 functions/macros even though they don't - # start with `h' or `H'. - next if $name =~ /^FUNC_(ENTER|LEAVE)(_(NO)?API|_PACKAGE|_STATIC)?(_NOFS|_NOCLEAR|_NOINIT)?(_NOFUNC|_TAG)?$/; - next if $name =~ /^(BEGIN|END)_FUNC$/; - next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)(_VAR)?$/; - next if $name =~ /^CI_(PRINT_STATS|INC_SRC|INC_DST)$/; - next if $name =~ /^(ABS|ADDR_OVERFLOW|ALL_MEMBERS|BOUND|CONSTR|DETECT_[I|F|M]|DOWN)$/; - next if $name =~ /^(MIN3?|MAX3?|NELMTS|POWER_OF_TWO|REGION_OVERFLOW)$/; - next if $name =~ /^(UNIQUE_MEMBERS)$/; - next if $name =~ /^addr_defined$/; - - # These functions/macros are exempt. - next if $name =~ /^(main|[fs]?printf|va_(start|arg|end))$/; - - # These are Windows system calls. Ignore them. - next if $name =~ /^(_get_osfhandle|GetFileInformationByHandle|SetFilePointer|GetLastError|SetEndOfFile)$/; - next if $name =~ /^(FindNextFile|FindClose|_tzset|Wgettimeofday|GetSystemTimeAsFileTime|Wgetlogin|GetUserName)$/; - - # These are MPI function calls. Ignore them. - next if $name =~ /^(MPI_|MPE_)/; - - # These are POSIX threads function calls. Ignore them. - next if $name =~ /^pthread_/; - - # These are Windows threads function calls. Ignore them. - next if $name =~ /^(_beginthread|(Initialize|Enter|Leave)CriticalSection|TlsAlloc)$/; - - # These are zlib & szlib function calls. Ignore them. - next if $name =~ /^(inflate|SZ_)/; - next if $name =~ /^compress2$/; - - print "$ARGV:$.: $name\n"; - } - - } continue { - close ARGV if eof; # reset line number - } - } -} diff --git a/bin/cmakehdf5 b/bin/cmakehdf5 index 753eb54..715d6d7 100755 --- a/bin/cmakehdf5 +++ b/bin/cmakehdf5 @@ -248,7 +248,7 @@ if [ ! -d $srcdir ]; then fi # figure out version information -vers=bin/h5vers.pl +vers=bin/h5vers if [ ! -x $srcdir/$vers ]; then echo $srcdir/$vers not found or not executable. Aborted. exit 1 diff --git a/bin/debug-ohdr b/bin/debug-ohdr new file mode 100755 index 0000000..170919a --- /dev/null +++ b/bin/debug-ohdr @@ -0,0 +1,40 @@ +#!/usr/bin/perl +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +require 5.003; + +# Looks for lines emitted by H5O_open() and H5O_close() and tries to +# determine which objects were not properly closed. + +while (<>) { + next unless /^([<>])(0x[\da-f]+|\d+)$/; + my ($op, $addr) = ($1, $2); + + if ($op eq ">") { + # Open object + $obj{$addr} += 1; + } else { + # Close object + die unless $obj{$addr}>0; + $obj{$addr} -= 1; + delete $obj{$addr} unless $obj{$addr}; + } +} + +for (sort keys %obj) { + printf "%3d %s\n", $obj{$_}, $_; +} + +exit 0; diff --git a/bin/debug-ohdr.pl b/bin/debug-ohdr.pl deleted file mode 100755 index 170919a..0000000 --- a/bin/debug-ohdr.pl +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/perl -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -require 5.003; - -# Looks for lines emitted by H5O_open() and H5O_close() and tries to -# determine which objects were not properly closed. - -while (<>) { - next unless /^([<>])(0x[\da-f]+|\d+)$/; - my ($op, $addr) = ($1, $2); - - if ($op eq ">") { - # Open object - $obj{$addr} += 1; - } else { - # Close object - die unless $obj{$addr}>0; - $obj{$addr} -= 1; - delete $obj{$addr} unless $obj{$addr}; - } -} - -for (sort keys %obj) { - printf "%3d %s\n", $obj{$_}, $_; -} - -exit 0; diff --git a/bin/dependencies b/bin/dependencies new file mode 100755 index 0000000..a82a3ee --- /dev/null +++ b/bin/dependencies @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +my $depend_file; +my $new_depend_file; +my $srcdir; +my $top_srcdir; +my $top_builddir; + +while ($_ = shift @ARGV) { + if (/^--top_srcdir=([^ \t\n]*)/) { + $top_srcdir = $1; + $top_srcdir =~ s/\+/\\\+/g; + $top_srcdir =~ s/\./\\\./g; + } elsif (/^--top_builddir=([^ \t\n]*)/) { + $top_builddir = $1; + $top_builddir =~ s/\+/\\\+/g; + $top_builddir =~ s/\./\\\./g; + } else { + $depend_file = $_; + $new_depend_file = "$_.new"; + last; + } +} + +open(DEPEND, "<$depend_file") || die "cannot open file $depend_file: $!\n"; +open(NEW, ">$new_depend_file") || die "cannot open file $new_depend_file: $!\n"; + +while () { + s/\.o(\b)/\.lo$1/g; + s/ $top_srcdir/ \$\(top_srcdir\)/g; + s/ $top_builddir/ \$\(top_builddir\)/g; + print NEW $_; +} + +close(DEPEND); +close(NEW); + +`mv $new_depend_file $depend_file`; diff --git a/bin/dependencies.pl b/bin/dependencies.pl deleted file mode 100755 index a82a3ee..0000000 --- a/bin/dependencies.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl -w -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -my $depend_file; -my $new_depend_file; -my $srcdir; -my $top_srcdir; -my $top_builddir; - -while ($_ = shift @ARGV) { - if (/^--top_srcdir=([^ \t\n]*)/) { - $top_srcdir = $1; - $top_srcdir =~ s/\+/\\\+/g; - $top_srcdir =~ s/\./\\\./g; - } elsif (/^--top_builddir=([^ \t\n]*)/) { - $top_builddir = $1; - $top_builddir =~ s/\+/\\\+/g; - $top_builddir =~ s/\./\\\./g; - } else { - $depend_file = $_; - $new_depend_file = "$_.new"; - last; - } -} - -open(DEPEND, "<$depend_file") || die "cannot open file $depend_file: $!\n"; -open(NEW, ">$new_depend_file") || die "cannot open file $new_depend_file: $!\n"; - -while () { - s/\.o(\b)/\.lo$1/g; - s/ $top_srcdir/ \$\(top_srcdir\)/g; - s/ $top_builddir/ \$\(top_builddir\)/g; - print NEW $_; -} - -close(DEPEND); -close(NEW); - -`mv $new_depend_file $depend_file`; diff --git a/bin/distdep b/bin/distdep new file mode 100755 index 0000000..0a22bd1 --- /dev/null +++ b/bin/distdep @@ -0,0 +1,26 @@ +#!/usr/bin/perl -p +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# Usage: $0 [<].depend + +# Takes dependency info and generates on stdout dependencies suitable for +# distribution by removing all the system include files from the list and +# removing all but the base name of other include files (since the Makefiles +# contain the logic for searching). + +($h,$_)=/\s*\\/?$h.$`:("",$h.$_); +s|( +/\S*)*( *)|$2?" \\\n ":""|eg; +#s|(([-\w\.]+)/)+([-\w\.]+)|\3|g; diff --git a/bin/distdep.pl b/bin/distdep.pl deleted file mode 100755 index 0a22bd1..0000000 --- a/bin/distdep.pl +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/perl -p -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# - -# Usage: $0 [<].depend - -# Takes dependency info and generates on stdout dependencies suitable for -# distribution by removing all the system include files from the list and -# removing all but the base name of other include files (since the Makefiles -# contain the logic for searching). - -($h,$_)=/\s*\\/?$h.$`:("",$h.$_); -s|( +/\S*)*( *)|$2?" \\\n ":""|eg; -#s|(([-\w\.]+)/)+([-\w\.]+)|\3|g; diff --git a/bin/errors b/bin/errors new file mode 100755 index 0000000..6ce997b --- /dev/null +++ b/bin/errors @@ -0,0 +1,140 @@ +#!/usr/local/bin/perl -w +require 5.003; +use Text::Tabs; + +# NOTE: THE FORMAT OF HRETURN_ERROR AND HGOTO_ERROR MACROS HAS +# CHANGED. THIS SCRIPT NO LONGER WORKS! --rpm + +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Robb Matzke, matzke@llnl.gov +# 30 Aug 1997 +# +# Purpose: This script will read standard input which should be a +# function prologue followed by a C function and will emit +# on standard output the same source code with the function +# prologue containing documentation for the various errors +# that occur in the function. +# +# Errors are raised by calling HGOTO_ERROR() or +# HRETURN_ERROR(). The reason for the error message is a +# comment which appears immediately after the error macro +# call and is contained entirely on one line: +# +# HRETURN_ERROR (...); /*entry not found*/ +# +# If such a comment doesn't exist, then the previous comment +# is used, subject to the constraint that raising an error +# clears the previous comment. +# +# /* Entry not found */ +# HGOTO_ERROR (...); +# +# Emacs users can use this script interactively with the +# c-mark-function and shell-command-on-region functions which +# are normally bound to M-C-h and M-|. + + +# Split STDIN into the prolog and the function body. Preserve leading +# white space. +$_ = join "", ; +my ($head, $prolog, $body) = (/^(\s*)(\/\*(.*?)\*\/)?(.*)/s)[0,2,3]; +$prolog = "" unless $prolog; + +# Find each error and the comment that goes with it. +for ($_=$body,$comment=""; /\/\*|H(RETURN|GOTO)_ERROR/s;) { + $_ = $&.$'; + + if (/^H(RETURN|GOTO)_ERROR\s*\(\s*H5E_(\w+)\s*,\s*H5E_(\w+)\s*,/s) { + ($major, $minor, $_) = ($2, $3, $'); + $comment=$1 if /^.*?\)\s*;\s*\/\*\s*(.*?)\s*\*\//; + $comment =~ s/^\s*\*+\s*/ /mg; # leading asterisks. + $comment =~ s/^\s+//s; # leading white space. + $comment =~ s/\s+$//s; # trailing white space. + $comment =~ s/(\w)$/$1./s; # punctuation. + $comment ||= "***NO COMMENT***"; + $errors{"$major\000$minor\000\u$comment"} = 1; + $comment = ""; + + } else { + ($comment) = /^\/\*\s*(.*?)\s*\*\//s; + $_ = $'; + } +} + + +# Format an error so it isn't too wide. +sub fmt_error ($) { + local ($_) = @_; + + my ($prefix,$space,$err) = /^((.*?)([A-Z_0-9]+\s+[A-Z_0-9]+\s+))/; + $_ = $'; + tr/\n / /s; + my $w = 70 - length expand $prefix; + s/(.{$w}\S+)\s+(\S)/$1."\n".$space.' 'x(length $err).$2/eg; + return $prefix . $_."\n"; +} + + + +# Sort the errors by major, then minor, then comment. Duplicate +# triplets have already been removed. +sub by_triplet { + my ($a_maj, $a_min, $a_com) = split /\000/, $a; + my ($b_maj, $b_min, $b_com) = split /\000/, $b; + $a_maj cmp $b_maj || $a_min cmp $b_min || $a_com cmp $b_com; +} +@errors = map {sprintf "%-9s %-13s %s\n", split /\000/} + sort by_triplet keys %errors; + + + +# Add the list of errors to the prologue depending on the type of +# prolog. +if (($front, $back) = $prolog=~/^(.*?Errors:\s*?(?=\n)).*?\n\s*\*\s*\n(.*)/s) { + #| * Errors: |# + #| * __list_of_error_messages__ (zero or more lines) |# + #| * |# + print $head, "/*", $front, "\n"; + map {print fmt_error " *\t\t".$_} @errors; + print " *\n", $back, "*/", $body; + +} elsif (($front,$back) = $prolog =~ + /(.*?\n\s*ERRORS:?\s*?(?=\n)).*?\n\s*\n(.*)/s) { + #| ERRORS |# + #| __list_of_error_messages__ (zero or more lines) |# + #| |# + print $head, "/*", $front, "\n"; + map {print fmt_error " ".$_} @errors; + print "\n", $back, "*/", $body; + +} elsif ($prolog eq "") { + # No prolog present. + print $head; + print " \n/*", "-"x73, "\n * Function:\t\n *\n * Purpose:\t\n *\n"; + print " * Errors:\n"; + map {print fmt_error " *\t\t".$_} @errors; + print " *\n * Return:\tSuccess:\t\n *\n *\t\tFailure:\t\n *\n"; + print " * Programmer:\t\n *\n * Modifications:\n *\n *", '-'x73, "\n"; + print " */\n", $body; + +} else { + # Prolog format not recognized. + print $head, "/*", $prolog, "*/\n\n"; + print "/*\n * Errors returned by this function...\n"; + map {print fmt_error " *\t".$_} @errors; + print " */\n", $body; +} + + diff --git a/bin/errors.pl b/bin/errors.pl deleted file mode 100755 index 6ce997b..0000000 --- a/bin/errors.pl +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/local/bin/perl -w -require 5.003; -use Text::Tabs; - -# NOTE: THE FORMAT OF HRETURN_ERROR AND HGOTO_ERROR MACROS HAS -# CHANGED. THIS SCRIPT NO LONGER WORKS! --rpm - -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -# Robb Matzke, matzke@llnl.gov -# 30 Aug 1997 -# -# Purpose: This script will read standard input which should be a -# function prologue followed by a C function and will emit -# on standard output the same source code with the function -# prologue containing documentation for the various errors -# that occur in the function. -# -# Errors are raised by calling HGOTO_ERROR() or -# HRETURN_ERROR(). The reason for the error message is a -# comment which appears immediately after the error macro -# call and is contained entirely on one line: -# -# HRETURN_ERROR (...); /*entry not found*/ -# -# If such a comment doesn't exist, then the previous comment -# is used, subject to the constraint that raising an error -# clears the previous comment. -# -# /* Entry not found */ -# HGOTO_ERROR (...); -# -# Emacs users can use this script interactively with the -# c-mark-function and shell-command-on-region functions which -# are normally bound to M-C-h and M-|. - - -# Split STDIN into the prolog and the function body. Preserve leading -# white space. -$_ = join "", ; -my ($head, $prolog, $body) = (/^(\s*)(\/\*(.*?)\*\/)?(.*)/s)[0,2,3]; -$prolog = "" unless $prolog; - -# Find each error and the comment that goes with it. -for ($_=$body,$comment=""; /\/\*|H(RETURN|GOTO)_ERROR/s;) { - $_ = $&.$'; - - if (/^H(RETURN|GOTO)_ERROR\s*\(\s*H5E_(\w+)\s*,\s*H5E_(\w+)\s*,/s) { - ($major, $minor, $_) = ($2, $3, $'); - $comment=$1 if /^.*?\)\s*;\s*\/\*\s*(.*?)\s*\*\//; - $comment =~ s/^\s*\*+\s*/ /mg; # leading asterisks. - $comment =~ s/^\s+//s; # leading white space. - $comment =~ s/\s+$//s; # trailing white space. - $comment =~ s/(\w)$/$1./s; # punctuation. - $comment ||= "***NO COMMENT***"; - $errors{"$major\000$minor\000\u$comment"} = 1; - $comment = ""; - - } else { - ($comment) = /^\/\*\s*(.*?)\s*\*\//s; - $_ = $'; - } -} - - -# Format an error so it isn't too wide. -sub fmt_error ($) { - local ($_) = @_; - - my ($prefix,$space,$err) = /^((.*?)([A-Z_0-9]+\s+[A-Z_0-9]+\s+))/; - $_ = $'; - tr/\n / /s; - my $w = 70 - length expand $prefix; - s/(.{$w}\S+)\s+(\S)/$1."\n".$space.' 'x(length $err).$2/eg; - return $prefix . $_."\n"; -} - - - -# Sort the errors by major, then minor, then comment. Duplicate -# triplets have already been removed. -sub by_triplet { - my ($a_maj, $a_min, $a_com) = split /\000/, $a; - my ($b_maj, $b_min, $b_com) = split /\000/, $b; - $a_maj cmp $b_maj || $a_min cmp $b_min || $a_com cmp $b_com; -} -@errors = map {sprintf "%-9s %-13s %s\n", split /\000/} - sort by_triplet keys %errors; - - - -# Add the list of errors to the prologue depending on the type of -# prolog. -if (($front, $back) = $prolog=~/^(.*?Errors:\s*?(?=\n)).*?\n\s*\*\s*\n(.*)/s) { - #| * Errors: |# - #| * __list_of_error_messages__ (zero or more lines) |# - #| * |# - print $head, "/*", $front, "\n"; - map {print fmt_error " *\t\t".$_} @errors; - print " *\n", $back, "*/", $body; - -} elsif (($front,$back) = $prolog =~ - /(.*?\n\s*ERRORS:?\s*?(?=\n)).*?\n\s*\n(.*)/s) { - #| ERRORS |# - #| __list_of_error_messages__ (zero or more lines) |# - #| |# - print $head, "/*", $front, "\n"; - map {print fmt_error " ".$_} @errors; - print "\n", $back, "*/", $body; - -} elsif ($prolog eq "") { - # No prolog present. - print $head; - print " \n/*", "-"x73, "\n * Function:\t\n *\n * Purpose:\t\n *\n"; - print " * Errors:\n"; - map {print fmt_error " *\t\t".$_} @errors; - print " *\n * Return:\tSuccess:\t\n *\n *\t\tFailure:\t\n *\n"; - print " * Programmer:\t\n *\n * Modifications:\n *\n *", '-'x73, "\n"; - print " */\n", $body; - -} else { - # Prolog format not recognized. - print $head, "/*", $prolog, "*/\n\n"; - print "/*\n * Errors returned by this function...\n"; - map {print fmt_error " *\t".$_} @errors; - print " */\n", $body; -} - - diff --git a/bin/h5vers b/bin/h5vers new file mode 100755 index 0000000..2fe9105 --- /dev/null +++ b/bin/h5vers @@ -0,0 +1,446 @@ +#! /bin/sh +perl -x -S $0 "$@" +exit + +#! perl +require 5.003; +use strict; + +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Robb Matzke +# 17 July 1998 + +### Purpose +# Increments the hdf5 version number by changing the value of +# constants in the src/H5public.h file. The new version number is +# printed on the standard output. An alternate source file name can be +# specified as an argument. In any case, the original file is saved +# by appending a tilde `~' to the name. + +### Usage: +# h5vers [OPTIONS] [FILE] + +# Without options this program only displays the current version and +# doesn't modify any files or create backups. The default is to print +# the version number like X.Y.Z-A where X is the major version number, +# Y is the minor version number, Z is the release number, and A is +# a short annotation string (the `-' is printed only if A is not empty). +# If the `-v' switch is given the version will be printed like: +# +# version X.Y release Z (A) +# +# The space and parentheses around A are only printed if A is not empty. +# +# The `-s VERSION' switch will set the version as specified. If the +# string contains a dotted triple then it will be used as the version +# number, otherwise up to three numbers will be read from the end of +# the string and used as the major version, minor version, and release +# number. If any numbers are missing then zero is assumed. This +# allows versions to be specified like `-s "version 2.1 release 8"' or +# `-s hdf5-2.1.8.tar.bz2'. If the new version is less than the old +# version then a warning message is generated on standard error. The +# annotation string, A, is set only if it appears immediately after the +# third number, separated by a dash (e.g., `1.2.3-pre1') or in parentheses +# (e.g., `version 1.2 release 3 (pre1)'). +# +# The `-i [major|minor|release|annot|last]' option increments the major +# number, minor number, release number, or annotation string. The `last' +# switch increments the annotation string if present, otherwise the +# release number. If the release number is incremented then the annotation +# string is cleared. If the minor number is incremented then the release +# number is set to zero and the annotation string is cleared; if the major +# number is incremented then the minor and release numbers are set to zero +# and the annotation string is cleared. +# +# If a file is specified then that file is used instead of +# ./H5public.h or ./src/H5public.h. +# +# If the version number is changed (either `-s' or `-i' was used on +# the command line) then the first line of the README.txt and RELEASE.txt files +# one directory above the H5public.h file is also modified so it looks +# something like: This is hdf5-1.2.3-pre1 currently under development. +# The AC_INIT macro in configure.ac will also change in this case to be +# something like: AC_INIT([HDF5], [hdf5-1.2.3-pre1], [help@hdfgroup.org]) +# Version changes are also reflected in the Windows-maintained H5pubconf.h +# file. +# +# Whenever the version changes, this script will increment the revision +# field in HDF5's libtool shared library version in config/lt_vers.am, +# which is included in src/Makefile.am. Incrementing the revision field +# indicates that the source code has changed since the last version +# (which it probably has). +############################################################################## + +sub getvers { + local ($_) = @_; + my (@vers); + + ($vers[0]) = /^\#\s*define\s+H5_VERS_MAJOR\s+(\d+)/m; + ($vers[1]) = /^\#\s*define\s+H5_VERS_MINOR\s+(\d+)/m; + ($vers[2]) = /^\#\s*define\s+H5_VERS_RELEASE\s+(\d+)/m; + ($vers[3]) = /^\#\s*define\s+H5_VERS_SUBRELEASE\s+\"([^\"]*)\"/m; + return @vers; +} + +sub setvers { + my ($contents, @vers) = @_; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_MAJOR\s+)\d+/$1$vers[0]/m; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_MINOR\s+)\d+/$1$vers[1]/m; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_RELEASE\s+)\d+/$1$vers[2]/m; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_SUBRELEASE\s+\")[^\"]*/$1$vers[3]/m; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_INFO\s+\")[^\"]*/ + sprintf("%sHDF5 library version: %d.%d.%d%s%s", $1, @vers[0,1,2], + $vers[3]?"-":"", $vers[3])/me; +} + +sub usage { + my ($prog) = $0 =~ /([^\/]+)$/; + print STDERR <; +close FILE; +my (@curver) = getvers $contents; + +# Determine the new version number. +my @newver; #new version +if ($set) { + if ($set =~ /(\d+)\.(\d+)\.(\d+)(-([a-zA-Z]\w*))?/) { + @newver = ($1, $2, $3, $5); + } elsif ($set =~ /(\d+)\D+(\d+)\D+(\d+)(\s*\(([a-zA-Z]\w*)\))?\D*$/) { + @newver = ($1, $2, $3, $5); + } elsif ($set =~ /(\d+)\D+(\d+)\D*$/) { + @newver = ($1, $2, 0, ""); + } elsif ($set =~ /(\d+)\D*$/) { + @newver = ($1, 0, 0, ""); + } else { + die "illegal version number specified: $set\n"; + } +} elsif ($inc) { + $inc = $curver[3] eq "" ? 'release' : 'annot' if $inc eq 'last'; + if ($inc eq "major") { + $newver[0] = $curver[0]+1; + @newver[1,2,3] = (0,0,""); + } elsif ($inc eq "minor") { + $newver[0] = $curver[0]; + $newver[1] = $curver[1]+1; + @newver[2,3] = (0,""); + } elsif ($inc eq "release") { + @newver[0,1] = @curver[0,1]; + $newver[2] = $curver[2]+1; + $newver[3] = ""; + } elsif ($inc eq "annot") { + @newver[0,1,2] = @curver[0,1,2]; + $newver[3] = $curver[3]; + $newver[3] =~ s/(\d+)\D*$/$1+1/e or + die "Annotation \"".$newver[3]."\" cannot be incremented.\n"; + } else { + die "unknown increment field: $inc\n"; + } +} else { + # Nothing to do but print result + $README = ""; + $RELEASE = ""; + $CONFIGURE = ""; + $CPP_DOC_CONFIG = ""; + $LT_VERS = ""; + @newver = @curver; +} + +# Note if the version increased or decreased +my $version_increased=""; +# Print a warning if the version got smaller (don't check annot field) +if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] < + $curver[0]*1000000 + $curver[1]*1000 + $curver[2]) { + printf STDERR "Warning: version decreased from %d.%d.%d to %d.%d.%d\n", + @curver[0,1,2], @newver[0,1,2]; +} +if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] > + $curver[0]*1000000 + $curver[1]*1000 + $curver[2]) { + $version_increased="true"; +} + +# Update the version number if it changed. +if ($newver[0]!=$curver[0] || + $newver[1]!=$curver[1] || + $newver[2]!=$curver[2] || + $newver[3]ne$curver[3]) { + setvers $contents, @newver or die "unable to set version\n"; + rename $file, "$file~" or die "unable to save backup file\n"; + open FILE, ">$file" or die "unable to open $file but backup saved!\n"; + print FILE $contents; + close FILE; +} + +# Update the libtool shared library version in src/Makefile.am if +# the version number has increased. +if ($LT_VERS && $version_increased) { + open FILE, $LT_VERS or die "$LT_VERS: $!\n"; + my ($contentsy) = join "", ; + close FILE; + + local($_) = $contentsy; + + my ($lt_revision) = /^LT_VERS_REVISION\s*=\s*(\d+)/m; + my $new_lt_revision = $lt_revision+1; + ($contentsy) =~ s/^(LT_VERS_REVISION\s*=\s*)\d+/$1$new_lt_revision/m; + + open FILE, ">$LT_VERS" or die "$LT_VERS: $!\n"; + print FILE $contentsy; + close FILE; +} + +# Update the README.txt file +if ($README) { + open FILE, $README or die "$README: $!\n"; + my @contents = ; + close FILE; + $contents[0] = sprintf("HDF5 version %d.%d.%d%s %s", + @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3], + "currently under development\n"); + open FILE, ">$README" or die "$README: $!\n"; + print FILE @contents; + close FILE; +} + +# Update the release_docs/RELEASE.txt file +if ($RELEASE) { + open FILE, $RELEASE or die "$RELEASE: $!\n"; + my @contents = ; + close FILE; + $contents[0] = sprintf("HDF5 version %d.%d.%d%s %s", + @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3], + "currently under development\n"); + open FILE, ">$RELEASE" or die "$RELEASE: $!\n"; + print FILE @contents; + close FILE; +} + +# Update the c++/src/cpp_doc_config file +if ($CPP_DOC_CONFIG) { + my $data = read_file($CPP_DOC_CONFIG); + my $version_string = sprintf("\"%d.%d.%d%s %s\"", + @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3], + "currently under development"); + + $data =~ s/PROJECT_NUMBER\s*=.*/PROJECT_NUMBER = $version_string/; + + write_file($CPP_DOC_CONFIG, $data); +} + +# helper function to read the file for updating c++/src/cpp_doc_config file. +# The version string in that file is not at the top, so the string replacement +# is not for the first line, and reading/writing the entire file as one string +# facilitates the substring replacement. +sub read_file { + my ($filename) = @_; + + open my $in, $filename or die "Could not open '$filename' for reading $!"; + local $/ = undef; + my $all = <$in>; + close $in; + + return $all; +} + +# helper function to write the file for updating c++/src/cpp_doc_config file. +sub write_file { + my ($filename, $content) = @_; + + open my $out, ">$filename" or die "Could not open '$filename' for writing $!";; + print $out $content; + close $out; + + return; +} + + +sub gen_configure { + my ($name, $conf) = @_; + + open FILE, $conf or die "$conf: $!\n"; + my @contents = ; + close FILE; + + for (my $i = 0; $i < $#contents; ++$i) { + if ($contents[$i] =~ /^AC_INIT/) { + $contents[$i] = sprintf("AC_INIT([$name], [%d.%d.%d%s], [help\@hdfgroup.org])\n", + @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3]); + last; + } + } + + open FILE, ">$conf" or die "$conf: $!\n"; + print FILE @contents; + close FILE; + + $conf =~ /^(.*?)\/?configure.ac$/; + + if ($1) { + $rc = system("cd $1 && bin/reconfigure >/dev/null 2>/dev/null && rm -rf autom4te.cache"); + } else { + $rc = system("bin/reconfigure >/dev/null 2>/dev/null && rm -rf autom4te.cache"); + } + if ($rc) { + printf("bin/reconfigure failed with exit code %d. Aborted.\n", $rc); + exit 1; + } +} + +# Update the configure.ac files and regenerate them +gen_configure("HDF5", $CONFIGURE) if $CONFIGURE; + +sub gen_h5pubconf { + my ($name, $pubconf, @vers) = @_; + + my $namelc = lc($name); + my $nameuc = uc($name); + + open FILE, $pubconf or die "$pubconf: $!\n"; + my @contents = ; + close FILE; + + for (my $i = 0; $i < $#contents; ++$i) { + if ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE\s+/) { + $contents[$i] = "\#define H5_PACKAGE \"$namelc\"\n"; + } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_NAME\s+/) { + $contents[$i] = "\#define H5_PACKAGE_NAME \"$nameuc\"\n"; + } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_STRING\s+/) { + $contents[$i] = sprintf("\#define H5_PACKAGE_STRING \"$nameuc %d.%d.%d%s\"\n", + @vers[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3]); + } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_TARNAME\s+/) { + $contents[$i] = "\#define H5_PACKAGE_TARNAME \"$namelc\"\n"; + } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_VERSION\s+/) { + $contents[$i] = sprintf("\#define H5_PACKAGE_VERSION \"%d.%d.%d%s\"\n", + @vers[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3]); + } elsif ($contents[$i] =~ /\#\s*define\s+H5_VERSION\s+/) { + $contents[$i] = sprintf("\#define H5_VERSION \"%d.%d.%d%s\"\n", + @vers[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3]); + } + } + + open FILE, ">$pubconf" or die "$pubconf: $!\n"; + print FILE @contents; + close FILE; +} + +# Print the new version number +if ($verbose) { + printf("version %d.%d release %d%s\n", @newver[0,1,2], + $newver[3] eq "" ? "" : " (".$newver[3].")"); +} else { + printf("%d.%d.%d%s\n", @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3]); +} + +exit 0; + +# Because the first line of this file looks like a Bourne shell script, we +# must tell XEmacs explicitly that this is really a perl script. +# +# Local Variables: +# mode:perl +# End: diff --git a/bin/h5vers.pl b/bin/h5vers.pl deleted file mode 100755 index 18c5854..0000000 --- a/bin/h5vers.pl +++ /dev/null @@ -1,446 +0,0 @@ -#! /bin/sh -perl -x -S $0 "$@" -exit - -#! perl -require 5.003; -use strict; - -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -# Robb Matzke -# 17 July 1998 - -### Purpose -# Increments the hdf5 version number by changing the value of -# constants in the src/H5public.h file. The new version number is -# printed on the standard output. An alternate source file name can be -# specified as an argument. In any case, the original file is saved -# by appending a tilde `~' to the name. - -### Usage: -# h5vers.pl [OPTIONS] [FILE] - -# Without options this program only displays the current version and -# doesn't modify any files or create backups. The default is to print -# the version number like X.Y.Z-A where X is the major version number, -# Y is the minor version number, Z is the release number, and A is -# a short annotation string (the `-' is printed only if A is not empty). -# If the `-v' switch is given the version will be printed like: -# -# version X.Y release Z (A) -# -# The space and parentheses around A are only printed if A is not empty. -# -# The `-s VERSION' switch will set the version as specified. If the -# string contains a dotted triple then it will be used as the version -# number, otherwise up to three numbers will be read from the end of -# the string and used as the major version, minor version, and release -# number. If any numbers are missing then zero is assumed. This -# allows versions to be specified like `-s "version 2.1 release 8"' or -# `-s hdf5-2.1.8.tar.bz2'. If the new version is less than the old -# version then a warning message is generated on standard error. The -# annotation string, A, is set only if it appears immediately after the -# third number, separated by a dash (e.g., `1.2.3-pre1') or in parentheses -# (e.g., `version 1.2 release 3 (pre1)'). -# -# The `-i [major|minor|release|annot|last]' option increments the major -# number, minor number, release number, or annotation string. The `last' -# switch increments the annotation string if present, otherwise the -# release number. If the release number is incremented then the annotation -# string is cleared. If the minor number is incremented then the release -# number is set to zero and the annotation string is cleared; if the major -# number is incremented then the minor and release numbers are set to zero -# and the annotation string is cleared. -# -# If a file is specified then that file is used instead of -# ./H5public.h or ./src/H5public.h. -# -# If the version number is changed (either `-s' or `-i' was used on -# the command line) then the first line of the README.txt and RELEASE.txt files -# one directory above the H5public.h file is also modified so it looks -# something like: This is hdf5-1.2.3-pre1 currently under development. -# The AC_INIT macro in configure.ac will also change in this case to be -# something like: AC_INIT([HDF5], [hdf5-1.2.3-pre1], [help@hdfgroup.org]) -# Version changes are also reflected in the Windows-maintained H5pubconf.h -# file. -# -# Whenever the version changes, this script will increment the revision -# field in HDF5's libtool shared library version in config/lt_vers.am, -# which is included in src/Makefile.am. Incrementing the revision field -# indicates that the source code has changed since the last version -# (which it probably has). -############################################################################## - -sub getvers { - local ($_) = @_; - my (@vers); - - ($vers[0]) = /^\#\s*define\s+H5_VERS_MAJOR\s+(\d+)/m; - ($vers[1]) = /^\#\s*define\s+H5_VERS_MINOR\s+(\d+)/m; - ($vers[2]) = /^\#\s*define\s+H5_VERS_RELEASE\s+(\d+)/m; - ($vers[3]) = /^\#\s*define\s+H5_VERS_SUBRELEASE\s+\"([^\"]*)\"/m; - return @vers; -} - -sub setvers { - my ($contents, @vers) = @_; - $_[0] =~ s/^(\#\s*define\s+H5_VERS_MAJOR\s+)\d+/$1$vers[0]/m; - $_[0] =~ s/^(\#\s*define\s+H5_VERS_MINOR\s+)\d+/$1$vers[1]/m; - $_[0] =~ s/^(\#\s*define\s+H5_VERS_RELEASE\s+)\d+/$1$vers[2]/m; - $_[0] =~ s/^(\#\s*define\s+H5_VERS_SUBRELEASE\s+\")[^\"]*/$1$vers[3]/m; - $_[0] =~ s/^(\#\s*define\s+H5_VERS_INFO\s+\")[^\"]*/ - sprintf("%sHDF5 library version: %d.%d.%d%s%s", $1, @vers[0,1,2], - $vers[3]?"-":"", $vers[3])/me; -} - -sub usage { - my ($prog) = $0 =~ /([^\/]+)$/; - print STDERR <; -close FILE; -my (@curver) = getvers $contents; - -# Determine the new version number. -my @newver; #new version -if ($set) { - if ($set =~ /(\d+)\.(\d+)\.(\d+)(-([a-zA-Z]\w*))?/) { - @newver = ($1, $2, $3, $5); - } elsif ($set =~ /(\d+)\D+(\d+)\D+(\d+)(\s*\(([a-zA-Z]\w*)\))?\D*$/) { - @newver = ($1, $2, $3, $5); - } elsif ($set =~ /(\d+)\D+(\d+)\D*$/) { - @newver = ($1, $2, 0, ""); - } elsif ($set =~ /(\d+)\D*$/) { - @newver = ($1, 0, 0, ""); - } else { - die "illegal version number specified: $set\n"; - } -} elsif ($inc) { - $inc = $curver[3] eq "" ? 'release' : 'annot' if $inc eq 'last'; - if ($inc eq "major") { - $newver[0] = $curver[0]+1; - @newver[1,2,3] = (0,0,""); - } elsif ($inc eq "minor") { - $newver[0] = $curver[0]; - $newver[1] = $curver[1]+1; - @newver[2,3] = (0,""); - } elsif ($inc eq "release") { - @newver[0,1] = @curver[0,1]; - $newver[2] = $curver[2]+1; - $newver[3] = ""; - } elsif ($inc eq "annot") { - @newver[0,1,2] = @curver[0,1,2]; - $newver[3] = $curver[3]; - $newver[3] =~ s/(\d+)\D*$/$1+1/e or - die "Annotation \"".$newver[3]."\" cannot be incremented.\n"; - } else { - die "unknown increment field: $inc\n"; - } -} else { - # Nothing to do but print result - $README = ""; - $RELEASE = ""; - $CONFIGURE = ""; - $CPP_DOC_CONFIG = ""; - $LT_VERS = ""; - @newver = @curver; -} - -# Note if the version increased or decreased -my $version_increased=""; -# Print a warning if the version got smaller (don't check annot field) -if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] < - $curver[0]*1000000 + $curver[1]*1000 + $curver[2]) { - printf STDERR "Warning: version decreased from %d.%d.%d to %d.%d.%d\n", - @curver[0,1,2], @newver[0,1,2]; -} -if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] > - $curver[0]*1000000 + $curver[1]*1000 + $curver[2]) { - $version_increased="true"; -} - -# Update the version number if it changed. -if ($newver[0]!=$curver[0] || - $newver[1]!=$curver[1] || - $newver[2]!=$curver[2] || - $newver[3]ne$curver[3]) { - setvers $contents, @newver or die "unable to set version\n"; - rename $file, "$file~" or die "unable to save backup file\n"; - open FILE, ">$file" or die "unable to open $file but backup saved!\n"; - print FILE $contents; - close FILE; -} - -# Update the libtool shared library version in src/Makefile.am if -# the version number has increased. -if ($LT_VERS && $version_increased) { - open FILE, $LT_VERS or die "$LT_VERS: $!\n"; - my ($contentsy) = join "", ; - close FILE; - - local($_) = $contentsy; - - my ($lt_revision) = /^LT_VERS_REVISION\s*=\s*(\d+)/m; - my $new_lt_revision = $lt_revision+1; - ($contentsy) =~ s/^(LT_VERS_REVISION\s*=\s*)\d+/$1$new_lt_revision/m; - - open FILE, ">$LT_VERS" or die "$LT_VERS: $!\n"; - print FILE $contentsy; - close FILE; -} - -# Update the README.txt file -if ($README) { - open FILE, $README or die "$README: $!\n"; - my @contents = ; - close FILE; - $contents[0] = sprintf("HDF5 version %d.%d.%d%s %s", - @newver[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3], - "currently under development\n"); - open FILE, ">$README" or die "$README: $!\n"; - print FILE @contents; - close FILE; -} - -# Update the release_docs/RELEASE.txt file -if ($RELEASE) { - open FILE, $RELEASE or die "$RELEASE: $!\n"; - my @contents = ; - close FILE; - $contents[0] = sprintf("HDF5 version %d.%d.%d%s %s", - @newver[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3], - "currently under development\n"); - open FILE, ">$RELEASE" or die "$RELEASE: $!\n"; - print FILE @contents; - close FILE; -} - -# Update the c++/src/cpp_doc_config file -if ($CPP_DOC_CONFIG) { - my $data = read_file($CPP_DOC_CONFIG); - my $version_string = sprintf("\"%d.%d.%d%s %s\"", - @newver[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3], - "currently under development"); - - $data =~ s/PROJECT_NUMBER\s*=.*/PROJECT_NUMBER = $version_string/; - - write_file($CPP_DOC_CONFIG, $data); -} - -# helper function to read the file for updating c++/src/cpp_doc_config file. -# The version string in that file is not at the top, so the string replacement -# is not for the first line, and reading/writing the entire file as one string -# facilitates the substring replacement. -sub read_file { - my ($filename) = @_; - - open my $in, $filename or die "Could not open '$filename' for reading $!"; - local $/ = undef; - my $all = <$in>; - close $in; - - return $all; -} - -# helper function to write the file for updating c++/src/cpp_doc_config file. -sub write_file { - my ($filename, $content) = @_; - - open my $out, ">$filename" or die "Could not open '$filename' for writing $!";; - print $out $content; - close $out; - - return; -} - - -sub gen_configure { - my ($name, $conf) = @_; - - open FILE, $conf or die "$conf: $!\n"; - my @contents = ; - close FILE; - - for (my $i = 0; $i < $#contents; ++$i) { - if ($contents[$i] =~ /^AC_INIT/) { - $contents[$i] = sprintf("AC_INIT([$name], [%d.%d.%d%s], [help\@hdfgroup.org])\n", - @newver[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3]); - last; - } - } - - open FILE, ">$conf" or die "$conf: $!\n"; - print FILE @contents; - close FILE; - - $conf =~ /^(.*?)\/?configure.ac$/; - - if ($1) { - $rc = system("cd $1 && bin/reconfigure >/dev/null 2>/dev/null && rm -rf autom4te.cache"); - } else { - $rc = system("bin/reconfigure >/dev/null 2>/dev/null && rm -rf autom4te.cache"); - } - if ($rc) { - printf("bin/reconfigure failed with exit code %d. Aborted.\n", $rc); - exit 1; - } -} - -# Update the configure.ac files and regenerate them -gen_configure("HDF5", $CONFIGURE) if $CONFIGURE; - -sub gen_h5pubconf { - my ($name, $pubconf, @vers) = @_; - - my $namelc = lc($name); - my $nameuc = uc($name); - - open FILE, $pubconf or die "$pubconf: $!\n"; - my @contents = ; - close FILE; - - for (my $i = 0; $i < $#contents; ++$i) { - if ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE\s+/) { - $contents[$i] = "\#define H5_PACKAGE \"$namelc\"\n"; - } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_NAME\s+/) { - $contents[$i] = "\#define H5_PACKAGE_NAME \"$nameuc\"\n"; - } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_STRING\s+/) { - $contents[$i] = sprintf("\#define H5_PACKAGE_STRING \"$nameuc %d.%d.%d%s\"\n", - @vers[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3]); - } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_TARNAME\s+/) { - $contents[$i] = "\#define H5_PACKAGE_TARNAME \"$namelc\"\n"; - } elsif ($contents[$i] =~ /\#\s*define\s+H5_PACKAGE_VERSION\s+/) { - $contents[$i] = sprintf("\#define H5_PACKAGE_VERSION \"%d.%d.%d%s\"\n", - @vers[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3]); - } elsif ($contents[$i] =~ /\#\s*define\s+H5_VERSION\s+/) { - $contents[$i] = sprintf("\#define H5_VERSION \"%d.%d.%d%s\"\n", - @vers[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3]); - } - } - - open FILE, ">$pubconf" or die "$pubconf: $!\n"; - print FILE @contents; - close FILE; -} - -# Print the new version number -if ($verbose) { - printf("version %d.%d release %d%s\n", @newver[0,1,2], - $newver[3] eq "" ? "" : " (".$newver[3].")"); -} else { - printf("%d.%d.%d%s\n", @newver[0,1,2], - $newver[3] eq "" ? "" : "-".$newver[3]); -} - -exit 0; - -# Because the first line of this file looks like a Bourne shell script, we -# must tell XEmacs explicitly that this is really a perl script. -# -# Local Variables: -# mode:perl -# End: diff --git a/bin/iostats b/bin/iostats new file mode 100755 index 0000000..f57c0d0 --- /dev/null +++ b/bin/iostats @@ -0,0 +1,99 @@ +#!/usr/bin/perl +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# Usage: pipe the output of Linux's `strace' program into the stdin of +# this command, and the output of this command into gnuplot. + +my ($fast,$npasses); +if ($ARGV[0] =~ /^--?fast$/) { + $fast = 1; + shift; +} + +my $filename = shift || "tstab2.h5"; +my $total = 0; +my %What; # What{pos}{nbytes}{r|w} = naccesses +my($total_writes, $total_bytes_out, $total_reads, $total_bytes_in); + +while (<>) { + if (!defined $fd) { + if (/^open\("(.*?)".*=\s+(\d+)/ && $1 eq $filename) { + $fd = $2; + $pos = 0; + } + } elsif (/^close\((\d+)/ && $1==$fd) { + $fd = undef; + } elsif (!$fast && + /^lseek\((\d+), -?\d+,.*= (\d+)/ && + $1==$fd && $2>=0) { + $pos = $2; + } elsif (!$fast && /^lseek\((\d+),/ && $1==$fd) { + die $_; + } elsif (/^write\((\d+), ".*?"(\.\.\.)?, \d+\)\s*= (\d+)/ && + $1==$fd && $3>=0) { + my $nbytes = $3; + if ($fast) { + $total_writes++; + $total_bytes_out += $nbytes; + } else { + $What{$pos}{$nbytes}{w}++; + printf "%d %d\n", $total, $pos; + $pos += $nbytes; + $total += $nbytes; + } + } elsif (/^write\((\d+),/ && $1==$fd) { + die $_; + } elsif (/^read\((\d+), ".*?"(\.\.\.)?, \d+\)\s*= (\d+)/ && + $1==$fd && $3>=0) { + my $nbytes = $3; + if ($fast) { + $total_reads++; + $total_bytes_in += $nbytes; + } else { + $What{$pos}{$nbytes}{r}++; + printf "%d %d\n", $total, $pos; + $pos += $nbytes; + $total += $nbytes; + } + } elsif (/^read\((\d+),/ && $1==$fd) { + die $_; + } +} + + +if (!$fast) { + print "="x36, "\n"; + printf "%8s %8s %8s %8s\n","Position","NBytes","NReads","NWrites"; + for $pos (sort {$a<=>$b} keys %What) { + for $nbytes (sort {$a<=>$b} keys %{$What{$pos}}) { + printf("%8d %8d %8d %8d\n", $pos, $nbytes, + $What{$pos}{$nbytes}{r}, + $What{$pos}{$nbytes}{w}); + $total_writes += $What{$pos}{$nbytes}{w}; + $total_reads += $What{$pos}{$nbytes}{r}; + $total_bytes_out += $What{$pos}{$nbytes}{w} * $nbytes; + $total_bytes_in += $What{$pos}{$nbytes}{r} * $nbytes; + } + } +} + +print "="x36, "\n"; +printf("Write: %8d calls, %10d total bytes, %10g average bytes\n", + $total_writes, $total_bytes_out, $total_bytes_out/$total_writes) + if $total_writes; +printf("Read: %8d calls, %10d total bytes, %10g average bytes\n", + $total_reads, $total_bytes_in, $total_bytes_in/$total_reads) + if $total_reads; diff --git a/bin/iostats.pl b/bin/iostats.pl deleted file mode 100755 index f57c0d0..0000000 --- a/bin/iostats.pl +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/perl -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# - -# Usage: pipe the output of Linux's `strace' program into the stdin of -# this command, and the output of this command into gnuplot. - -my ($fast,$npasses); -if ($ARGV[0] =~ /^--?fast$/) { - $fast = 1; - shift; -} - -my $filename = shift || "tstab2.h5"; -my $total = 0; -my %What; # What{pos}{nbytes}{r|w} = naccesses -my($total_writes, $total_bytes_out, $total_reads, $total_bytes_in); - -while (<>) { - if (!defined $fd) { - if (/^open\("(.*?)".*=\s+(\d+)/ && $1 eq $filename) { - $fd = $2; - $pos = 0; - } - } elsif (/^close\((\d+)/ && $1==$fd) { - $fd = undef; - } elsif (!$fast && - /^lseek\((\d+), -?\d+,.*= (\d+)/ && - $1==$fd && $2>=0) { - $pos = $2; - } elsif (!$fast && /^lseek\((\d+),/ && $1==$fd) { - die $_; - } elsif (/^write\((\d+), ".*?"(\.\.\.)?, \d+\)\s*= (\d+)/ && - $1==$fd && $3>=0) { - my $nbytes = $3; - if ($fast) { - $total_writes++; - $total_bytes_out += $nbytes; - } else { - $What{$pos}{$nbytes}{w}++; - printf "%d %d\n", $total, $pos; - $pos += $nbytes; - $total += $nbytes; - } - } elsif (/^write\((\d+),/ && $1==$fd) { - die $_; - } elsif (/^read\((\d+), ".*?"(\.\.\.)?, \d+\)\s*= (\d+)/ && - $1==$fd && $3>=0) { - my $nbytes = $3; - if ($fast) { - $total_reads++; - $total_bytes_in += $nbytes; - } else { - $What{$pos}{$nbytes}{r}++; - printf "%d %d\n", $total, $pos; - $pos += $nbytes; - $total += $nbytes; - } - } elsif (/^read\((\d+),/ && $1==$fd) { - die $_; - } -} - - -if (!$fast) { - print "="x36, "\n"; - printf "%8s %8s %8s %8s\n","Position","NBytes","NReads","NWrites"; - for $pos (sort {$a<=>$b} keys %What) { - for $nbytes (sort {$a<=>$b} keys %{$What{$pos}}) { - printf("%8d %8d %8d %8d\n", $pos, $nbytes, - $What{$pos}{$nbytes}{r}, - $What{$pos}{$nbytes}{w}); - $total_writes += $What{$pos}{$nbytes}{w}; - $total_reads += $What{$pos}{$nbytes}{r}; - $total_bytes_out += $What{$pos}{$nbytes}{w} * $nbytes; - $total_bytes_in += $What{$pos}{$nbytes}{r} * $nbytes; - } - } -} - -print "="x36, "\n"; -printf("Write: %8d calls, %10d total bytes, %10g average bytes\n", - $total_writes, $total_bytes_out, $total_bytes_out/$total_writes) - if $total_writes; -printf("Read: %8d calls, %10d total bytes, %10g average bytes\n", - $total_reads, $total_bytes_in, $total_bytes_in/$total_reads) - if $total_reads; diff --git a/bin/make_err b/bin/make_err new file mode 100755 index 0000000..4b1f474 --- /dev/null +++ b/bin/make_err @@ -0,0 +1,390 @@ +#!/usr/bin/perl -w +require 5.003; +$indent=4; + +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# Create error headers +# +# Read in the error description text file and create the appropriate headers +# needed by the library. +# +# Programmer: Quincey Koziol +# Creation Date: 2003/08/12 + +############################################################################## +# Print the copyright into an open file +# +sub print_copyright ($) { + my $fh = shift; + + print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; + print $fh " * Copyright by The HDF Group. *\n"; + print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; + print $fh " * All rights reserved. *\n"; + print $fh " * *\n"; + print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; + print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; + print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; + print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; + print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; + print $fh " * is linked from the top-level documents page. It can also be found at *\n"; + print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; + print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; + print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; +} + +############################################################################## +# Print the "do not change this file" warning +# +sub print_warning ($) { + my $fh = shift; + + print $fh "\n/* Generated automatically by bin/make_err -- do not edit */\n"; + print $fh "/* Add new errors to H5err.txt file */\n\n"; +} + +############################################################################## +# Print start of ifdef's to prevent a file from being re-included +# +sub print_startprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the ifdef info + print $fh "\n#ifndef _${file}_H\n"; + print $fh "#define _${file}_H\n"; +} + +############################################################################## +# Print end of ifdef's to prevent a file from being re-included +# +sub print_endprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the endif info + print $fh "\n#endif /* ${file}_H */\n"; +} + +############################################################################## +# Parse a meaningful line (not a comment or blank line) into the appropriate +# data structure +# +sub parse_line ($) { + my $line = shift; # Get the line to parse + my $name; # The name of the error message + my $desc; # The description of the error message + + # Parse major error lines +#print "line=$line\n"; + if($line =~ /^\s*MAJOR,/) { + # Get the major error's name & description + ($name, $desc) = ($line =~ /^\s*MAJOR,\s*(\w*),\s*(.*)\n/); +#print "MAJOR: name=$name, desc=$desc\n"; + + # Check if the name already exists as a major or minor error message + if(exists($major{$name}) || exists($minor{$name})) { + die "duplicated name: $name"; + } + + # Store the major errors in a hash table, indexed by the name + $major{$name}=$desc; + } + # Parse minor error lines + elsif($line =~ /^\s*MINOR,/) { + my $min_section; # Minor errors have a section they below to also + + # Get the minor error's section, name & description + ($min_section, $name, $desc) = ($line =~ /^\s*MINOR,\s*(\w*),\s*(\w*),\s*(.*)\n/); +#print "MINOR: min_section=$min_section, name=$name, desc=$desc\n"; + + # Check for valid section + if(!exists($section{$min_section})) { + die "unknown section: $min_section"; + } + + # Check if the name already exists as a major or minor error message + if(exists($major{$name}) || exists($minor{$name})) { + die "duplicated name: $name"; + } + + # Store the minor errors in a hash table, indexed by the name + $minor{$name}=$desc; + + # Add the minor error to the list for the section + push @{$section_list{$min_section}}, $name; + } + # Parse section lines + elsif($line =~ /^\s*SECTION,/) { + # Get the section's name & description + ($name, $desc) = ($line =~ /^\s*SECTION,\s*(\w*),\s*(.*)\n/); +#print "SECTION: name=$name, desc=$desc\n"; + + # Check if the section has already been defined + if(exists($section{$name})) { + die "duplicated name: $name"; + } + + # Store the section in a hash table, indexed by the name + $section{$name}=$desc; + } + # Unknown keyword + else { + die "unknown keyword: $line"; + } +} + +############################################################################## +# Create the generated portion of the public header file +# +sub create_public ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5Epubgen.h"; # Name of file to generate + my $name; # Name of error message + my $desc; # Description of error message + my $sect_name; # Section of minor error messages + my $sect_desc; # Description of section + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + + # Iterate over all the major errors + print HEADER "\n/*********************/\n"; + print HEADER "/* Major error codes */\n"; + print HEADER "/*********************/\n\n"; + foreach $name (keys %major) { + printf HEADER "#define %-20s (H5OPEN %s_g)\n",$name,$name; + } + foreach $name (keys %major) { + printf HEADER "H5_DLLVAR hid_t %-20s /* %s */\n","${name}_g;",$major{$name}; + } + + # Iterate over all the minor error sections + print HEADER "\n/*********************/\n"; + print HEADER "/* Minor error codes */\n"; + print HEADER "/*********************/\n"; + while ( ($sect_name, $sect_desc) = each (%section)) { + print HEADER "\n/* $sect_desc */\n"; + + # Iterate over all the minor errors in each section + for $name ( @{$section_list{$sect_name}}) { + printf HEADER "#define %-20s (H5OPEN %s_g)\n",$name,$name; + } + for $name ( @{$section_list{$sect_name}}) { + printf HEADER "H5_DLLVAR hid_t %-20s /* %s */\n","${name}_g;",$minor{$name}; + } + } + + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Create the generated portion of the H5E initialization code +# +sub create_init ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5Einit.h"; # Name of file to generate + my $name; # Name of error message + my $desc; # Description of error message + my $sect_name; # Section of minor error messages + my $sect_desc; # Description of section + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + + # Iterate over all the major errors + print HEADER "\n/*********************/\n"; + print HEADER "/* Major error codes */\n"; + print HEADER "/*********************/\n\n"; + foreach $name (keys %major) { + print HEADER " "x(0*$indent),"assert(${name}_g==(-1));\n"; + print HEADER " "x(0*$indent),"if((msg = H5E_create_msg(cls, H5E_MAJOR, \"${major{$name}}\"))==NULL)\n"; + print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\")\n"; + print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0)\n"; + print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\")\n"; + } + + # Iterate over all the minor error sections + print HEADER "\n/*********************/\n"; + print HEADER "/* Minor error codes */\n"; + print HEADER "/*********************/\n\n"; + while ( ($sect_name, $sect_desc) = each (%section)) { + print HEADER "\n"," "x(0*$indent),"/* $sect_desc */\n"; + + # Iterate over all the minor errors in each section + for $name ( @{$section_list{$sect_name}}) { + print HEADER " "x(0*$indent),"assert(${name}_g==(-1));\n"; + print HEADER " "x(0*$indent),"if((msg = H5E_create_msg(cls, H5E_MINOR, \"${minor{$name}}\"))==NULL)\n"; + print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\")\n"; + print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0)\n"; + print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\")\n"; + } + } + + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Create the generated portion of the H5E termination code +# +sub create_term ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5Eterm.h"; # Name of file to generate + my $name; # Name of error message + my $desc; # Description of error message + my $sect_name; # Section of minor error messages + my $sect_desc; # Description of section + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + + # Iterate over all the major errors + print HEADER "\n/* Reset major error IDs */\n"; + foreach $name (keys %major) { + print HEADER " "x($indent),"\n${name}_g="; + } + print HEADER " (-1);\n"; + + # Iterate over all the minor error sections + print HEADER "\n/* Reset minor error IDs */\n"; + while ( ($sect_name, $sect_desc) = each (%section)) { + print HEADER "\n"," "x(0*$indent),"\n/* $sect_desc */"; + + # Iterate over all the minor errors in each section + for $name ( @{$section_list{$sect_name}}) { + print HEADER " "x($indent),"\n${name}_g="; + } + } + print HEADER " (-1);\n"; + + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Create the generated portion of the error code definitions +# +sub create_define ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5Edefin.h"; # Name of file to generate + my $name; # Name of error message + my $desc; # Description of error message + my $sect_name; # Section of minor error messages + my $sect_desc; # Description of section + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + + # Iterate over all the major errors + print HEADER "\n/* Major error IDs */\n"; + foreach $name (keys %major) { + printf HEADER "hid_t %-20s = FAIL; /* %s */\n","${name}_g",$major{$name}; + } + + # Iterate over all the minor error sections + print HEADER "\n/* Minor error IDs */\n"; + while ( ($sect_name, $sect_desc) = each (%section)) { + print HEADER "\n/* $sect_desc */\n"; + + # Iterate over all the minor errors in each section + for $name ( @{$section_list{$sect_name}}) { + printf HEADER "hid_t %-20s = FAIL; /* %s */\n","${name}_g",$minor{$name}; + } + } + + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Read error file (given as command-line argument) in and process it into +# internal data structures, then create error header files. +# +for $file (@ARGV) { + my $prefix; # Local prefix for generated files + + ($prefix) = ($file =~ /(^.*\/)/); + # Read in the entire file + open SOURCE, $file or die "$file: $!\n"; + while ( defined ($line=) ) { + if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { + # Construct data structures for later printing + parse_line($line); + } + } + close SOURCE; + + # Create header files + print "Generating 'H5Epubgen.h'\n"; + create_public($prefix); + print "Generating 'H5Einit.h'\n"; + create_init($prefix); + print "Generating 'H5Eterm.h'\n"; + create_term($prefix); + print "Generating 'H5Edefin.h'\n"; + create_define($prefix); +} diff --git a/bin/make_err.pl b/bin/make_err.pl deleted file mode 100755 index 4b1f474..0000000 --- a/bin/make_err.pl +++ /dev/null @@ -1,390 +0,0 @@ -#!/usr/bin/perl -w -require 5.003; -$indent=4; - -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# - -# Create error headers -# -# Read in the error description text file and create the appropriate headers -# needed by the library. -# -# Programmer: Quincey Koziol -# Creation Date: 2003/08/12 - -############################################################################## -# Print the copyright into an open file -# -sub print_copyright ($) { - my $fh = shift; - - print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; - print $fh " * Copyright by The HDF Group. *\n"; - print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; - print $fh " * All rights reserved. *\n"; - print $fh " * *\n"; - print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; - print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; - print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; - print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; - print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; - print $fh " * is linked from the top-level documents page. It can also be found at *\n"; - print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; - print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; - print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; -} - -############################################################################## -# Print the "do not change this file" warning -# -sub print_warning ($) { - my $fh = shift; - - print $fh "\n/* Generated automatically by bin/make_err -- do not edit */\n"; - print $fh "/* Add new errors to H5err.txt file */\n\n"; -} - -############################################################################## -# Print start of ifdef's to prevent a file from being re-included -# -sub print_startprotect ($$) { - my ($fh, $file) = @_; - - # Clip off the ".h" part of the name - $file =~ s/(\w*)\.h/$1/; - - # Print the ifdef info - print $fh "\n#ifndef _${file}_H\n"; - print $fh "#define _${file}_H\n"; -} - -############################################################################## -# Print end of ifdef's to prevent a file from being re-included -# -sub print_endprotect ($$) { - my ($fh, $file) = @_; - - # Clip off the ".h" part of the name - $file =~ s/(\w*)\.h/$1/; - - # Print the endif info - print $fh "\n#endif /* ${file}_H */\n"; -} - -############################################################################## -# Parse a meaningful line (not a comment or blank line) into the appropriate -# data structure -# -sub parse_line ($) { - my $line = shift; # Get the line to parse - my $name; # The name of the error message - my $desc; # The description of the error message - - # Parse major error lines -#print "line=$line\n"; - if($line =~ /^\s*MAJOR,/) { - # Get the major error's name & description - ($name, $desc) = ($line =~ /^\s*MAJOR,\s*(\w*),\s*(.*)\n/); -#print "MAJOR: name=$name, desc=$desc\n"; - - # Check if the name already exists as a major or minor error message - if(exists($major{$name}) || exists($minor{$name})) { - die "duplicated name: $name"; - } - - # Store the major errors in a hash table, indexed by the name - $major{$name}=$desc; - } - # Parse minor error lines - elsif($line =~ /^\s*MINOR,/) { - my $min_section; # Minor errors have a section they below to also - - # Get the minor error's section, name & description - ($min_section, $name, $desc) = ($line =~ /^\s*MINOR,\s*(\w*),\s*(\w*),\s*(.*)\n/); -#print "MINOR: min_section=$min_section, name=$name, desc=$desc\n"; - - # Check for valid section - if(!exists($section{$min_section})) { - die "unknown section: $min_section"; - } - - # Check if the name already exists as a major or minor error message - if(exists($major{$name}) || exists($minor{$name})) { - die "duplicated name: $name"; - } - - # Store the minor errors in a hash table, indexed by the name - $minor{$name}=$desc; - - # Add the minor error to the list for the section - push @{$section_list{$min_section}}, $name; - } - # Parse section lines - elsif($line =~ /^\s*SECTION,/) { - # Get the section's name & description - ($name, $desc) = ($line =~ /^\s*SECTION,\s*(\w*),\s*(.*)\n/); -#print "SECTION: name=$name, desc=$desc\n"; - - # Check if the section has already been defined - if(exists($section{$name})) { - die "duplicated name: $name"; - } - - # Store the section in a hash table, indexed by the name - $section{$name}=$desc; - } - # Unknown keyword - else { - die "unknown keyword: $line"; - } -} - -############################################################################## -# Create the generated portion of the public header file -# -sub create_public ($) { - my $prefix = shift; # Get the prefix for the generated file - my $file = "H5Epubgen.h"; # Name of file to generate - my $name; # Name of error message - my $desc; # Description of error message - my $sect_name; # Section of minor error messages - my $sect_desc; # Description of section - - # Rename previous file -# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; - - # Open new header file - open HEADER, ">${prefix}${file}" or die "unable to modify source"; - - # Create file contents - - print_copyright(*HEADER); - print_warning(*HEADER); - print_startprotect(*HEADER, $file); - - # Iterate over all the major errors - print HEADER "\n/*********************/\n"; - print HEADER "/* Major error codes */\n"; - print HEADER "/*********************/\n\n"; - foreach $name (keys %major) { - printf HEADER "#define %-20s (H5OPEN %s_g)\n",$name,$name; - } - foreach $name (keys %major) { - printf HEADER "H5_DLLVAR hid_t %-20s /* %s */\n","${name}_g;",$major{$name}; - } - - # Iterate over all the minor error sections - print HEADER "\n/*********************/\n"; - print HEADER "/* Minor error codes */\n"; - print HEADER "/*********************/\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n/* $sect_desc */\n"; - - # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - printf HEADER "#define %-20s (H5OPEN %s_g)\n",$name,$name; - } - for $name ( @{$section_list{$sect_name}}) { - printf HEADER "H5_DLLVAR hid_t %-20s /* %s */\n","${name}_g;",$minor{$name}; - } - } - - print_endprotect(*HEADER, $file); - - # Close header file - close HEADER; -} - -############################################################################## -# Create the generated portion of the H5E initialization code -# -sub create_init ($) { - my $prefix = shift; # Get the prefix for the generated file - my $file = "H5Einit.h"; # Name of file to generate - my $name; # Name of error message - my $desc; # Description of error message - my $sect_name; # Section of minor error messages - my $sect_desc; # Description of section - - # Rename previous file -# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; - - # Open new header file - open HEADER, ">${prefix}${file}" or die "unable to modify source"; - - # Create file contents - - print_copyright(*HEADER); - print_warning(*HEADER); - print_startprotect(*HEADER, $file); - - # Iterate over all the major errors - print HEADER "\n/*********************/\n"; - print HEADER "/* Major error codes */\n"; - print HEADER "/*********************/\n\n"; - foreach $name (keys %major) { - print HEADER " "x(0*$indent),"assert(${name}_g==(-1));\n"; - print HEADER " "x(0*$indent),"if((msg = H5E_create_msg(cls, H5E_MAJOR, \"${major{$name}}\"))==NULL)\n"; - print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\")\n"; - print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0)\n"; - print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\")\n"; - } - - # Iterate over all the minor error sections - print HEADER "\n/*********************/\n"; - print HEADER "/* Minor error codes */\n"; - print HEADER "/*********************/\n\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n"," "x(0*$indent),"/* $sect_desc */\n"; - - # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - print HEADER " "x(0*$indent),"assert(${name}_g==(-1));\n"; - print HEADER " "x(0*$indent),"if((msg = H5E_create_msg(cls, H5E_MINOR, \"${minor{$name}}\"))==NULL)\n"; - print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, \"error message initialization failed\")\n"; - print HEADER " "x(0*$indent),"if((${name}_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0)\n"; - print HEADER " "x(1*$indent),"HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, \"can't register error message\")\n"; - } - } - - print_endprotect(*HEADER, $file); - - # Close header file - close HEADER; -} - -############################################################################## -# Create the generated portion of the H5E termination code -# -sub create_term ($) { - my $prefix = shift; # Get the prefix for the generated file - my $file = "H5Eterm.h"; # Name of file to generate - my $name; # Name of error message - my $desc; # Description of error message - my $sect_name; # Section of minor error messages - my $sect_desc; # Description of section - - # Rename previous file -# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; - - # Open new header file - open HEADER, ">${prefix}${file}" or die "unable to modify source"; - - # Create file contents - - print_copyright(*HEADER); - print_warning(*HEADER); - print_startprotect(*HEADER, $file); - - # Iterate over all the major errors - print HEADER "\n/* Reset major error IDs */\n"; - foreach $name (keys %major) { - print HEADER " "x($indent),"\n${name}_g="; - } - print HEADER " (-1);\n"; - - # Iterate over all the minor error sections - print HEADER "\n/* Reset minor error IDs */\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n"," "x(0*$indent),"\n/* $sect_desc */"; - - # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - print HEADER " "x($indent),"\n${name}_g="; - } - } - print HEADER " (-1);\n"; - - print_endprotect(*HEADER, $file); - - # Close header file - close HEADER; -} - -############################################################################## -# Create the generated portion of the error code definitions -# -sub create_define ($) { - my $prefix = shift; # Get the prefix for the generated file - my $file = "H5Edefin.h"; # Name of file to generate - my $name; # Name of error message - my $desc; # Description of error message - my $sect_name; # Section of minor error messages - my $sect_desc; # Description of section - - # Rename previous file -# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; - - # Open new header file - open HEADER, ">${prefix}${file}" or die "unable to modify source"; - - # Create file contents - - print_copyright(*HEADER); - print_warning(*HEADER); - print_startprotect(*HEADER, $file); - - # Iterate over all the major errors - print HEADER "\n/* Major error IDs */\n"; - foreach $name (keys %major) { - printf HEADER "hid_t %-20s = FAIL; /* %s */\n","${name}_g",$major{$name}; - } - - # Iterate over all the minor error sections - print HEADER "\n/* Minor error IDs */\n"; - while ( ($sect_name, $sect_desc) = each (%section)) { - print HEADER "\n/* $sect_desc */\n"; - - # Iterate over all the minor errors in each section - for $name ( @{$section_list{$sect_name}}) { - printf HEADER "hid_t %-20s = FAIL; /* %s */\n","${name}_g",$minor{$name}; - } - } - - print_endprotect(*HEADER, $file); - - # Close header file - close HEADER; -} - -############################################################################## -# Read error file (given as command-line argument) in and process it into -# internal data structures, then create error header files. -# -for $file (@ARGV) { - my $prefix; # Local prefix for generated files - - ($prefix) = ($file =~ /(^.*\/)/); - # Read in the entire file - open SOURCE, $file or die "$file: $!\n"; - while ( defined ($line=) ) { - if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { - # Construct data structures for later printing - parse_line($line); - } - } - close SOURCE; - - # Create header files - print "Generating 'H5Epubgen.h'\n"; - create_public($prefix); - print "Generating 'H5Einit.h'\n"; - create_init($prefix); - print "Generating 'H5Eterm.h'\n"; - create_term($prefix); - print "Generating 'H5Edefin.h'\n"; - create_define($prefix); -} diff --git a/bin/make_overflow b/bin/make_overflow new file mode 100755 index 0000000..ced486a --- /dev/null +++ b/bin/make_overflow @@ -0,0 +1,219 @@ +#!/usr/bin/perl -w +require 5.003; +use strict; + +# Global settings + +# List of supported C types to generate overflow assignment code for +my @ctypes = ( () ); + +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# Create assignment overflow #ifdefs +# +# Programmer: Quincey Koziol +# Creation Date: 2009/04/09 + +############################################################################## +# Parse a meaningful line (not a comment or blank line) into the appropriate +# data structure +# +sub parse_line ($) { + my $line = shift; # Get the line to parse + + # Parse get the type name and whether it's signed or unsigned +#print "line=$line\n"; + if($line =~ /.*SIGNED\s*;\s*$/ || $line =~ /.*UNSIGNED\s*;\s*$/) { + my $name; # The name of the type + my $signed; # Whether the type is signed or not + + # Get the type's name & signed status + ($name, $signed) = ($line =~ /^\s*(\w*)\s*,\s*(\w*)\s*;\s*$/); +#print "name = '$name', signed = '$signed'\n"; + + # Append the type to the list of C types already parsed + push @ctypes, [$name, $signed]; + + } + # Unknown keyword + else { + die "unknown keyword: $line"; + } +} + +############################################################################## +# Print the copyright into an open file +# +sub print_copyright ($) { + my $fh = shift; + + print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; + print $fh " * Copyright by The HDF Group. *\n"; + print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; + print $fh " * All rights reserved. *\n"; + print $fh " * *\n"; + print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; + print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; + print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; + print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; + print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; + print $fh " * is linked from the top-level documents page. It can also be found at *\n"; + print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; + print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; + print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; +} + +############################################################################## +# Print the "do not change this file" warning +# +sub print_warning ($) { + my $fh = shift; + + print $fh "\n/* Generated automatically by bin/make_overflow -- do not edit */\n"; + print $fh "/* Add new types to H5overflow.txt file */\n\n"; +} + +############################################################################## +# Print start of ifdef's to prevent a file from being re-included +# +sub print_startprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the ifdef info + print $fh "\n#ifndef _${file}_H\n"; + print $fh "#define _${file}_H\n"; +} + +############################################################################## +# Print assignment overflow macros for each type +# +sub print_typemacros ($) { + my $fh = shift; # File handle for output file + my ($src_aref, $dst_aref); # References for each type's information + + # Print the descriptive comment + print $fh "\n\n/* Each type in this file is tested for assignment to the other types,\n"; + print $fh " * and range checks are defined for bad assignments at run-time.\n"; + print $fh " */\n"; + + for $src_aref (@ctypes) { + # Print a descriptive comment + print $fh "\n/* Assignment checks for @$src_aref[0] */\n\n"; + + for $dst_aref (@ctypes) { + if (@$src_aref[0] ne @$dst_aref[0]) { + # Print a descriptive comment + print $fh "/* src: @$src_aref[0], dst: @$dst_aref[0] */\n"; + + # Print actual type size checks & macro definitions + print $fh "#if H5_SIZEOF_", uc @$src_aref[0], " < H5_SIZEOF_", uc @$dst_aref[0], "\n"; + print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; + if ( @$src_aref[1] eq @$dst_aref[1]) { + print $fh " ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n"; + } elsif ( @$src_aref[1] eq "SIGNED") { + print $fh " ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n"; + } else { + print $fh " ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n"; + } + print $fh "#elif H5_SIZEOF_", uc @$src_aref[0], " > H5_SIZEOF_", uc @$dst_aref[0], "\n"; + print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; + print $fh " ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype)\n"; + print $fh "#else /* H5_SIZEOF_", uc @$src_aref[0], " == H5_SIZEOF_", uc @$dst_aref[0], " */\n"; + print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; + if ( @$src_aref[1] eq @$dst_aref[1]) { + print $fh " ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n"; + } elsif ( @$src_aref[1] eq "SIGNED") { + print $fh " ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n"; + } else { + print $fh " ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n"; + } + print $fh "#endif /* src: @$src_aref[0] dst: @$dst_aref[0] */\n\n"; + } + } + } + +} + +############################################################################## +# Print end of ifdef's to prevent a file from being re-included +# +sub print_endprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the endif info + print $fh "#endif /* ${file}_H */\n\n"; +} + +############################################################################## +# Create the generated portion of the public header file +# +sub create_public ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5overflow.h"; # Name of file to generate + my $name; # Name of function + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + print_typemacros(*HEADER); + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Read symbol version file (given as command-line argument) in and process it +# into internal data structures, then create header files. +# +my $file; # Filename of input file + +for $file (@ARGV) { + my $prefix; # Local prefix for generated files + my $line; # Line from input file + +#print "file = '$file'\n"; + ($prefix) = ($file =~ /(^.*\/)/); +#print "prefix = '$prefix'\n"; + # Read in the entire file + open SOURCE, $file or die "$file: $!\n"; + while ( defined ($line=) ) { + # Skip blank lines and those lines whose first character is a '#' + if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { + # Construct data structures for later printing + parse_line($line); + } + } + close SOURCE; + + # Create header files + print "Generating 'H5overflow.h'\n"; + create_public($prefix); +} + diff --git a/bin/make_overflow.pl b/bin/make_overflow.pl deleted file mode 100755 index ced486a..0000000 --- a/bin/make_overflow.pl +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/perl -w -require 5.003; -use strict; - -# Global settings - -# List of supported C types to generate overflow assignment code for -my @ctypes = ( () ); - -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# - -# Create assignment overflow #ifdefs -# -# Programmer: Quincey Koziol -# Creation Date: 2009/04/09 - -############################################################################## -# Parse a meaningful line (not a comment or blank line) into the appropriate -# data structure -# -sub parse_line ($) { - my $line = shift; # Get the line to parse - - # Parse get the type name and whether it's signed or unsigned -#print "line=$line\n"; - if($line =~ /.*SIGNED\s*;\s*$/ || $line =~ /.*UNSIGNED\s*;\s*$/) { - my $name; # The name of the type - my $signed; # Whether the type is signed or not - - # Get the type's name & signed status - ($name, $signed) = ($line =~ /^\s*(\w*)\s*,\s*(\w*)\s*;\s*$/); -#print "name = '$name', signed = '$signed'\n"; - - # Append the type to the list of C types already parsed - push @ctypes, [$name, $signed]; - - } - # Unknown keyword - else { - die "unknown keyword: $line"; - } -} - -############################################################################## -# Print the copyright into an open file -# -sub print_copyright ($) { - my $fh = shift; - - print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; - print $fh " * Copyright by The HDF Group. *\n"; - print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; - print $fh " * All rights reserved. *\n"; - print $fh " * *\n"; - print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; - print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; - print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; - print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; - print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; - print $fh " * is linked from the top-level documents page. It can also be found at *\n"; - print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; - print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; - print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; -} - -############################################################################## -# Print the "do not change this file" warning -# -sub print_warning ($) { - my $fh = shift; - - print $fh "\n/* Generated automatically by bin/make_overflow -- do not edit */\n"; - print $fh "/* Add new types to H5overflow.txt file */\n\n"; -} - -############################################################################## -# Print start of ifdef's to prevent a file from being re-included -# -sub print_startprotect ($$) { - my ($fh, $file) = @_; - - # Clip off the ".h" part of the name - $file =~ s/(\w*)\.h/$1/; - - # Print the ifdef info - print $fh "\n#ifndef _${file}_H\n"; - print $fh "#define _${file}_H\n"; -} - -############################################################################## -# Print assignment overflow macros for each type -# -sub print_typemacros ($) { - my $fh = shift; # File handle for output file - my ($src_aref, $dst_aref); # References for each type's information - - # Print the descriptive comment - print $fh "\n\n/* Each type in this file is tested for assignment to the other types,\n"; - print $fh " * and range checks are defined for bad assignments at run-time.\n"; - print $fh " */\n"; - - for $src_aref (@ctypes) { - # Print a descriptive comment - print $fh "\n/* Assignment checks for @$src_aref[0] */\n\n"; - - for $dst_aref (@ctypes) { - if (@$src_aref[0] ne @$dst_aref[0]) { - # Print a descriptive comment - print $fh "/* src: @$src_aref[0], dst: @$dst_aref[0] */\n"; - - # Print actual type size checks & macro definitions - print $fh "#if H5_SIZEOF_", uc @$src_aref[0], " < H5_SIZEOF_", uc @$dst_aref[0], "\n"; - print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; - if ( @$src_aref[1] eq @$dst_aref[1]) { - print $fh " ASSIGN_TO_LARGER_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n"; - } elsif ( @$src_aref[1] eq "SIGNED") { - print $fh " ASSIGN_TO_LARGER_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n"; - } else { - print $fh " ASSIGN_TO_LARGER_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n"; - } - print $fh "#elif H5_SIZEOF_", uc @$src_aref[0], " > H5_SIZEOF_", uc @$dst_aref[0], "\n"; - print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; - print $fh " ASSIGN_TO_SMALLER_SIZE(dst, dsttype, src, srctype)\n"; - print $fh "#else /* H5_SIZEOF_", uc @$src_aref[0], " == H5_SIZEOF_", uc @$dst_aref[0], " */\n"; - print $fh " #define ASSIGN_", @$src_aref[0], "_TO_", @$dst_aref[0], "(dst, dsttype, src, srctype) \\\n"; - if ( @$src_aref[1] eq @$dst_aref[1]) { - print $fh " ASSIGN_TO_SAME_SIZE_SAME_SIGNED(dst, dsttype, src, srctype)\n"; - } elsif ( @$src_aref[1] eq "SIGNED") { - print $fh " ASSIGN_TO_SAME_SIZE_SIGNED_TO_UNSIGNED(dst, dsttype, src, srctype)\n"; - } else { - print $fh " ASSIGN_TO_SAME_SIZE_UNSIGNED_TO_SIGNED(dst, dsttype, src, srctype)\n"; - } - print $fh "#endif /* src: @$src_aref[0] dst: @$dst_aref[0] */\n\n"; - } - } - } - -} - -############################################################################## -# Print end of ifdef's to prevent a file from being re-included -# -sub print_endprotect ($$) { - my ($fh, $file) = @_; - - # Clip off the ".h" part of the name - $file =~ s/(\w*)\.h/$1/; - - # Print the endif info - print $fh "#endif /* ${file}_H */\n\n"; -} - -############################################################################## -# Create the generated portion of the public header file -# -sub create_public ($) { - my $prefix = shift; # Get the prefix for the generated file - my $file = "H5overflow.h"; # Name of file to generate - my $name; # Name of function - - # Rename previous file -# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; - - # Open new header file - open HEADER, ">${prefix}${file}" or die "unable to modify source"; - - # Create file contents - print_copyright(*HEADER); - print_warning(*HEADER); - print_startprotect(*HEADER, $file); - print_typemacros(*HEADER); - print_endprotect(*HEADER, $file); - - # Close header file - close HEADER; -} - -############################################################################## -# Read symbol version file (given as command-line argument) in and process it -# into internal data structures, then create header files. -# -my $file; # Filename of input file - -for $file (@ARGV) { - my $prefix; # Local prefix for generated files - my $line; # Line from input file - -#print "file = '$file'\n"; - ($prefix) = ($file =~ /(^.*\/)/); -#print "prefix = '$prefix'\n"; - # Read in the entire file - open SOURCE, $file or die "$file: $!\n"; - while ( defined ($line=) ) { - # Skip blank lines and those lines whose first character is a '#' - if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { - # Construct data structures for later printing - parse_line($line); - } - } - close SOURCE; - - # Create header files - print "Generating 'H5overflow.h'\n"; - create_public($prefix); -} - diff --git a/bin/make_vers b/bin/make_vers new file mode 100755 index 0000000..0bc3b62 --- /dev/null +++ b/bin/make_vers @@ -0,0 +1,505 @@ +#!/usr/bin/perl -w +require 5.003; + +# Global settings +# (The max_idx parameter is the only thing that needs to be changed when adding +# support for a new major release. If support for a prior major release +# is added (like support for 1.4, etc), the min_sup_idx parameter will +# need to be decremented. - QAK) + +# Max. library "index" (0 = v1.0, 1 = 1.2, etc) +$max_idx = 5; + +# Min. supported previous library version "index" (0 = v1.0, 1 = 1.2, etc) +$min_sup_idx = 3; + +# Number of spaces to indent preprocessor commands inside ifdefs +$indent = 2; + +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# + +# Create public symbol version headers +# +# Read in the public symbol version description text file and create the +# appropriate headers needed by the library. +# +# Programmer: Quincey Koziol +# Creation Date: 2007/07/10 + +############################################################################## +# Print the copyright into an open file +# +sub print_copyright ($) { + my $fh = shift; + + print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; + print $fh " * Copyright by The HDF Group. *\n"; + print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; + print $fh " * All rights reserved. *\n"; + print $fh " * *\n"; + print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; + print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; + print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; + print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; + print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; + print $fh " * is linked from the top-level documents page. It can also be found at *\n"; + print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; + print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; + print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; +} + +############################################################################## +# Print the "do not change this file" warning +# +sub print_warning ($) { + my $fh = shift; + + print $fh "\n/* Generated automatically by bin/make_vers -- do not edit */\n"; + print $fh "/* Add new versioned symbols to H5vers.txt file */\n\n"; +} + +############################################################################## +# Print start of ifdef's to prevent a file from being re-included +# +sub print_startprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the ifdef info + print $fh "\n#ifndef _${file}_H\n"; + print $fh "#define _${file}_H\n"; +} + +############################################################################## +# Print check for conflicting version macro settings +# +sub print_checkoptions ($) { + my $fh = shift; # File handle for output file + my $curr_idx; # Current API version index + + # Print the option checking + print $fh "\n/* Issue error if contradicting macros have been defined. */\n"; + + # Print the #ifdef + print $fh "#if ("; + for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { + print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)"; + if($curr_idx < ($max_idx - 1)) { + print $fh " || "; + } + } + print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS)\n"; + + # Print the error for bad API version chosen + print $fh ' ' x $indent, "#error \"Can't choose old API versions when deprecated APIs are disabled\"\n"; + + # Print the #endif + print $fh "#endif /* ("; + for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { + print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)"; + if($curr_idx < ($max_idx - 1)) { + print $fh " || "; + } + } + print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS) */\n"; +} + +############################################################################## +# Print "global" API version macro settings +# +sub print_globalapivers ($) { + my $fh = shift; # File handle for output file + my $curr_idx; # Current API version index + + # Print the descriptive comment + print $fh "\n\n/* If a particular \"global\" version of the library's interfaces is chosen,\n"; + print $fh " * set the versions for the API symbols affected.\n"; + print $fh " *\n"; + print $fh " * Note: If an application has already chosen a particular version for an\n"; + print $fh " * API symbol, the individual API version macro takes priority.\n"; + print $fh " */\n"; + + for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { + # Print API version ifdef + print $fh "#if defined(H5_USE_1", ($curr_idx * 2), "_API_DEFAULT) && !defined(H5_USE_1", ($curr_idx * 2), "_API)\n"; + # Print API version definition + print $fh " " x $indent, "#define H5_USE_1", ($curr_idx * 2), "_API 1\n"; + # Print API version endif + print $fh "#endif /* H5_USE_1", ($curr_idx * 2), "_API_DEFAULT && !H5_USE_1", ($curr_idx * 2), "_API */\n\n"; + } + + # Loop over supported older library APIs and define the appropriate macros + for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { + # Print API version ifdef + print $fh "\n#ifdef H5_USE_1", ($curr_idx * 2), "_API\n"; + + # Print the version macro info for each function that is defined for + # this API version + print $fh "\n/*************/\n"; + print $fh "/* Functions */\n"; + print $fh "/*************/\n"; + for $name (sort keys %{$func_vers[$curr_idx]}) { + print $fh "\n#if !defined(", $name, "_vers)\n"; + print $fh " " x $indent, "#define ", $name, "_vers $func_vers[$curr_idx]{$name}\n"; + print $fh "#endif /* !defined(", $name, "_vers) */\n"; + } + + # Print the version macro info for each typedef that is defined for + # this API version + print $fh "\n/************/\n"; + print $fh "/* Typedefs */\n"; + print $fh "/************/\n"; + for $name (sort keys %{$type_vers[$curr_idx]}) { + print $fh "\n#if !defined(", $name, "_t_vers)\n"; + print $fh " " x $indent, "#define ", $name, "_t_vers $type_vers[$curr_idx]{$name}\n"; + print $fh "#endif /* !defined(", $name, "_t_vers) */\n"; + } + + # Print API version endif + print $fh "\n#endif /* H5_USE_1", ($curr_idx * 2), "_API */\n"; + } +} + +############################################################################## +# Print "default" API version macro settings +# +sub print_defaultapivers ($) { + my $fh = shift; # File handle for output file + my $curr_name; # Current API function + + # Print the descriptive comment + print $fh "\n\n/* Choose the correct version of each API symbol, defaulting to the latest\n"; + print $fh " * version of each. The \"best\" name for API parameters/data structures\n"; + print $fh " * that have changed definitions is also set. An error is issued for\n"; + print $fh " * specifying an invalid API version.\n"; + print $fh " */\n"; + + # Loop over function names that are versioned and set up the version macros + print $fh "\n/*************/\n"; + print $fh "/* Functions */\n"; + print $fh "/*************/\n"; + for $curr_name (sort keys %functions) { + my $curr_vers_name; # Name of version macro for current function + my $curr_vers; # Version of function + my @param_list; # Typedefs for the function parameters + + # Set up variables for later use + $curr_vers_name = $curr_name . "_vers"; + $curr_vers = $functions{$curr_name}; + + # Split up parameter info + @param_list = split(/\s*,\s*/, $func_params{$curr_name}); +#print "print_defaultapivers: param_list=(@param_list)\n"; + + # Set up default/latest version name mapping + print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n"; + print $fh " " x $indent, "#ifndef $curr_vers_name\n"; + print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n"; + print $fh " " x $indent, "#endif /* $curr_vers_name */\n"; + print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n"; + + # Print function's dependent parameter types + foreach(sort(@param_list)) { + print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n"; + } + + # Loop to print earlier version name mappings + $curr_vers--; + while($curr_vers > 0) { + print $fh "#elif $curr_vers_name == $curr_vers\n"; + print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n"; + + # Print function's dependent parameter types + foreach(sort(@param_list)) { + print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n"; + } + + $curr_vers--; + } + + # Finish up with error for unknown version and endif + print $fh "#else /* $curr_vers_name */\n"; + print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n"; + print $fh "#endif /* $curr_vers_name */\n"; + } + + # Loop over typedefs that are versioned and set up the version macros + print $fh "\n/************/\n"; + print $fh "/* Typedefs */\n"; + print $fh "/************/\n"; + for $curr_name (sort keys %typedefs) { + my $curr_vers_name; # Name of version macro for current function + my $curr_vers; # Version of function + + # Set up variables for later use + $curr_vers_name = $curr_name . "_t_vers"; + $curr_vers = $typedefs{$curr_name}; + + # Set up default/latest version name mapping + print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n"; + print $fh " " x $indent, "#ifndef $curr_vers_name\n"; + print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n"; + print $fh " " x $indent, "#endif /* $curr_vers_name */\n"; + print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n"; + + # Loop to print earlier version name mappings + $curr_vers--; + while($curr_vers > 0) { + print $fh "#elif $curr_vers_name == $curr_vers\n"; + print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n"; + $curr_vers--; + } + + # Finish up with error for unknown version and endif + print $fh "#else /* $curr_vers_name */\n"; + print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n"; + print $fh "#endif /* $curr_vers_name */\n\n"; + } +} + +############################################################################## +# Print end of ifdef's to prevent a file from being re-included +# +sub print_endprotect ($$) { + my ($fh, $file) = @_; + + # Clip off the ".h" part of the name + $file =~ s/(\w*)\.h/$1/; + + # Print the endif info + print $fh "#endif /* ${file}_H */\n\n"; +} + +############################################################################## +# Parse a meaningful line (not a comment or blank line) into the appropriate +# data structure +# +sub parse_line ($) { + my $line = shift; # Get the line to parse + + # Parse API function lines +#print "line=$line\n"; + if($line =~ /^\s*FUNCTION:/ || $line =~ /^\s*TYPEDEF:/) { + my $name; # The name of the function + my $params; # Typedefs for function parameters + my $vers; # The version info for the function + my @vers_list; # Version info, as a list + my @vers_nums; # Version info, as a numeric list + my $num_versions; # Number of versions for function + my %sym_versions; # Versions for a symbol + my $last_idx; # The previous version index seen for a function + my $last_vers; # The previous version # seen for a function + my $line_type; # Type of line we are parsing + + # Determine the type of the line to parse + if($line =~ /^\s*FUNCTION:/) { + $line_type = 1; + # Get the function's name & version info + ($name, $params, $vers) = ($line =~ /^\s*FUNCTION:\s*(\w*);\s*(.*?)\s*;\s*(.*?)\s*$/); +#print "parse_line: name='$name', params='$params', vers='$vers'\n"; + } + elsif($line =~ /^\s*TYPEDEF:/) { + $line_type = 2; + + # Get the typedefs's name & version info + ($name, $vers) = ($line =~ /^\s*TYPEDEF:\s*(\w*);\s*(.*?)\s*$/); +#print "parse_line: name='$name', vers='$vers'\n"; + } +#print "parse_line: line_type='$line_type'\n"; + + + # Check if the name already exists in the list of symbols + if(exists($functions{$name}) || exists($typedefs{$name})) { + die "duplicated symbol: $name"; + } + + # Check for no version info given + if($vers eq "") { + die "no version information: $name"; + } + + # Split up version info + @vers_list = split(/\s*,\s*/, $vers); +#print "parse_line: vers_list=(@vers_list)\n"; + + # Parse the version list into numbers, checking for invalid input + foreach(@vers_list) { + my $vers_idx; # Index of version in array + + # Do some validation on the input + if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ )) { + die "bad version information: $name"; + } + if(exists($sym_versions{$_})) { + die "duplicate version information: $name"; + } + + # Store the versions for the function in a local hash table, indexed by the version + $sym_versions{$_}=$_; + +#print "parse_line: _=$_\n"; + # Get the index of the version + ($vers_idx) = ($_ =~ /v1(\d+)/); + $vers_idx /= 2; +#print "parse_line: vers_idx='$vers_idx'\n"; + push(@vers_nums, $vers_idx); + } +#print "parse_line: vers_nums=(@vers_nums)\n"; + + # Check for invalid version info given + $last_idx = -1; + $last_vers = 1; + foreach(sort(@vers_nums)) { +#print "parse_line: _=$_ last_idx='$last_idx'\n"; + # Update intermediate versions of the library that included the API routine + if($last_idx >= 0) { +#print "parse_line: name='$name'\n"; +#print "parse_line: last_vers='$last_vers'\n"; +#print "parse_line: last_idx='$last_idx'\n"; + + # Add the function to the list of API routines available in + # different versions of the library + while($last_idx <= $_) { + if($line_type == 1) { + $func_vers[$last_idx]{$name} = $last_vers; + } elsif($line_type == 2) { + $type_vers[$last_idx]{$name} = $last_vers; + } else { + die "unknown line type: $line"; + } + $last_idx++; + } + + # Increment the version # of the function + $last_vers++; + } + + # Keep track of last version index seen + $last_idx = $_; + } + + # Finish updating versions of the library that included the API routine + if($last_idx >= 0) { +#print "parse_line: max_idx='$max_idx'\n"; + + # Add the function to the list of API routines available in + # different versions of the library + while($last_idx <= $max_idx) { + if($line_type == 1) { + $func_vers[$last_idx]{$name} = $last_vers; + } elsif($line_type == 2) { + $type_vers[$last_idx]{$name} = $last_vers; + } else { + die "unknown line type: $line"; + } + $last_idx++; + } + } + + # Store the number of symbol versions in a hash table, indexed by the name + if($line_type == 1) { + $functions{$name} = $#vers_list + 1; + + # Store the function's parameter types for later + $func_params{$name} = $params; + } elsif($line_type == 2) { + $typedefs{$name} = $#vers_list + 1; + } else { + die "unknown line type: $line"; + } + } + # Unknown keyword + else { + die "unknown keyword: $line"; + } +} + +############################################################################## +# Create the generated portion of the public header file +# +sub create_public ($) { + my $prefix = shift; # Get the prefix for the generated file + my $file = "H5version.h"; # Name of file to generate + my $name; # Name of function + + # Rename previous file +# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; + + # Open new header file + open HEADER, ">${prefix}${file}" or die "unable to modify source"; + + # Create file contents + print_copyright(*HEADER); + print_warning(*HEADER); + print_startprotect(*HEADER, $file); + print_checkoptions(*HEADER); + print_globalapivers(*HEADER); + print_defaultapivers(*HEADER); + print_endprotect(*HEADER, $file); + + # Close header file + close HEADER; +} + +############################################################################## +# Read symbol version file (given as command-line argument) in and process it +# into internal data structures, then create header files. +# +for $file (@ARGV) { + my $prefix; # Local prefix for generated files + +#print "file = '$file'\n"; + # Check for directory prefix on input file + if($file =~ /\//) { + ($prefix) = ($file =~ /(^.*\/)/); + } + else { + $prefix = ""; + } +#print "prefix = '$prefix'\n"; + # Read in the entire file + open SOURCE, $file or die "$file: $!\n"; + while ( defined ($line=) ) { + # Skip blank lines and those lines whose first character is a '#' + if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { + # Construct data structures for later printing + parse_line($line); + } + } + close SOURCE; + + # Create header files + print "Generating '", $prefix, "H5version.h'\n"; + create_public($prefix); + +#for $name (sort keys %functions) { +# print "functions{$name} = $functions{$name}\n"; +#} + +#for $i (0 .. $#func_vers) { +# my $vers_name; # Name of indexed version +# $vers_name = "v1." . ($i * 2); +# print "$vers_name functions: "; +# for $name (sort keys %{$func_vers[$i]}) { +# print "$name$func_vers[$i]{$name} "; +# } +# print "\n"; +#} + +} + diff --git a/bin/make_vers.pl b/bin/make_vers.pl deleted file mode 100755 index 0bc3b62..0000000 --- a/bin/make_vers.pl +++ /dev/null @@ -1,505 +0,0 @@ -#!/usr/bin/perl -w -require 5.003; - -# Global settings -# (The max_idx parameter is the only thing that needs to be changed when adding -# support for a new major release. If support for a prior major release -# is added (like support for 1.4, etc), the min_sup_idx parameter will -# need to be decremented. - QAK) - -# Max. library "index" (0 = v1.0, 1 = 1.2, etc) -$max_idx = 5; - -# Min. supported previous library version "index" (0 = v1.0, 1 = 1.2, etc) -$min_sup_idx = 3; - -# Number of spaces to indent preprocessor commands inside ifdefs -$indent = 2; - -# -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# - -# Create public symbol version headers -# -# Read in the public symbol version description text file and create the -# appropriate headers needed by the library. -# -# Programmer: Quincey Koziol -# Creation Date: 2007/07/10 - -############################################################################## -# Print the copyright into an open file -# -sub print_copyright ($) { - my $fh = shift; - - print $fh "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"; - print $fh " * Copyright by The HDF Group. *\n"; - print $fh " * Copyright by the Board of Trustees of the University of Illinois. *\n"; - print $fh " * All rights reserved. *\n"; - print $fh " * *\n"; - print $fh " * This file is part of HDF5. The full HDF5 copyright notice, including *\n"; - print $fh " * terms governing use, modification, and redistribution, is contained in *\n"; - print $fh " * the files COPYING and Copyright.html. COPYING can be found at the root *\n"; - print $fh " * of the source code distribution tree; Copyright.html can be found at the *\n"; - print $fh " * root level of an installed copy of the electronic HDF5 document set and *\n"; - print $fh " * is linked from the top-level documents page. It can also be found at *\n"; - print $fh " * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n"; - print $fh " * access to either file, you may request a copy from help\@hdfgroup.org. *\n"; - print $fh " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n"; -} - -############################################################################## -# Print the "do not change this file" warning -# -sub print_warning ($) { - my $fh = shift; - - print $fh "\n/* Generated automatically by bin/make_vers -- do not edit */\n"; - print $fh "/* Add new versioned symbols to H5vers.txt file */\n\n"; -} - -############################################################################## -# Print start of ifdef's to prevent a file from being re-included -# -sub print_startprotect ($$) { - my ($fh, $file) = @_; - - # Clip off the ".h" part of the name - $file =~ s/(\w*)\.h/$1/; - - # Print the ifdef info - print $fh "\n#ifndef _${file}_H\n"; - print $fh "#define _${file}_H\n"; -} - -############################################################################## -# Print check for conflicting version macro settings -# -sub print_checkoptions ($) { - my $fh = shift; # File handle for output file - my $curr_idx; # Current API version index - - # Print the option checking - print $fh "\n/* Issue error if contradicting macros have been defined. */\n"; - - # Print the #ifdef - print $fh "#if ("; - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { - print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)"; - if($curr_idx < ($max_idx - 1)) { - print $fh " || "; - } - } - print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS)\n"; - - # Print the error for bad API version chosen - print $fh ' ' x $indent, "#error \"Can't choose old API versions when deprecated APIs are disabled\"\n"; - - # Print the #endif - print $fh "#endif /* ("; - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { - print $fh "defined(H5_USE_1", ($curr_idx * 2), "_API)"; - if($curr_idx < ($max_idx - 1)) { - print $fh " || "; - } - } - print $fh ") && defined(H5_NO_DEPRECATED_SYMBOLS) */\n"; -} - -############################################################################## -# Print "global" API version macro settings -# -sub print_globalapivers ($) { - my $fh = shift; # File handle for output file - my $curr_idx; # Current API version index - - # Print the descriptive comment - print $fh "\n\n/* If a particular \"global\" version of the library's interfaces is chosen,\n"; - print $fh " * set the versions for the API symbols affected.\n"; - print $fh " *\n"; - print $fh " * Note: If an application has already chosen a particular version for an\n"; - print $fh " * API symbol, the individual API version macro takes priority.\n"; - print $fh " */\n"; - - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { - # Print API version ifdef - print $fh "#if defined(H5_USE_1", ($curr_idx * 2), "_API_DEFAULT) && !defined(H5_USE_1", ($curr_idx * 2), "_API)\n"; - # Print API version definition - print $fh " " x $indent, "#define H5_USE_1", ($curr_idx * 2), "_API 1\n"; - # Print API version endif - print $fh "#endif /* H5_USE_1", ($curr_idx * 2), "_API_DEFAULT && !H5_USE_1", ($curr_idx * 2), "_API */\n\n"; - } - - # Loop over supported older library APIs and define the appropriate macros - for $curr_idx ($min_sup_idx .. ($max_idx - 1)) { - # Print API version ifdef - print $fh "\n#ifdef H5_USE_1", ($curr_idx * 2), "_API\n"; - - # Print the version macro info for each function that is defined for - # this API version - print $fh "\n/*************/\n"; - print $fh "/* Functions */\n"; - print $fh "/*************/\n"; - for $name (sort keys %{$func_vers[$curr_idx]}) { - print $fh "\n#if !defined(", $name, "_vers)\n"; - print $fh " " x $indent, "#define ", $name, "_vers $func_vers[$curr_idx]{$name}\n"; - print $fh "#endif /* !defined(", $name, "_vers) */\n"; - } - - # Print the version macro info for each typedef that is defined for - # this API version - print $fh "\n/************/\n"; - print $fh "/* Typedefs */\n"; - print $fh "/************/\n"; - for $name (sort keys %{$type_vers[$curr_idx]}) { - print $fh "\n#if !defined(", $name, "_t_vers)\n"; - print $fh " " x $indent, "#define ", $name, "_t_vers $type_vers[$curr_idx]{$name}\n"; - print $fh "#endif /* !defined(", $name, "_t_vers) */\n"; - } - - # Print API version endif - print $fh "\n#endif /* H5_USE_1", ($curr_idx * 2), "_API */\n"; - } -} - -############################################################################## -# Print "default" API version macro settings -# -sub print_defaultapivers ($) { - my $fh = shift; # File handle for output file - my $curr_name; # Current API function - - # Print the descriptive comment - print $fh "\n\n/* Choose the correct version of each API symbol, defaulting to the latest\n"; - print $fh " * version of each. The \"best\" name for API parameters/data structures\n"; - print $fh " * that have changed definitions is also set. An error is issued for\n"; - print $fh " * specifying an invalid API version.\n"; - print $fh " */\n"; - - # Loop over function names that are versioned and set up the version macros - print $fh "\n/*************/\n"; - print $fh "/* Functions */\n"; - print $fh "/*************/\n"; - for $curr_name (sort keys %functions) { - my $curr_vers_name; # Name of version macro for current function - my $curr_vers; # Version of function - my @param_list; # Typedefs for the function parameters - - # Set up variables for later use - $curr_vers_name = $curr_name . "_vers"; - $curr_vers = $functions{$curr_name}; - - # Split up parameter info - @param_list = split(/\s*,\s*/, $func_params{$curr_name}); -#print "print_defaultapivers: param_list=(@param_list)\n"; - - # Set up default/latest version name mapping - print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n"; - print $fh " " x $indent, "#ifndef $curr_vers_name\n"; - print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n"; - print $fh " " x $indent, "#endif /* $curr_vers_name */\n"; - print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n"; - - # Print function's dependent parameter types - foreach(sort(@param_list)) { - print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n"; - } - - # Loop to print earlier version name mappings - $curr_vers--; - while($curr_vers > 0) { - print $fh "#elif $curr_vers_name == $curr_vers\n"; - print $fh " " x $indent, "#define $curr_name $curr_name$curr_vers\n"; - - # Print function's dependent parameter types - foreach(sort(@param_list)) { - print $fh " " x $indent, "#define ${_}_t $_${curr_vers}_t\n"; - } - - $curr_vers--; - } - - # Finish up with error for unknown version and endif - print $fh "#else /* $curr_vers_name */\n"; - print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n"; - print $fh "#endif /* $curr_vers_name */\n"; - } - - # Loop over typedefs that are versioned and set up the version macros - print $fh "\n/************/\n"; - print $fh "/* Typedefs */\n"; - print $fh "/************/\n"; - for $curr_name (sort keys %typedefs) { - my $curr_vers_name; # Name of version macro for current function - my $curr_vers; # Version of function - - # Set up variables for later use - $curr_vers_name = $curr_name . "_t_vers"; - $curr_vers = $typedefs{$curr_name}; - - # Set up default/latest version name mapping - print $fh "\n#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n"; - print $fh " " x $indent, "#ifndef $curr_vers_name\n"; - print $fh " " x ($indent * 2), "#define $curr_vers_name $curr_vers\n"; - print $fh " " x $indent, "#endif /* $curr_vers_name */\n"; - print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n"; - - # Loop to print earlier version name mappings - $curr_vers--; - while($curr_vers > 0) { - print $fh "#elif $curr_vers_name == $curr_vers\n"; - print $fh " " x $indent, "#define ${curr_name}_t $curr_name${curr_vers}_t\n"; - $curr_vers--; - } - - # Finish up with error for unknown version and endif - print $fh "#else /* $curr_vers_name */\n"; - print $fh " " x $indent, "#error \"$curr_vers_name set to invalid value\"\n"; - print $fh "#endif /* $curr_vers_name */\n\n"; - } -} - -############################################################################## -# Print end of ifdef's to prevent a file from being re-included -# -sub print_endprotect ($$) { - my ($fh, $file) = @_; - - # Clip off the ".h" part of the name - $file =~ s/(\w*)\.h/$1/; - - # Print the endif info - print $fh "#endif /* ${file}_H */\n\n"; -} - -############################################################################## -# Parse a meaningful line (not a comment or blank line) into the appropriate -# data structure -# -sub parse_line ($) { - my $line = shift; # Get the line to parse - - # Parse API function lines -#print "line=$line\n"; - if($line =~ /^\s*FUNCTION:/ || $line =~ /^\s*TYPEDEF:/) { - my $name; # The name of the function - my $params; # Typedefs for function parameters - my $vers; # The version info for the function - my @vers_list; # Version info, as a list - my @vers_nums; # Version info, as a numeric list - my $num_versions; # Number of versions for function - my %sym_versions; # Versions for a symbol - my $last_idx; # The previous version index seen for a function - my $last_vers; # The previous version # seen for a function - my $line_type; # Type of line we are parsing - - # Determine the type of the line to parse - if($line =~ /^\s*FUNCTION:/) { - $line_type = 1; - # Get the function's name & version info - ($name, $params, $vers) = ($line =~ /^\s*FUNCTION:\s*(\w*);\s*(.*?)\s*;\s*(.*?)\s*$/); -#print "parse_line: name='$name', params='$params', vers='$vers'\n"; - } - elsif($line =~ /^\s*TYPEDEF:/) { - $line_type = 2; - - # Get the typedefs's name & version info - ($name, $vers) = ($line =~ /^\s*TYPEDEF:\s*(\w*);\s*(.*?)\s*$/); -#print "parse_line: name='$name', vers='$vers'\n"; - } -#print "parse_line: line_type='$line_type'\n"; - - - # Check if the name already exists in the list of symbols - if(exists($functions{$name}) || exists($typedefs{$name})) { - die "duplicated symbol: $name"; - } - - # Check for no version info given - if($vers eq "") { - die "no version information: $name"; - } - - # Split up version info - @vers_list = split(/\s*,\s*/, $vers); -#print "parse_line: vers_list=(@vers_list)\n"; - - # Parse the version list into numbers, checking for invalid input - foreach(@vers_list) { - my $vers_idx; # Index of version in array - - # Do some validation on the input - if(!( $_ =~ /v1[02468]/ || $_ =~ /v11[02468]/ )) { - die "bad version information: $name"; - } - if(exists($sym_versions{$_})) { - die "duplicate version information: $name"; - } - - # Store the versions for the function in a local hash table, indexed by the version - $sym_versions{$_}=$_; - -#print "parse_line: _=$_\n"; - # Get the index of the version - ($vers_idx) = ($_ =~ /v1(\d+)/); - $vers_idx /= 2; -#print "parse_line: vers_idx='$vers_idx'\n"; - push(@vers_nums, $vers_idx); - } -#print "parse_line: vers_nums=(@vers_nums)\n"; - - # Check for invalid version info given - $last_idx = -1; - $last_vers = 1; - foreach(sort(@vers_nums)) { -#print "parse_line: _=$_ last_idx='$last_idx'\n"; - # Update intermediate versions of the library that included the API routine - if($last_idx >= 0) { -#print "parse_line: name='$name'\n"; -#print "parse_line: last_vers='$last_vers'\n"; -#print "parse_line: last_idx='$last_idx'\n"; - - # Add the function to the list of API routines available in - # different versions of the library - while($last_idx <= $_) { - if($line_type == 1) { - $func_vers[$last_idx]{$name} = $last_vers; - } elsif($line_type == 2) { - $type_vers[$last_idx]{$name} = $last_vers; - } else { - die "unknown line type: $line"; - } - $last_idx++; - } - - # Increment the version # of the function - $last_vers++; - } - - # Keep track of last version index seen - $last_idx = $_; - } - - # Finish updating versions of the library that included the API routine - if($last_idx >= 0) { -#print "parse_line: max_idx='$max_idx'\n"; - - # Add the function to the list of API routines available in - # different versions of the library - while($last_idx <= $max_idx) { - if($line_type == 1) { - $func_vers[$last_idx]{$name} = $last_vers; - } elsif($line_type == 2) { - $type_vers[$last_idx]{$name} = $last_vers; - } else { - die "unknown line type: $line"; - } - $last_idx++; - } - } - - # Store the number of symbol versions in a hash table, indexed by the name - if($line_type == 1) { - $functions{$name} = $#vers_list + 1; - - # Store the function's parameter types for later - $func_params{$name} = $params; - } elsif($line_type == 2) { - $typedefs{$name} = $#vers_list + 1; - } else { - die "unknown line type: $line"; - } - } - # Unknown keyword - else { - die "unknown keyword: $line"; - } -} - -############################################################################## -# Create the generated portion of the public header file -# -sub create_public ($) { - my $prefix = shift; # Get the prefix for the generated file - my $file = "H5version.h"; # Name of file to generate - my $name; # Name of function - - # Rename previous file -# rename "${prefix}${file}", "${prefix}${file}~" or die "unable to make backup"; - - # Open new header file - open HEADER, ">${prefix}${file}" or die "unable to modify source"; - - # Create file contents - print_copyright(*HEADER); - print_warning(*HEADER); - print_startprotect(*HEADER, $file); - print_checkoptions(*HEADER); - print_globalapivers(*HEADER); - print_defaultapivers(*HEADER); - print_endprotect(*HEADER, $file); - - # Close header file - close HEADER; -} - -############################################################################## -# Read symbol version file (given as command-line argument) in and process it -# into internal data structures, then create header files. -# -for $file (@ARGV) { - my $prefix; # Local prefix for generated files - -#print "file = '$file'\n"; - # Check for directory prefix on input file - if($file =~ /\//) { - ($prefix) = ($file =~ /(^.*\/)/); - } - else { - $prefix = ""; - } -#print "prefix = '$prefix'\n"; - # Read in the entire file - open SOURCE, $file or die "$file: $!\n"; - while ( defined ($line=) ) { - # Skip blank lines and those lines whose first character is a '#' - if(!($line =~ /(^\s*#.*$)|(^\s*$)/)) { - # Construct data structures for later printing - parse_line($line); - } - } - close SOURCE; - - # Create header files - print "Generating '", $prefix, "H5version.h'\n"; - create_public($prefix); - -#for $name (sort keys %functions) { -# print "functions{$name} = $functions{$name}\n"; -#} - -#for $i (0 .. $#func_vers) { -# my $vers_name; # Name of indexed version -# $vers_name = "v1." . ($i * 2); -# print "$vers_name functions: "; -# for $name (sort keys %{$func_vers[$i]}) { -# print "$name$func_vers[$i]{$name} "; -# } -# print "\n"; -#} - -} - diff --git a/bin/release b/bin/release index 1eea9b4..703916b 100755 --- a/bin/release +++ b/bin/release @@ -159,7 +159,7 @@ fi # Defaults DEST=releases -VERS=`perl bin/h5vers.pl` +VERS=`perl bin/h5vers` VERS_OLD= test "$VERS" || exit 1 verbose=yes @@ -178,7 +178,7 @@ RESTORE_VERSION() echo restoring version information back to $VERS_OLD rm -f config/lt_vers.am cp $tmpdir/lt_vers.am config/lt_vers.am - bin/h5vers.pl -s $VERS_OLD + bin/h5vers -s $VERS_OLD VERS_OLD= fi } @@ -240,7 +240,7 @@ if [ X$pmode = Xyes ]; then # (h5vers does not correctly handle just m.n.r-$today.) VERS=`echo $VERS | sed -e s/-.*//`-of$today echo Private release of $VERS - bin/h5vers.pl -s $VERS + bin/h5vers -s $VERS fi # Store hdf5-$VERS ("hdf5-1.7.51", e.g.) to a variable to avoid typos diff --git a/bin/snapshot b/bin/snapshot index 4a94ff4..a496edd 100755 --- a/bin/snapshot +++ b/bin/snapshot @@ -466,10 +466,10 @@ if [ "$cmd" = "all" -o -n "$cmdrel" ]; then # commit source if errors encounter here. set -e cd ${CURRENT} - RELEASE_VERSION="`perl bin/h5vers.pl -v`" + RELEASE_VERSION="`perl bin/h5vers -v`" echo "Making snapshot release ($RELEASE_VERSION) to ${ReleaseDir}..." bin/release -d $ReleaseDir $METHODS - perl bin/h5vers.pl -i + perl bin/h5vers -i svn -q commit -m "Snapshot $RELEASE_VERSION" ) errcode=$? diff --git a/bin/trace b/bin/trace new file mode 100755 index 0000000..da6673c --- /dev/null +++ b/bin/trace @@ -0,0 +1,337 @@ +#!/usr/bin/perl -w +## +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +## +require 5.003; +$Source = ""; + +############################################################################## +# A map from type name to type letter. We use this map for two reasons: +# 1. We want the debugging stuff in the source code to be as unobtrusive as +# possible, which means as compact as possible. +# 2. It's easier (faster) to parse these one and two-letter types in the C +# functions that display debugging results. +# +# All type strings are one or two characters. One-character strings +# are always lower case and should be used for common types. +# Two-character strings begin with an upper-case letter which is +# usually the same as the package name. +# +%TypeString = ("haddr_t" => "a", + "hbool_t" => "b", + "double" => "d", + "H5D_alloc_time_t" => "Da", + "H5FD_mpio_collective_opt_t" => "Dc", + "H5D_fill_time_t" => "Df", + "H5D_fill_value_t" => "DF", + "H5FD_mpio_chunk_opt_t" => "Dh", + "H5D_mpio_actual_io_mode_t" => "Di", + "H5D_layout_t" => "Dl", + "H5D_mpio_no_collective_cause_t" => "Dn", + "H5D_mpio_actual_chunk_opt_mode_t" => "Do", + "H5D_space_status_t" => "Ds", + "H5FD_mpio_xfer_t" => "Dt", + "herr_t" => "e", + "H5E_direction_t" => "Ed", + "H5E_error_t" => "Ee", + "H5E_type_t" => "Et", + "H5F_close_degree_t" => "Fd", + "H5F_file_space_type_t" => "Ff", + "H5F_mem_t" => "Fm", + "H5F_scope_t" => "Fs", + "H5F_libver_t" => "Fv", + "H5G_obj_t" => "Go", + "H5G_stat_t" => "Gs", + "hsize_t" => "h", + "hssize_t" => "Hs", + "H5E_major_t" => "i", + "H5E_minor_t" => "i", + "H5_iter_order_t" => "Io", + "H5_index_t" => "Ii", + "hid_t" => "i", + "int" => "Is", + "int32_t" => "Is", + "unsigned" => "Iu", + "unsigned int" => "Iu", + "uint32_t" => "Iu", + "H5I_type_t" => "It", + "H5G_link_t" => "Ll", #Same as H5L_type_t now + "H5L_type_t" => "Ll", + "MPI_Comm" => "Mc", + "MPI_Info" => "Mi", + "H5FD_mem_t" => "Mt", + "off_t" => "o", + "H5O_type_t" => "Ot", + "H5P_class_t" => "p", + "hobj_ref_t" => "r", + "H5R_type_t" => "Rt", + "char" => "s", + "unsigned char" => "s", + "H5S_class_t" => "Sc", + "H5S_seloper_t" => "Ss", + "H5S_sel_type" => "St", + "htri_t" => "t", + "H5T_cset_t", => "Tc", + "H5T_direction_t", => "Td", + "H5T_norm_t" => "Tn", + "H5T_order_t" => "To", + "H5T_pad_t" => "Tp", + "H5T_pers_t" => "Te", + "H5T_sign_t" => "Ts", + "H5T_class_t" => "Tt", + "H5T_str_t" => "Tz", + "unsigned long" => "Ul", + "unsigned long long" => "UL", + "void" => "x", + "FILE" => "x", + "H5A_operator_t" => "x", + "H5A_operator1_t" => "x", + "H5A_operator2_t" => "x", + "H5A_info_t" => "x", + "H5AC_cache_config_t" => "x", + "H5D_gather_func_t" => "x", + "H5D_operator_t" => "x", + "H5D_scatter_func_t" => "x", + "H5E_auto_t" => "x", + "H5E_auto1_t" => "x", + "H5E_auto2_t" => "x", + "H5E_walk_t" => "x", + "H5E_walk1_t" => "x", + "H5E_walk2_t" => "x", + "H5F_info1_t" => "x", + "H5F_info2_t" => "x", + "H5FD_t" => "x", + "H5FD_class_t" => "x", + "H5FD_stream_fapl_t" => "x", + "H5FD_file_image_callbacks_t" => "x", + "H5G_iterate_t" => "x", + "H5G_info_t" => "x", + "H5I_free_t" => "x", + "H5I_search_func_t" => "x", + "H5L_class_t" => "x", + "H5L_elink_traverse_t" => "x", + "H5L_iterate_t" => "x", + "H5MM_allocate_t" => "x", + "H5MM_free_t" => "x", + "H5O_info_t" => "x", + "H5O_iterate_t" => "x", + "H5O_mcdt_search_cb_t" => "x", + "H5P_cls_create_func_t" => "x", + "H5P_cls_copy_func_t" => "x", + "H5P_cls_close_func_t" => "x", + "H5P_iterate_t" => "x", + "H5P_prp_create_func_t" => "x", + "H5P_prp_copy_func_t" => "x", + "H5P_prp_close_func_t" => "x", + "H5P_prp_delete_func_t" => "x", + "H5P_prp_get_func_t" => "x", + "H5P_prp_set_func_t" => "x", + "H5P_prp_compare_func_t" => "x", + "H5T_cdata_t" => "x", + "H5T_conv_t" => "x", + "H5T_conv_except_func_t" => "x", + "H5Z_func_t" => "x", + "H5Z_filter_func_t" => "x", + "va_list" => "x", + "size_t" => "z", + "H5Z_SO_scale_type_t" => "Za", + "H5Z_class_t" => "Zc", + "H5Z_EDC_t" => "Ze", + "H5Z_filter_t" => "Zf", + "ssize_t" => "Zs", + ); + +############################################################################## +# Print an error message. +# +sub errmesg ($$@) { + my ($file, $func, @mesg) = @_; + my ($mesg) = join "", @mesg; + my ($lineno) = 1; + if ($Source =~ /(.*?\n)($func)/s) { + local $_ = $1; + $lineno = tr/\n/\n/; + } + + print "$file: in function \`$func\':\n"; + print "$file:$lineno: $mesg\n"; +} + +############################################################################## +# Given a C data type return the type string that goes with it. +# +sub argstring ($$$) { + my ($file, $func, $atype) = @_; + my ($ptr, $tstr, $array) = (0, "!", ""); + my ($fq_atype); + + # Normalize the data type by removing redundant white space, + # certain type qualifiers, and indirection. + $atype =~ s/^\bconst\b//; + $atype =~ s/\bH5_ATTR_UNUSED\b//g; + $atype =~ s/\s+/ /g; + $ptr = length $1 if $atype =~ s/(\*+)//; + $atype =~ s/^\s+//; + $atype =~ s/\s+$//; + if ($atype =~ /(.*)\[(.*)\]$/) { + ($array, $atype) = ($2, $1); + $atype =~ s/\s+$//; + } + $fq_atype = $atype . ('*' x $ptr); + + if ($ptr>0 && exists $TypeString{$fq_atype}) { + $ptr = 0; + $tstr = $TypeString{$fq_atype}; + } elsif ($ptr>0 && exists $TypeString{"$atype*"}) { + --$ptr; + $tstr = $TypeString{"$atype*"}; + } elsif (!exists $TypeString{$atype}) { + errmesg $file, $func, "untraceable type \`$atype", '*'x$ptr, "\'"; + } else { + $tstr = $TypeString{$atype}; + } + return ("*" x $ptr) . ($array?"[$array]":"") . $tstr; +} + +############################################################################## +# Given information about an API function, rewrite that function with +# updated tracing information. +# +sub rewrite_func ($$$$$) { + my ($file, $type, $name, $args, $body) = @_; + my ($arg,$trace); + my (@arg_name, @arg_str); + local $_; + + # Parse return value + my $rettype = argstring $file, $name, $type; + goto error if $rettype =~ /!/; + + # Parse arguments + if ($args eq "void") { + $trace = "H5TRACE0(\"$rettype\",\"\");\n"; + } else { + # Split arguments. First convert `/*in,out*/' to get rid of the + # comma, then split the arguments on commas. + $args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g; + my @args = split /,[\s\n]*/, $args; + my $argno = 0; + my %names; + + for $arg (@args) { + if($arg=~/\w*\.{3}\w*/){ + next; + } + unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**) + ([a-z_A-Z]\w*)(\[.*?\])? + (\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) { + errmesg $file, $name, "unable to parse \`$arg\'"; + goto error; + } else { + my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6); + $names{$aname} = $argno++; + $adir ||= "in"; + $atype =~ s/\s+$//; + push @arg_name, $aname; + + if ($adir eq "out") { + push @arg_str, "x"; + } else { + if (defined $array) { + $atype .= "*"; + if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) { + my $asize = $1; + if (exists $names{$asize}) { + $atype .= '[a' . $names{$asize} . ']'; + } else { + warn "bad array size: $asize"; + $atype .= "*"; + } + } + } + push @arg_str, argstring $file, $name, $atype; + } + } + } + $trace = "H5TRACE" . scalar(@arg_str) . "(\"$rettype\", \""; + $trace .= join("", @arg_str) . "\""; + my $len = 4 + length $trace; + for (@arg_name) { + if ($len + length >= 77) { + $trace .= ",\n $_"; + $len = 13 + length; + } else { + $trace .= ", $_"; + $len += 1 + length; + } + } + $trace .= ");\n"; + } + goto error if grep {/!/} @arg_str; + + # The H5TRACE() statement + if ($body =~ /\/\*[ \t]*NO[ \t]*TRACE[ \t]*\*\//) { + # Ignored due to NO TRACE comment. + } elsif ($body =~ s/((\n[ \t]*)H5TRACE\d+\s*\(.*?\);)\n/"$2$trace"/es) { + # Replaced an H5TRACE macro. + } elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\w*\s*(\(.*?\))?;??)\n/"$1$2$trace"/es) { + # Added an H5TRACE macro after a FUNC_ENTER macro. + } else { + errmesg $file, $name, "unable to insert tracing information"; + print "body = ", $body, "\n"; + goto error; + } + + + error: + return "\n$type\n$name($args)\n$body"; +} + +############################################################################## +# Process each source file, rewriting API functions with updated +# tracing information. +# +my $total_api = 0; +for $file (@ARGV) { + # Ignore some files that do not need tracing macros + unless ($file eq "H5FDmulti.c" or $file eq "src/H5FDmulti.c" or $file eq "H5FDstdio.c" or $file eq "src/H5FDstdio.c") { + + # Snarf up the entire file + open SOURCE, $file or die "$file: $!\n"; + $Source = join "", ; + close SOURCE; + + # Make modifications + my $original = $Source; + my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**)\n #type + (H5[A-Z]{0,2}[^_A-Z0-9]\w*) #name + \s*\((.*?)\)\s* #args + (\{.*?\n\}[^\n]*) #body + /rewrite_func($file,$1,$3,$4,$5)/segx; + $total_api += $napi; + +# If the source changed then print out the new version + if ($original ne $Source) { + printf "%s: instrumented %d API function%s\n", + $file, $napi, 1==$napi?"":"s"; + rename $file, "$file~" or die "unable to make backup"; + open SOURCE, ">$file" or die "unable to modify source"; + print SOURCE $Source; + close SOURCE; + } + } +} + +printf "Finished processing HDF5 API calls\n" + diff --git a/bin/trace.pl b/bin/trace.pl deleted file mode 100755 index da6673c..0000000 --- a/bin/trace.pl +++ /dev/null @@ -1,337 +0,0 @@ -#!/usr/bin/perl -w -## -# Copyright by The HDF Group. -# Copyright by the Board of Trustees of the University of Illinois. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -## -require 5.003; -$Source = ""; - -############################################################################## -# A map from type name to type letter. We use this map for two reasons: -# 1. We want the debugging stuff in the source code to be as unobtrusive as -# possible, which means as compact as possible. -# 2. It's easier (faster) to parse these one and two-letter types in the C -# functions that display debugging results. -# -# All type strings are one or two characters. One-character strings -# are always lower case and should be used for common types. -# Two-character strings begin with an upper-case letter which is -# usually the same as the package name. -# -%TypeString = ("haddr_t" => "a", - "hbool_t" => "b", - "double" => "d", - "H5D_alloc_time_t" => "Da", - "H5FD_mpio_collective_opt_t" => "Dc", - "H5D_fill_time_t" => "Df", - "H5D_fill_value_t" => "DF", - "H5FD_mpio_chunk_opt_t" => "Dh", - "H5D_mpio_actual_io_mode_t" => "Di", - "H5D_layout_t" => "Dl", - "H5D_mpio_no_collective_cause_t" => "Dn", - "H5D_mpio_actual_chunk_opt_mode_t" => "Do", - "H5D_space_status_t" => "Ds", - "H5FD_mpio_xfer_t" => "Dt", - "herr_t" => "e", - "H5E_direction_t" => "Ed", - "H5E_error_t" => "Ee", - "H5E_type_t" => "Et", - "H5F_close_degree_t" => "Fd", - "H5F_file_space_type_t" => "Ff", - "H5F_mem_t" => "Fm", - "H5F_scope_t" => "Fs", - "H5F_libver_t" => "Fv", - "H5G_obj_t" => "Go", - "H5G_stat_t" => "Gs", - "hsize_t" => "h", - "hssize_t" => "Hs", - "H5E_major_t" => "i", - "H5E_minor_t" => "i", - "H5_iter_order_t" => "Io", - "H5_index_t" => "Ii", - "hid_t" => "i", - "int" => "Is", - "int32_t" => "Is", - "unsigned" => "Iu", - "unsigned int" => "Iu", - "uint32_t" => "Iu", - "H5I_type_t" => "It", - "H5G_link_t" => "Ll", #Same as H5L_type_t now - "H5L_type_t" => "Ll", - "MPI_Comm" => "Mc", - "MPI_Info" => "Mi", - "H5FD_mem_t" => "Mt", - "off_t" => "o", - "H5O_type_t" => "Ot", - "H5P_class_t" => "p", - "hobj_ref_t" => "r", - "H5R_type_t" => "Rt", - "char" => "s", - "unsigned char" => "s", - "H5S_class_t" => "Sc", - "H5S_seloper_t" => "Ss", - "H5S_sel_type" => "St", - "htri_t" => "t", - "H5T_cset_t", => "Tc", - "H5T_direction_t", => "Td", - "H5T_norm_t" => "Tn", - "H5T_order_t" => "To", - "H5T_pad_t" => "Tp", - "H5T_pers_t" => "Te", - "H5T_sign_t" => "Ts", - "H5T_class_t" => "Tt", - "H5T_str_t" => "Tz", - "unsigned long" => "Ul", - "unsigned long long" => "UL", - "void" => "x", - "FILE" => "x", - "H5A_operator_t" => "x", - "H5A_operator1_t" => "x", - "H5A_operator2_t" => "x", - "H5A_info_t" => "x", - "H5AC_cache_config_t" => "x", - "H5D_gather_func_t" => "x", - "H5D_operator_t" => "x", - "H5D_scatter_func_t" => "x", - "H5E_auto_t" => "x", - "H5E_auto1_t" => "x", - "H5E_auto2_t" => "x", - "H5E_walk_t" => "x", - "H5E_walk1_t" => "x", - "H5E_walk2_t" => "x", - "H5F_info1_t" => "x", - "H5F_info2_t" => "x", - "H5FD_t" => "x", - "H5FD_class_t" => "x", - "H5FD_stream_fapl_t" => "x", - "H5FD_file_image_callbacks_t" => "x", - "H5G_iterate_t" => "x", - "H5G_info_t" => "x", - "H5I_free_t" => "x", - "H5I_search_func_t" => "x", - "H5L_class_t" => "x", - "H5L_elink_traverse_t" => "x", - "H5L_iterate_t" => "x", - "H5MM_allocate_t" => "x", - "H5MM_free_t" => "x", - "H5O_info_t" => "x", - "H5O_iterate_t" => "x", - "H5O_mcdt_search_cb_t" => "x", - "H5P_cls_create_func_t" => "x", - "H5P_cls_copy_func_t" => "x", - "H5P_cls_close_func_t" => "x", - "H5P_iterate_t" => "x", - "H5P_prp_create_func_t" => "x", - "H5P_prp_copy_func_t" => "x", - "H5P_prp_close_func_t" => "x", - "H5P_prp_delete_func_t" => "x", - "H5P_prp_get_func_t" => "x", - "H5P_prp_set_func_t" => "x", - "H5P_prp_compare_func_t" => "x", - "H5T_cdata_t" => "x", - "H5T_conv_t" => "x", - "H5T_conv_except_func_t" => "x", - "H5Z_func_t" => "x", - "H5Z_filter_func_t" => "x", - "va_list" => "x", - "size_t" => "z", - "H5Z_SO_scale_type_t" => "Za", - "H5Z_class_t" => "Zc", - "H5Z_EDC_t" => "Ze", - "H5Z_filter_t" => "Zf", - "ssize_t" => "Zs", - ); - -############################################################################## -# Print an error message. -# -sub errmesg ($$@) { - my ($file, $func, @mesg) = @_; - my ($mesg) = join "", @mesg; - my ($lineno) = 1; - if ($Source =~ /(.*?\n)($func)/s) { - local $_ = $1; - $lineno = tr/\n/\n/; - } - - print "$file: in function \`$func\':\n"; - print "$file:$lineno: $mesg\n"; -} - -############################################################################## -# Given a C data type return the type string that goes with it. -# -sub argstring ($$$) { - my ($file, $func, $atype) = @_; - my ($ptr, $tstr, $array) = (0, "!", ""); - my ($fq_atype); - - # Normalize the data type by removing redundant white space, - # certain type qualifiers, and indirection. - $atype =~ s/^\bconst\b//; - $atype =~ s/\bH5_ATTR_UNUSED\b//g; - $atype =~ s/\s+/ /g; - $ptr = length $1 if $atype =~ s/(\*+)//; - $atype =~ s/^\s+//; - $atype =~ s/\s+$//; - if ($atype =~ /(.*)\[(.*)\]$/) { - ($array, $atype) = ($2, $1); - $atype =~ s/\s+$//; - } - $fq_atype = $atype . ('*' x $ptr); - - if ($ptr>0 && exists $TypeString{$fq_atype}) { - $ptr = 0; - $tstr = $TypeString{$fq_atype}; - } elsif ($ptr>0 && exists $TypeString{"$atype*"}) { - --$ptr; - $tstr = $TypeString{"$atype*"}; - } elsif (!exists $TypeString{$atype}) { - errmesg $file, $func, "untraceable type \`$atype", '*'x$ptr, "\'"; - } else { - $tstr = $TypeString{$atype}; - } - return ("*" x $ptr) . ($array?"[$array]":"") . $tstr; -} - -############################################################################## -# Given information about an API function, rewrite that function with -# updated tracing information. -# -sub rewrite_func ($$$$$) { - my ($file, $type, $name, $args, $body) = @_; - my ($arg,$trace); - my (@arg_name, @arg_str); - local $_; - - # Parse return value - my $rettype = argstring $file, $name, $type; - goto error if $rettype =~ /!/; - - # Parse arguments - if ($args eq "void") { - $trace = "H5TRACE0(\"$rettype\",\"\");\n"; - } else { - # Split arguments. First convert `/*in,out*/' to get rid of the - # comma, then split the arguments on commas. - $args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g; - my @args = split /,[\s\n]*/, $args; - my $argno = 0; - my %names; - - for $arg (@args) { - if($arg=~/\w*\.{3}\w*/){ - next; - } - unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**) - ([a-z_A-Z]\w*)(\[.*?\])? - (\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) { - errmesg $file, $name, "unable to parse \`$arg\'"; - goto error; - } else { - my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6); - $names{$aname} = $argno++; - $adir ||= "in"; - $atype =~ s/\s+$//; - push @arg_name, $aname; - - if ($adir eq "out") { - push @arg_str, "x"; - } else { - if (defined $array) { - $atype .= "*"; - if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) { - my $asize = $1; - if (exists $names{$asize}) { - $atype .= '[a' . $names{$asize} . ']'; - } else { - warn "bad array size: $asize"; - $atype .= "*"; - } - } - } - push @arg_str, argstring $file, $name, $atype; - } - } - } - $trace = "H5TRACE" . scalar(@arg_str) . "(\"$rettype\", \""; - $trace .= join("", @arg_str) . "\""; - my $len = 4 + length $trace; - for (@arg_name) { - if ($len + length >= 77) { - $trace .= ",\n $_"; - $len = 13 + length; - } else { - $trace .= ", $_"; - $len += 1 + length; - } - } - $trace .= ");\n"; - } - goto error if grep {/!/} @arg_str; - - # The H5TRACE() statement - if ($body =~ /\/\*[ \t]*NO[ \t]*TRACE[ \t]*\*\//) { - # Ignored due to NO TRACE comment. - } elsif ($body =~ s/((\n[ \t]*)H5TRACE\d+\s*\(.*?\);)\n/"$2$trace"/es) { - # Replaced an H5TRACE macro. - } elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\w*\s*(\(.*?\))?;??)\n/"$1$2$trace"/es) { - # Added an H5TRACE macro after a FUNC_ENTER macro. - } else { - errmesg $file, $name, "unable to insert tracing information"; - print "body = ", $body, "\n"; - goto error; - } - - - error: - return "\n$type\n$name($args)\n$body"; -} - -############################################################################## -# Process each source file, rewriting API functions with updated -# tracing information. -# -my $total_api = 0; -for $file (@ARGV) { - # Ignore some files that do not need tracing macros - unless ($file eq "H5FDmulti.c" or $file eq "src/H5FDmulti.c" or $file eq "H5FDstdio.c" or $file eq "src/H5FDstdio.c") { - - # Snarf up the entire file - open SOURCE, $file or die "$file: $!\n"; - $Source = join "", ; - close SOURCE; - - # Make modifications - my $original = $Source; - my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**)\n #type - (H5[A-Z]{0,2}[^_A-Z0-9]\w*) #name - \s*\((.*?)\)\s* #args - (\{.*?\n\}[^\n]*) #body - /rewrite_func($file,$1,$3,$4,$5)/segx; - $total_api += $napi; - -# If the source changed then print out the new version - if ($original ne $Source) { - printf "%s: instrumented %d API function%s\n", - $file, $napi, 1==$napi?"":"s"; - rename $file, "$file~" or die "unable to make backup"; - open SOURCE, ">$file" or die "unable to modify source"; - print SOURCE $Source; - close SOURCE; - } - } -} - -printf "Finished processing HDF5 API calls\n" - -- cgit v0.12