summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2009-09-21 05:28:44 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2009-09-21 05:28:44 (GMT)
commit1d2bf10ae704d08b03ce9f86234e81368549ba3e (patch)
treee3acb5907b24c0b624334b15a961eb9e1a69dbe4 /src/H5detect.c
parent22d4097ff71fcdb7fbc505d3296f63943251ffd3 (diff)
downloadhdf5-1d2bf10ae704d08b03ce9f86234e81368549ba3e.zip
hdf5-1d2bf10ae704d08b03ce9f86234e81368549ba3e.tar.gz
hdf5-1d2bf10ae704d08b03ce9f86234e81368549ba3e.tar.bz2
[svn-r17502] 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. Additional tests: jam serial; jam --disable-embedded-libinfo; jam --disable-shared. All passed.
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c76
1 files changed, 56 insertions, 20 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index 8d7b93b..d5801ef 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,10 @@ 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.
+ * Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not
+ * defined, i.e., not enabled.
*
* Return: void
*
@@ -519,9 +522,10 @@ sigbus_handler(int UNUSED signo)
*/
#define LIBSETTINGSFNAME "libhdf5.settings"
static void
-insert_libhdf5_settings(void)
+insert_libhdf5_settings(FILE *flibinfo)
{
- FILE *fsettings;
+#ifdef H5_HAVE_EMBEDDED_LIBINFO
+ FILE *fsettings; /* for files libhdf5.settings */
int inchar;
int bol=0; /* indicates the beginning of a new line */
@@ -529,34 +533,66 @@ 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);
+ }
+#else
+ /* print variable definition and an empty string */
+ fprintf(flibinfo, "char H5libhdf5_settings[]=\"\";\n");
+#endif
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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 +659,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\
@@ -639,10 +677,8 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/*******************/\n\
\n");
-#ifdef H5_HAVE_EMBEDDED_LIBINFO
- /* Insert content of libhdf5.settings */
- insert_libhdf5_settings();
-#endif
+ /* Generate embedded library information variable definition */
+ make_libinfo();
/* The interface initialization function */
printf("\n\
@@ -1119,8 +1155,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
*