diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2015-10-08 20:50:15 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2015-10-08 20:50:15 (GMT) |
commit | 1f1081e039bea766161cb7055589b74267764c9b (patch) | |
tree | 4322b8502e18562d6c88535ee83c8f0e1720138e | |
parent | 74ab402e3eb08b53dbf2ad7d3a27b51cfae87f5b (diff) | |
download | hdf5-1f1081e039bea766161cb7055589b74267764c9b.zip hdf5-1f1081e039bea766161cb7055589b74267764c9b.tar.gz hdf5-1f1081e039bea766161cb7055589b74267764c9b.tar.bz2 |
[svn-r28009] HDFFV-9536: Changed H5check_version() to use libtool shared library version numbers instead of the library version numbers.
bin/h5vers:
Changed to copy the shared lib version from lt_vers.am to H5public.h
(Thanks to Larry who made the changes.)
src/H5public.h:
Changed by bin/h5vers.
src/H5.c:
Changed H5check_version() to use shared library version for compatibility
checking.
test/tcheck_version.c:
test/testcheck_version.sh.in:
Changed to use shared library version numbers instead of the HDF5 library
version numbers for testing.
Tested: tested in Jam and Kituo.
-rwxr-xr-x | bin/h5vers | 60 | ||||
-rw-r--r-- | src/H5.c | 63 | ||||
-rw-r--r-- | src/H5public.h | 12 | ||||
-rw-r--r-- | test/tcheck_version.c | 12 | ||||
-rw-r--r-- | test/testcheck_version.sh.in | 11 |
5 files changed, 110 insertions, 48 deletions
@@ -105,6 +105,13 @@ sub setvers { $vers[3]?"-":"", $vers[3])/me; } +sub setltvers { + my ($contents, @vers) = @_; + $_[0] =~ s/^(\#\s*define\s+LT_VERS_INTERFACE\s+)\d+/$1$vers[0]/m; + $_[0] =~ s/^(\#\s*define\s+LT_VERS_REVISION\s+)\d+/$1$vers[1]/m; + $_[0] =~ s/^(\#\s*define\s+LT_VERS_AGE\s+)\d+/$1$vers[2]/m; +} + sub usage { my ($prog) = $0 =~ /([^\/]+)$/; print STDERR <<EOF; @@ -239,7 +246,7 @@ if ($set) { $RELEASE = ""; $CONFIGURE = ""; $CPP_DOC_CONFIG = ""; - $LT_VERS = ""; +# $LT_VERS = ""; @newver = @curver; } @@ -256,35 +263,45 @@ if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] > $version_increased="true"; } +my @newltver; +# Update the libtool shared library version in src/H5public.h +if ($LT_VERS) { + open FILE, $LT_VERS or die "$LT_VERS: $!\n"; + my ($contentsy) = join "", <FILE>; + close FILE; + + local($_) = $contentsy; + + # Don't increment LT_VERS_REVISION, but instead copy LT_VERS_* values + # to H5public.h. + # 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; + + my ($lt_interface) = /^LT_VERS_INTERFACE\s*=\s*(\d+)/m; + my ($lt_revision) = /^LT_VERS_REVISION\s*=\s*(\d+)/m; + my ($lt_age) = /^LT_VERS_AGE\s*=\s*(\d+)/m; + + @newltver = ($lt_interface, $lt_revision, $lt_age); + +} + # 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"; +} + setltvers $contents, @newltver or die "unable to set lt 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 "", <FILE>; - 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) { @@ -436,6 +453,9 @@ if ($verbose) { $newver[3] eq "" ? "" : "-".$newver[3]); } +# print shared lib version in the format of interface.revision.age +printf("Shared lib version %d.%d.%d\n", @newltver[0,1,2]); + exit 0; # Because the first line of this file looks like a Bourne shell script, we @@ -675,6 +675,31 @@ done: * called from user to verify that the versions of header files * compiled into the application match the version of the hdf5 * library. + * Algorithm: + * + * Definitions: + * Compile-time (aka headers, defined in src/H5public.h): + * the three arguments supplied + * interface: compile time interface + * revision: compile time revision + * age: compiler time age + * + * Link-time (aka values library has from its version of src/H5public.h): + * LT_VERS_INTERFACE + * LT_VERS_REVISION + * LT_VERS_AGE + * + * Verification criteria: + * Assert interface >= age and LT_VERS_INTERFACE >= LT_VERS_AGE + * + * if ((LT_VERS_INTERFACE - LT_VERS_AGE) .ne. (interface - age)) then + * mesg “incompatible” + * else + * if (age > LT_VERS_AGE) then + * mesg “incompatible” + * endif + * endif + * * * Return: Success: SUCCEED * @@ -686,6 +711,8 @@ done: * Modifications: * Albert Cheng, May 12, 2001 * Added verification of H5_VERS_INFO. + * Albert Cheng, Oct 8, 2015 + * Changed to use shared library version for verification criteria. * *------------------------------------------------------------------------- */ @@ -700,33 +727,43 @@ done: "settings such as 'LD_LIBRARY_PATH'.\n" herr_t -H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) +H5check_version(unsigned interface, unsigned revision, unsigned age) { char lib_str[256]; char substr[] = H5_VERS_SUBRELEASE; static int checked = 0; /* If we've already checked the version info */ static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ static const char *version_mismatch_warning = VERSION_MISMATCH_WARNING; + const char *s; /* Environment string for disabling version check */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT_NOERR_NOFS - H5TRACE3("e", "IuIuIu", majnum, minnum, relnum); + H5TRACE3("e", "IuIuIu", interface, revision, age); /* Don't check again, if we already have */ if (checked) HGOTO_DONE(SUCCEED) - { const char *s; /* Environment string for disabling version check */ + /* Check if the user wishes to allow different versions of the header */ + /* files and the library. */ + s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK"); - /* Allow different versions of the header files and library? */ - s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK"); + if (s && HDisdigit(*s)) + disable_version_check = (unsigned int)HDstrtol (s, NULL, 0); - if (s && HDisdigit(*s)) - disable_version_check = (unsigned int)HDstrtol (s, NULL, 0); + /* assert version sanity */ + if ((LT_VERS_INTERFACE < LT_VERS_AGE) || (interface < age)){ + HDfprintf(stderr, "It is illegal for interface is less than age\n" + "LT_VERS_INTERFACE=%u, LT_VERS_AGE=%u, interface=%u, age=%u\n", + LT_VERS_INTERFACE, LT_VERS_AGE, interface, age); + /* Bail out now. */ + + HDfputs ("Bye...\n", stderr); + HDabort (); } - if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum || - H5_VERS_RELEASE!=relnum) { + if (((LT_VERS_INTERFACE - LT_VERS_AGE) != (interface - age)) || \ + (age > LT_VERS_AGE)) { switch (disable_version_check) { case 0: HDfprintf(stderr, "%s%s", version_mismatch_warning, @@ -735,8 +772,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) "Setting it to 2 or higher will suppress the warning messages totally.\n"); /* Mention the versions we are referring to */ HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", - majnum, minnum, relnum, - (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); + interface, revision, age, + (unsigned)LT_VERS_INTERFACE, (unsigned)LT_VERS_REVISION, (unsigned)LT_VERS_AGE); /* Show library settings if available */ HDfprintf (stderr, "%s", H5libhdf5_settings); @@ -753,8 +790,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) version_mismatch_warning, disable_version_check); /* Mention the versions we are referring to */ HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", - majnum, minnum, relnum, - (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE); + interface, revision, age, + (unsigned)LT_VERS_INTERFACE, (unsigned)LT_VERS_REVISION, (unsigned)LT_VERS_AGE); /* Show library settings if available */ HDfprintf (stderr, "%s", H5libhdf5_settings); break; diff --git a/src/H5public.h b/src/H5public.h index 5c43298..d1ac819 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -99,8 +99,8 @@ extern "C" { /* Empty string for real releases. */ #define H5_VERS_INFO "HDF5 library version: 1.8.16-snap18" /* Full version string */ -#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ - H5_VERS_RELEASE) +#define H5check() H5check_version(LT_VERS_INTERFACE, LT_VERS_REVISION, \ + LT_VERS_AGE) /* macros for comparing the version */ #define H5_VERSION_GE(Maj,Min,Rel) \ @@ -113,6 +113,11 @@ extern "C" { ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR<Min)) || \ (H5_VERS_MAJOR<Maj)) +/* LT Version numbers */ +#define LT_VERS_INTERFACE 10 +#define LT_VERS_REVISION 1 +#define LT_VERS_AGE 0 + /* * Status return values. Failed integer functions in HDF5 result almost * always in a negative value (unsigned failing functions sometimes return @@ -329,8 +334,7 @@ H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim, int blk_list_lim); H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); -H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, - unsigned relnum); +H5_DLL herr_t H5check_version(unsigned interface, unsigned revision, unsigned age); H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts); H5_DLL herr_t H5free_memory(void *mem); H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); diff --git a/test/tcheck_version.c b/test/tcheck_version.c index a75d642..67c45fd 100644 --- a/test/tcheck_version.c +++ b/test/tcheck_version.c @@ -39,9 +39,9 @@ void parse(int ac, char **av); void abort_intercept (int H5_ATTR_UNUSED sig); /* global variables */ -unsigned major = H5_VERS_MAJOR; -unsigned minor = H5_VERS_MINOR; -unsigned release = H5_VERS_RELEASE; +unsigned major = LT_VERS_INTERFACE; +unsigned minor = LT_VERS_REVISION; +unsigned release = LT_VERS_AGE; void showhelp(void) @@ -50,9 +50,9 @@ showhelp(void) printf("\t-h\tShow this page and version information\n"); printf("\t-t<vers>: Test by changing (adding 1 to) the <vers> to trigger\n"); printf("\t\t the warning. <vers> can be:\n"); - printf("\t\t\tM for Major version number (%d)\n", H5_VERS_MAJOR); - printf("\t\t\tm for Minor version number (%d)\n", H5_VERS_MINOR); - printf("\t\t\tr for Release number (%d)\n", H5_VERS_RELEASE); + printf("\t\t\tM for Major version number (%d)\n", LT_VERS_INTERFACE); + printf("\t\t\tm for Minor version number (%d)\n", LT_VERS_REVISION); + printf("\t\t\tr for Release number (%d)\n", LT_VERS_AGE); } diff --git a/test/testcheck_version.sh.in b/test/testcheck_version.sh.in index ed9845e..f89480e 100644 --- a/test/testcheck_version.sh.in +++ b/test/testcheck_version.sh.in @@ -217,10 +217,11 @@ h5libsettings=../src/libhdf5.settings PURPOSE -# Figure out library version numbers from the header file. -h5versmajor=`grep '#define H5_VERS_MAJOR' $srcdir/../src/H5public.h | cut -f2` -h5versminor=`grep '#define H5_VERS_MINOR' $srcdir/../src/H5public.h | cut -f2` -h5versrelease=`grep '#define H5_VERS_RELEASE' $srcdir/../src/H5public.h | cut -f2` +# Figure out lt version numbers from the header file. +# sed uses spaces and tabs as white spaces. +h5versmajor=`sed -e 's/#define[ ]*LT_VERS_INTERFACE[ ]*//p;d' $srcdir/../src/H5public.h` +h5versminor=`sed -e 's/#define[ ]*LT_VERS_REVISION[ ]*//p;d' $srcdir/../src/H5public.h` +h5versrelease=`sed -e 's/#define[ ]*LT_VERS_AGE[ ]*//p;d' $srcdir/../src/H5public.h` DEBUGPRINT $h5versmajor.$h5versminor.$h5versrelease case "$h5versmajor$h5versminor$h5versrelease" in [0-9]*) # good. noop. @@ -247,7 +248,7 @@ fi # HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3 for val_disable_version_check in unset "" -1 0 1 2 3; do - for wrong_version in none M m r; do + for wrong_version in none M r ; do TESTING "$val_disable_version_check" "$wrong_version" done done |