diff options
-rw-r--r-- | MANIFEST | 3 | ||||
-rwxr-xr-x | bin/make_vers | 348 | ||||
-rw-r--r-- | src/H5public.h | 3 | ||||
-rw-r--r-- | src/H5vers.txt | 48 | ||||
-rw-r--r-- | src/H5version.h | 44 | ||||
-rwxr-xr-x | src/Makefile.am | 29 | ||||
-rw-r--r-- | src/Makefile.in | 9 |
7 files changed, 470 insertions, 14 deletions
@@ -57,6 +57,7 @@ ./bin/locate_sw ./bin/ltmain.sh ./bin/make_err +./bin/make_vers ./bin/makehelp ./bin/missing ./bin/mkdirs @@ -414,6 +415,8 @@ ./src/H5system.c ./src/H5timer.c ./src/H5trace.c +./src/H5vers.txt +./src/H5version.h ./src/H5A.c ./src/H5Abtree2.c ./src/H5Adense.c diff --git a/bin/make_vers b/bin/make_vers new file mode 100755 index 0000000..465a308 --- /dev/null +++ b/bin/make_vers @@ -0,0 +1,348 @@ +#!/usr/bin/perl -w +require 5.003; + +# Global settings + +# Max. library "index" (0 = v1.0, 1 = 1.2, etc) +$max_idx = 4; + +# Min. supported previous library version "index" (0 = v1.0, 1 = 1.2, etc) +$min_sup_idx = 3; + +# +# 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; + + # Print the option checking + print $fh "\n/* Issue error if contradicting macros have been defined. */\n"; + print $fh "#if defined(H5_USE_16_API) && defined(H5_WITHOUT_DEPRECATED_APIS)\n"; + print $fh "#error \"Can't choose old API versions when deprecated APIs are disabled\"\n"; + print $fh "#endif /* defined(H5_USE_16_API) && defined(H5_WITHOUT_DEPRECATED_APIS) */\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/* If a particular \"global\" version of the library's interfaces is chosen,\n"; + print $fh " * set the versions for the API routines affected.\n"; + print $fh " *\n"; + print $fh " * Note: If an application has already chosen a particular version for an\n"; + print $fh " * API routine, the individual API version macro takes priority.\n"; + print $fh " */\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 "#ifdef H5_USE_1", ($curr_idx * 2), "_API\n"; + + # Print the version macro info for each function that is defined for + # this API version + for $name (sort keys %{$api_vers[$curr_idx]}) { + print $fh "#if !defined(", $name, "_vers)\n"; + print $fh "#define ", $name, "_vers $api_vers[$curr_idx]{$name}\n"; + print $fh "#endif /* !defined(", $name, "_vers) */\n"; + } + + # Print API version endif + print $fh "#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/* Choose the correct version of each API routine, defaulting to the latest\n"; + print $fh " * version of each API routine. The \"best\" name for API parameters/data\n"; + print $fh " * structures that have changed definitions is also set. An error is\n"; + print $fh " * issued for specifying an invalid API version.\n"; + print $fh " */\n"; + + # Loop over function names that are versioned and set up the version macros + for $curr_name (sort keys %functions) { + 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 . "_vers"; + $curr_vers = $functions{$curr_name}; + + # Set up default/latest version name mapping + print $fh "#if !defined($curr_vers_name) || $curr_vers_name == $curr_vers\n"; + print $fh "#define $curr_name $curr_name$curr_vers\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 "#define $curr_name $curr_name$curr_vers\n"; + $curr_vers--; + } + + # Finish up with error for unknown version and endif + print $fh "#else /* $curr_vers_name */\n"; + print $fh "#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 "\n#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,/) { + my $name; # The name of the function + my $vers; # The version info for the function + my @vers_list; # Version info, as a list + my $num_versions; # Number of versions for function + my %func_versions; # Versions for a function + my $last_idx; # The previous version index seen for a function + my $last_vers; # The previous version # seen for a function + + # Get the function's name & version info + ($name, $vers) = ($line =~ /^\s*FUNCTION,\s*(\w*),\s*(.*?)\s*$/); +#print "FUNCTION: name='$name', vers='$vers'\n"; + + # Check if the name already exists in the list of functions + if(exists($functions{$name})) { + die "duplicated name: $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 "FUNCTION: vers_list=(@vers_list)\n"; + + # Check for invalid version info given + $last_idx = -1; + $last_vers = 1; + foreach(sort(@vers_list)) { + my $vers_idx; # Index of version in array + +#print "FUNCTION: _=$_ last_idx='$last_idx'\n"; + # Do some validation on the input + if(!($_ =~ /v1[02468]/)) { + die "bad version information: $name"; + } + if(exists($func_versions{$_})) { + die "duplicate version information: $name"; + } + + # Store the versions for the function in a local hash table, indexed by the version + $func_versions{$_}=$_; + + # Get the index of the version + ($vers_idx) = ($_ =~ /v1(\d)/); + $vers_idx /= 2; +#print "FUNCTION: vers_idx='$vers_idx'\n"; + + # Update intermediate versions of the library that included the API routine + if($last_idx >= 0) { +#print "FUNCTION: last_idx='$last_idx'\n"; + + # Add the function to the list of API routines available in + # different versions of the library + while($last_idx < $vers_idx) { + $api_vers[$last_idx]{$name} = $last_vers; + $last_idx++; + } + + # Increment the version # of the function + $last_vers++; + } + + # Keep track of last version index seen + $last_idx = $vers_idx; + } + + # Finish updating versions of the library that included the API routine + if($last_idx >= 0) { +#print "FUNCTION: 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) { + $api_vers[$last_idx]{$name} = $last_vers; + $last_idx++; + } + } + + # Store the number of function versions in a hash table, indexed by the name + $functions{$name} = $#vers_list + 1; + } + # 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"; + ($prefix) = ($file =~ /(^.*\/)/); +#print "prefix = '$prefix'\n"; + # Read in the entire file + open SOURCE, $file or die "$file: $!\n"; + while ( defined ($line=<SOURCE>) ) { + # 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 'H5version.h'\n"; + create_public($prefix); + +#for $name (sort keys %functions) { +# print "functions{$name} = $functions{$name}\n"; +#} + +#for $i (0 .. $#api_vers) { +# my $vers_name; # Name of indexed version +# $vers_name = "v1." . ($i * 2); +# print "$vers_name functions: "; +# for $name (sort keys %{$api_vers[$i]}) { +# print "$name$api_vers[$i]{$name} "; +# } +# print "\n"; +#} + +} + diff --git a/src/H5public.h b/src/H5public.h index a14a554..09b2d5c 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -30,6 +30,9 @@ */ #include "H5pubconf.h" /*from configure */ +/* API Version macro wrapper definitions */ +#include "H5version.h" + #ifdef H5_HAVE_FEATURES_H #include <features.h> /*for setting POSIX, BSD, etc. compatibility */ #endif diff --git a/src/H5vers.txt b/src/H5vers.txt new file mode 100644 index 0000000..0fd4c4c --- /dev/null +++ b/src/H5vers.txt @@ -0,0 +1,48 @@ +# 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. +# + +# This file is used to generate the various headers that are needed for +# versioning the public symbols for the library. +# +# The bin/make_vers script reads in this file and creates the appropriate files +# in the src/ directory when the generated headers are out of date with respect +# to this file. +# +# Blank lines and lines beginning with '#' are ignored +# +# The format of this file is as follows: +# <type>, <base routine name>, <version introduced>, <list of revised versions> +# +# For example, the following sample input shows two functions with different +# API versions for each. The example below shows H5Gfoo being added to the +# library in the v1.0 branch and revised in the v1.4 and v1.8 branches (so +# there should be three versioned names for the routine: H5Gfoo1, H5Gfoo2 and +# H5Gfoo3). H5Gbar is shown as being added to the library in the v1.2 branch +# (so the "base" version of the API name wouldn't appear if the library +# was configured with the default API interface corresponding to v1.0) and +# revised in the v1.6 branch (so there should be two versioned names for the +# routine: H5Gbar1 and H5Gbar2). +# +# FUNCTION, H5Gfoo, v10, v14, v18 +# FUNCTION, H5Gbar, v12, v16 +# +# Programmer: Quincey Koziol +# Creation Date: 2007/07/10 + +# API function names +# (although not required, it's easier to compare this file with the headers +# generated if the list below is in alphanumeric sort order - QAK) +#FUNCTION, H5Gcreate, v10, v14, v18 +#FUNCTION, H5Gopen, v12, v18 + diff --git a/src/H5version.h b/src/H5version.h new file mode 100644 index 0000000..a74857b --- /dev/null +++ b/src/H5version.h @@ -0,0 +1,44 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Generated automatically by bin/make_vers -- do not edit */ +/* Add new versioned symbols to H5vers.txt file */ + + +#ifndef _H5version_H +#define _H5version_H + +/* Issue error if contradicting macros have been defined. */ +#if defined(H5_USE_16_API) && defined(H5_WITHOUT_DEPRECATED_APIS) +#error "Can't choose old API versions when deprecated APIs are disabled" +#endif /* defined(H5_USE_16_API) && defined(H5_WITHOUT_DEPRECATED_APIS) */ + +/* If a particular "global" version of the library's interfaces is chosen, + * set the versions for the API routines affected. + * + * Note: If an application has already chosen a particular version for an + * API routine, the individual API version macro takes priority. + */ +#ifdef H5_USE_16_API +#endif /* H5_USE_16_API */ + +/* Choose the correct version of each API routine, defaulting to the latest + * version of each API routine. The "best" name for API parameters/data + * structures that have changed definitions is also set. An error is + * issued for specifying an invalid API version. + */ + +#endif /* H5version_H */ + diff --git a/src/Makefile.am b/src/Makefile.am index 1e593d2..bef62b6 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -89,29 +89,22 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ # Public headers -include_HEADERS =H5public.h H5Apublic.h H5ACpublic.h \ - H5Cpublic.h H5Dpublic.h \ +include_HEADERS = hdf5.h H5api_adpt.h H5pubconf.h H5public.h H5version.h \ + H5Apublic.h H5ACpublic.h \ + H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h H5FDstream.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ - H5Tpublic.h H5Zpublic.h H5pubconf.h hdf5.h H5api_adpt.h + H5Tpublic.h H5Zpublic.h # install libhdf5.settings in lib directory settingsdir=$(libdir) settings_DATA=libhdf5.settings -# Error header generation -# -# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all -# depend on H5err.txt, but the perl script generates them all, so just -# list one here. -$(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt - perl $(top_srcdir)/bin/make_err $> - # Number format detection -# The LD_LIBRARY_PATH setting is a klutch. +# The LD_LIBRARY_PATH setting is a kludge. # Things should have been all set during H5detect making. # Remove the generated .c file if errors occur unless HDF5_Make_Ignore # is set to ignore the error. @@ -122,6 +115,18 @@ H5Tinit.c: H5detect$(EXEEXT) (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ ($(RM) $@ ; exit 1) +# Error header generation +# +# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all +# depend on H5err.txt, but the perl script generates them all, so just +# list one here. +$(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt + perl $(top_srcdir)/bin/make_err $? + +# API version macro generation +$(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt + perl $(top_srcdir)/bin/make_vers $? + # Add TRACE macros to library source files. This is done via the trace script # in the hdf5/bin directory. If the file contains HDF5 API macros, a "clean" # version of the source file is saved with a tilde (~) after its name and diff --git a/src/Makefile.in b/src/Makefile.in index bf9074f..c6284b6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -442,7 +442,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ # Public headers -include_HEADERS = H5public.h H5Apublic.h H5ACpublic.h \ +include_HEADERS = H5public.h H5version.h H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ @@ -1062,13 +1062,18 @@ help: # 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. +# API version macro generation +# +$(top_srcdir)/src/H5version.h: $(top_srcdir)/src/H5vers.txt + perl $(top_srcdir)/bin/make_vers $? + # Error header generation # # Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all # depend on H5err.txt, but the perl script generates them all, so just # list one here. $(top_srcdir)/src/H5Edefin.h: $(top_srcdir)/src/H5err.txt - perl $(top_srcdir)/bin/make_err $> + perl $(top_srcdir)/bin/make_err $? # Number format detection # The LD_LIBRARY_PATH setting is a klutch. |