summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2009-09-18 18:34:37 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2009-09-18 18:34:37 (GMT)
commit3a83be48fb88572d675507a5d5cfbacb302f1ad7 (patch)
tree62a02358948629bd268d90e0e1ac79496276cf07 /src
parent8664cb26c3da2749e4c82d99454701352cc15b0e (diff)
downloadhdf5-3a83be48fb88572d675507a5d5cfbacb302f1ad7.zip
hdf5-3a83be48fb88572d675507a5d5cfbacb302f1ad7.tar.gz
hdf5-3a83be48fb88572d675507a5d5cfbacb302f1ad7.tar.bz2
[svn-r17499] Purpose:
Stage 2 implementation of embedded library information feature. H5.c: added code to print the embedded library information when there is a library versions mis-match occurs. This ensures the library information string is included in the executable. Also modifies the code so that the Library mismatch warning string is included only once in the executable. H5private.h: Added a global reference to the libinfo string variable to prepare for possible stage 3 implementation of a public API. test/testlibinfo.sh.in: A new test added to verify the library information is indeed included in the executables. configure.in: configure: Added entry to auto-generate test/testlibinfo.sh. H5detect.c: Modified the libhdf5settings generating code to allow it to insert the strings to a file other than stdout. This maybe needed in stage 3 implementation. MANIFEST: updated with the newly added file of testlibinfo.sh.in. Tested: h5committest passed. Also passed jam in serial mode.
Diffstat (limited to 'src')
-rw-r--r--src/H5.c20
-rw-r--r--src/H5detect.c67
-rw-r--r--src/H5private.h1
3 files changed, 63 insertions, 25 deletions
diff --git a/src/H5.c b/src/H5.c
index b49db8d..f11e8b7 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -28,7 +28,7 @@
#include "H5Lprivate.h" /* Links */
#include "H5Pprivate.h" /* Property lists */
#include "H5Tprivate.h" /* Datatypes */
-#include "H5SLprivate.h" /* Skip lists */
+#include "H5SLprivate.h" /* Skip lists */
/****************/
@@ -623,6 +623,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
static int checked = 0; /* If we've already checked the version info */
static int disable_version_check = 0; /* Set if the version check should be disabled */
herr_t ret_value=SUCCEED; /* Return value */
+ static char *version_mismatch_warning=VERSION_MISMATCH_WARNING;
FUNC_ENTER_API_NOINIT_NOFS(H5check_version)
H5TRACE3("e", "IuIuIu", majnum, minnum, relnum);
@@ -644,15 +645,16 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
H5_VERS_RELEASE!=relnum) {
switch (disable_version_check) {
case 0:
- HDfputs (VERSION_MISMATCH_WARNING
+ HDfprintf(stderr, "%s%s", version_mismatch_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 will suppress the warning messages totally.\n",
- stderr);
+ "Setting it to 2 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);
+ /* Show library settings if available */
+ HDfprintf (stderr, "%s", H5libhdf5_settings);
/* Bail out now. */
HDfputs ("Bye...\n", stderr);
@@ -662,14 +664,18 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
break;
default:
/* continue with a warning */
- HDfprintf (stderr, VERSION_MISMATCH_WARNING
- "'HDF5_DISABLE_VERSION_CHECK' "
+ /* 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", disable_version_check);
+ "continue at your own risk.\n",
+ 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);
+ /* Show library settings if available */
+ HDfprintf (stderr, "%s", H5libhdf5_settings);
break;
} /* end switch */
diff --git a/src/H5detect.c b/src/H5detect.c
index 8d7b93b..4dae076 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -108,7 +108,8 @@ static void detect_C99_integers16(void);
static void detect_C99_integers32(void);
static void detect_C99_integers64(void);
static void detect_alignments(void);
-static void insert_libhdf5_settings(void);
+static void insert_libhdf5_settings(FILE *flibinfo);
+static void make_libinfo(void);
static size_t align_g[] = {1, 2, 4, 8, 16};
static jmp_buf jbuf_g;
@@ -505,8 +506,8 @@ sigbus_handler(int UNUSED signo)
/*-------------------------------------------------------------------------
* Function: insert_libhdf5_settings
*
- * Purpose: Insert contents of libhdf5.settings so that it is included
- * in all hdf5 executables.
+ * Purpose: insert the contents of libhdf5.settings into a file
+ * represented by flibinfo.
*
* Return: void
*
@@ -519,9 +520,9 @@ sigbus_handler(int UNUSED signo)
*/
#define LIBSETTINGSFNAME "libhdf5.settings"
static void
-insert_libhdf5_settings(void)
+insert_libhdf5_settings(FILE *flibinfo)
{
- FILE *fsettings;
+ FILE *fsettings; /* for files libhdf5.settings */
int inchar;
int bol=0; /* indicates the beginning of a new line */
@@ -529,34 +530,62 @@ insert_libhdf5_settings(void)
perror(LIBSETTINGSFNAME);
exit(1);
}
- /* print variable definition */
- printf("extern char H5libhdf5_settings[]=\n");
+ /* print variable definition and the string */
+ fprintf(flibinfo, "char H5libhdf5_settings[]=\n");
bol++;
while (EOF != (inchar = getc(fsettings))){
if (bol){
/* Start a new line */
- printf("\t\"");
+ fprintf(flibinfo, "\t\"");
bol = 0;
}
if (inchar == '\n'){
/* end of a line */
- printf("\\n\"\n");
+ fprintf(flibinfo, "\\n\"\n");
bol++;
}else{
- putchar(inchar);
+ putc(inchar, flibinfo);
}
}
if (feof(fsettings)){
/* wrap up */
if (!bol){
/* EOF found without a new line */
- printf("\\n\"\n");
+ fprintf(flibinfo, "\\n\"\n");
};
- printf(";\n\n");
+ fprintf(flibinfo, ";\n\n");
}else{
fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
exit(1);
}
+ if (0 != fclose(fsettings)){
+ perror(LIBSETTINGSFNAME);
+ exit(1);
+ }
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: make_libinfo
+ *
+ * Purpose: Create the embedded library information definition.
+ * This sets up for a potential extension that the declaration
+ * is printed to a file different from stdout.
+ *
+ * Return: void
+ *
+ * Programmer: Albert Cheng
+ * Sep 15, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+make_libinfo(void)
+{
+ /* print variable definition and then the string as a macro. */
+ insert_libhdf5_settings(stdout);
}
@@ -623,11 +652,13 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/********************/\n\
/* Public Variables */\n\
/********************/\n\
-\n\n\
+\n\
+\n\
/*****************************/\n\
/* Library Private Variables */\n\
/*****************************/\n\
-\n\n\
+\n\
+\n\
/*********************/\n\
/* Package Variables */\n\
/*********************/\n\
@@ -640,8 +671,8 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
\n");
#ifdef H5_HAVE_EMBEDDED_LIBINFO
- /* Insert content of libhdf5.settings */
- insert_libhdf5_settings();
+ /* Generate embedded library information files */
+ make_libinfo();
#endif
/* The interface initialization function */
@@ -1119,8 +1150,8 @@ find_bias(int epos, int esize, int *perm, void *_a)
/*-------------------------------------------------------------------------
* Function: print_header
- *
- * Purpose: Prints the C file header for the generated file.
+ *
+ * Purpose: Prints the C file header for the generated file.
*
* Return: void
*
diff --git a/src/H5private.h b/src/H5private.h
index ccfbd5d..12af8e7 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -1514,6 +1514,7 @@ typedef struct H5_debug_t {
extern H5_debug_t H5_debug_g;
#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream)
+extern char H5libhdf5_settings[]; /* embedded library information */
/*-------------------------------------------------------------------------
* Purpose: These macros are inserted automatically just after the