summaryrefslogtreecommitdiffstats
path: root/src/H5.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2016-03-07 22:03:57 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2016-03-07 22:03:57 (GMT)
commit2c36685010638e6bfcdd4ec74194cd200081668b (patch)
tree2f8a2d904c2bdcfeccf97f17f9ea2cec5f9ada52 /src/H5.c
parentb99b5d494e4aa86901d7a68d4a31de96d11c83c7 (diff)
downloadhdf5-2c36685010638e6bfcdd4ec74194cd200081668b.zip
hdf5-2c36685010638e6bfcdd4ec74194cd200081668b.tar.gz
hdf5-2c36685010638e6bfcdd4ec74194cd200081668b.tar.bz2
[svn-r29326] 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.) config/lt_vers.am: cosmetic change, nothing material. 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 (C only), platypus and osx1010dev (enable fortran and C++).
Diffstat (limited to 'src/H5.c')
-rw-r--r--src/H5.c130
1 files changed, 130 insertions, 0 deletions
diff --git a/src/H5.c b/src/H5.c
index 41fb3ba..acbdecb 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -720,6 +720,9 @@ done:
} /* end H5get_libversion() */
+/* Depreciated by H5check_interface_compatibility. Need to keep it around
+ * because Fortran API calls it. Will be retired later.
+ */
/*-------------------------------------------------------------------------
* Function: H5check_version
*
@@ -855,6 +858,133 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5check_interface_compatibility
+ *
+ * Purpose: Verifies that the arguments are compatible with the link library.
+ * This function is intended to be called from user to verify that
+ * the versions of header files compiled into the application
+ * is compatible with the version of the link hdf5 library.
+ *
+ * Return: Success: SUCCEED
+ *
+ * Failure: abort()
+ * The value of the environment variable,
+ * HDF5_DISABLE_VERSION_CHECK, could affect
+ * how failure is handles. See Code below.
+ *
+ * Algorithm: {provided by Mike McGreevy}
+ * How to determine if two libraries, given their interface, revision,
+ * and age, are compatible? Let's say you have:
+ *
+ * interface, revision, age --> compiled HDF5
+ * INTERFACE, REVISION, AGE --> linked HDF5 library
+ * Then:
+ * if ((INTERFACE-AGE) != (interface-age))
+ * not compatible
+ * else
+ * if (age <= AGE)
+ * compatible
+ * else
+ * not compatible
+ * endif
+ * endif
+ * [Note: revision/REVISION do not affect compatibility]
+ *
+ * Programmer: Albert Cheng
+ * Feb 21, 2016
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#define INTERFACE_INCOMPATIBLE_WARNING \
+"Warning! ***HDF5 interface incompatibility detected***\n" \
+"The HDF5 header files used to compile this application are not compatible \n" \
+"with the HDF5 library to which this application is linked.\n" \
+"Data corruption or segmentation faults may occur if the application continues.\n" \
+"This can happen when an application was compiled by one version of HDF5 but\n" \
+"linked with a different version of static or shared HDF5 library.\n" \
+"You should recompile the application or check your shared library related\n" \
+"settings such as 'LD_LIBRARY_PATH'.\n"
+
+herr_t
+H5check_interface_compatibility(unsigned interface, unsigned age, unsigned revision)
+{
+ char lib_str[256];
+ 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 *interface_incompatible_warning = INTERFACE_INCOMPATIBLE_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", interface, age, revision);
+
+ assert(interface >= age);
+ assert(LT_VERS_INTERFACE >= LT_VERS_AGE);
+
+ /* Optimization: Don't check again, if we already have */
+ if (checked)
+ HGOTO_DONE(SUCCEED)
+ else
+ /* Indicate that the version check has been performed */
+ checked++;
+
+ /* check version compatibility */
+ if (((LT_VERS_INTERFACE - LT_VERS_AGE) == (interface - age)) &&\
+ (LT_VERS_AGE >= age))
+ HGOTO_DONE(SUCCEED)
+ /* else NOT COMPATIBLE */
+
+ /* Allow different handling of not compatible */
+ s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK");
+ if (s && HDisdigit(*s))
+ disable_version_check = (unsigned int)HDstrtol (s, NULL, 0);
+
+ /* check the version of the link library */
+ switch (disable_version_check) {
+ case 0:
+ /* print a message and abort */
+ HDfprintf(stderr, "%s%s", interface_incompatible_warning,
+ "You can, at your own risk, disable this warning by setting the environment\n"
+ "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n"
+ "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",
+ (interface-age), age, revision,
+ ((unsigned)LT_VERS_INTERFACE-(unsigned)LT_VERS_AGE), (unsigned)LT_VERS_AGE, (unsigned)LT_VERS_REVISION);
+ /* Show library settings if available */
+ HDfprintf (stderr, "%s", H5libhdf5_settings);
+
+ /* Bail out now. */
+ HDfputs ("Bye...\n", stderr);
+ HDabort ();
+ case 1:
+ /* continue with a warning */
+ /* Note that the warning message is embedded in the format string.*/
+ HDfprintf (stderr,
+ "%s'HDF5_DISABLE_VERSION_CHECK' "
+ "environment variable is set to %d, application will\n"
+ "continue at your own risk.\n",
+ interface_incompatible_warning, disable_version_check);
+ /* Mention the versions we are referring to */
+ HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n",
+ (interface-age), age, revision,
+ ((unsigned)LT_VERS_INTERFACE-(unsigned)LT_VERS_AGE), (unsigned)LT_VERS_AGE, (unsigned)LT_VERS_REVISION);
+ /* Show library settings if available */
+ HDfprintf (stderr, "%s", H5libhdf5_settings);
+ break;
+ default:
+ /* 2 or higher: continue silently */
+ break;
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_API_NOFS(ret_value)
+} /* end H5check_version() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5open
*
* Purpose: Initialize the library. This is normally called