summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-09-18 21:39:28 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-09-18 21:39:28 (GMT)
commit44de4ee2e54b84484b099c51c51440b61c4ee465 (patch)
tree18a5236b47c75e461bb4e8790d0639e507690411
parentcb5b36e4dcd88633b8044c250142b0a2a85a8f4f (diff)
parent6c78869c19a88edfd7b6a2a99a8fb8f5febf0b7a (diff)
downloadhdf5-44de4ee2e54b84484b099c51c51440b61c4ee465.zip
hdf5-44de4ee2e54b84484b099c51c51440b61c4ee465.tar.gz
hdf5-44de4ee2e54b84484b099c51c51440b61c4ee465.tar.bz2
Merge pull request #1243 in HDFFV/hdf5 from ~BYRN/hdf5_merge_adb:develop to develop
* commit '6c78869c19a88edfd7b6a2a99a8fb8f5febf0b7a': Fix whitespace and exit status HDFFV-9059 take file as argument HDFFV-9059 Allow detect to take a file as an argument
-rw-r--r--release_docs/RELEASE.txt11
-rw-r--r--src/CMakeLists.txt12
-rw-r--r--src/H5detect.c860
-rw-r--r--src/H5make_libsettings.c260
-rw-r--r--src/Makefile.am4
5 files changed, 525 insertions, 622 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 5150349..c8c7d5c 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -148,7 +148,7 @@ New Features
Java Library:
----------------
- JNI native library dependencies
-
+
The build for the hdf5_java native library used the wrong
hdf5 target library for CMake builds. Correcting the hdf5_java
library to build with the shared hdf5 library required testing
@@ -209,6 +209,15 @@ Bug Fixes since HDF5-1.10.3 release
Library
-------
+ - Allow H5detect and H5make_libsettings to take a file as an argument.
+
+ Rather than only writing to stdout, add a command argument to name
+ the file that H5detect and H5make_libsettings will use for output.
+ Without an argument, stdout is still used, so backwards compatibility
+ is maintained.
+
+ (ADB - 2018/09/05, HDFFV-9059)
+
- A bug was discovered in the parallel library where an application
would hang if a collective read/write of a chunked dataset occurred
when collective metadata reads were enabled and some of the ranks
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3c5526f..ee06f06 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -854,7 +854,7 @@ endif ()
# specific type checks inside
#-----------------------------------------------------------------------------
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
-target_include_directories(H5detect PRIVATE "${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+target_include_directories(H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
TARGET_C_PROPERTIES (H5detect STATIC)
target_link_libraries (H5detect
@@ -865,12 +865,12 @@ target_link_libraries (H5detect
add_custom_command (
OUTPUT ${HDF5_BINARY_DIR}/H5Tinit.c
COMMAND $<TARGET_FILE:H5detect>
- ARGS > ${HDF5_BINARY_DIR}/H5Tinit.c
+ ARGS ${HDF5_BINARY_DIR}/H5Tinit.c
DEPENDS H5detect
)
add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
-target_include_directories(H5make_libsettings PRIVATE "${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+target_include_directories(H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
TARGET_C_PROPERTIES (H5make_libsettings STATIC)
target_link_libraries (H5make_libsettings
@@ -881,7 +881,7 @@ target_link_libraries (H5make_libsettings
add_custom_command (
OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c
COMMAND $<TARGET_FILE:H5make_libsettings>
- ARGS > ${HDF5_BINARY_DIR}/H5lib_settings.c
+ ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c
DEPENDS H5make_libsettings
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
)
@@ -925,14 +925,14 @@ if (BUILD_SHARED_LIBS)
add_custom_command (
OUTPUT ${HDF5_BINARY_DIR}/shared/H5Tinit.c
COMMAND $<TARGET_FILE:H5detect>
- ARGS > ${HDF5_BINARY_DIR}/shared/H5Tinit.c
+ ARGS ${HDF5_BINARY_DIR}/shared/H5Tinit.c
DEPENDS H5detect
WORKING_DIRECTORY ${HDF5_BINARY_DIR}/shared
)
add_custom_command (
OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
COMMAND $<TARGET_FILE:H5make_libsettings>
- ARGS > ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
+ ARGS ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
DEPENDS H5make_libsettings
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
)
diff --git a/src/H5detect.c b/src/H5detect.c
index 2d33a3d..aac58de 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -26,11 +26,6 @@ static const char *FileHeader = "\n\
* help@hdfgroup.org. *\n\
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
/*
- *
- * Created: H5detect.c
- * 10 Aug 1997
- * Robb Matzke
- *
* Purpose: This code was borrowed heavily from the `detect.c'
* program in the AIO distribution from Lawrence
* Livermore National Laboratory.
@@ -44,9 +39,6 @@ static const char *FileHeader = "\n\
* features which aren't available. We're not
* running on a Vax or other machine with mixed
* endianness.
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
#undef NDEBUG
@@ -117,6 +109,8 @@ typedef struct malign_t {
unsigned int comp_align; /* alignment for structure */
} malign_t;
+FILE *rawoutstream = NULL;
+
/* global variables types detection code */
H5_GCC_DIAG_OFF(larger-than=)
static detected_t d_g[MAXDETECT];
@@ -143,9 +137,9 @@ static void detect_C99_integers32(void);
static void detect_C99_integers64(void);
static void detect_alignments(void);
static unsigned int align_g[] = {1, 2, 4, 8, 16};
-static int align_status_g = 0; /* ALIGNMENT Signal Status */
+static int align_status_g = 0; /* ALIGNMENT Signal Status */
static int sigbus_handler_called_g = 0; /* how many times called */
-static int sigsegv_handler_called_g = 0;/* how many times called */
+static int sigsegv_handler_called_g = 0; /* how many times called */
static int sigill_handler_called_g = 0; /* how many times called */
static int signal_handler_tested_g = 0; /* how many times tested */
#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
@@ -157,17 +151,11 @@ static H5JMP_BUF jbuf_g;
/*-------------------------------------------------------------------------
- * Function: precision
+ * Function: precision
*
- * Purpose: Determine the precision and offset.
+ * Purpose: Determine the precision and offset.
*
* Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 18, 1998
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -189,7 +177,8 @@ precision (detected_t *d)
/*void*/;
d->precision = 8 * (d->size - n);
d->offset = 0;
- } else if (d->perm[d->size - 1] < 0) {
+ }
+ else if (d->perm[d->size - 1] < 0) {
/*
* Higher addresses are padded.
*/
@@ -197,14 +186,16 @@ precision (detected_t *d)
/*void*/;
d->precision = 8 * (d->size - n);
d->offset = 8 * n;
- } else {
+ }
+ else {
/*
* No padding.
*/
d->precision = 8 * d->size;
d->offset = 0;
}
- } else {
+ }
+ else {
/* A floating point */
d->offset = MIN3(d->mpos, d->epos, d->sign);
d->precision = d->msize + d->esize + 1;
@@ -213,21 +204,17 @@ precision (detected_t *d)
/*-------------------------------------------------------------------------
- * Function: DETECT_I/DETECT_BYTE
+ * Function: DETECT_I/DETECT_BYTE
*
- * Purpose: These macro takes a type like `int' and a base name like
- * `nati' and detects the byte order. The VAR is used to
- * construct the names of the C variables defined.
+ * Purpose: These macro takes a type like `int' and a base name like
+ * `nati' and detects the byte order. The VAR is used to
+ * construct the names of the C variables defined.
*
- * DETECT_I is used for types that are larger than one byte,
- * DETECT_BYTE is used for types that are exactly one byte.
+ * DETECT_I is used for types that are larger than one byte,
+ * DETECT_BYTE is used for types that are exactly one byte.
*
* Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12 1996
- *
* Modifications:
*
* Robb Matzke, 4 Nov 1996
@@ -244,7 +231,7 @@ precision (detected_t *d)
*
* Neil Fortner, 6 Sep 2013
* Split macro into DETECT_I and DETECT_BYTE macros, extracted
- * common cod einto DETECT_I_BYTE_CORE. This was done to remove
+ * common code into DETECT_I_BYTE_CORE. This was done to remove
* "will never be executed" warnings.
*
*-------------------------------------------------------------------------
@@ -291,20 +278,13 @@ precision (detected_t *d)
/*-------------------------------------------------------------------------
- * Function: DETECT_F
- *
- * Purpose: This macro takes a floating point type like `double' and
- * a base name like `natd' and detects byte order, mantissa
- * location, exponent location, sign bit location, presence or
- * absence of implicit mantissa bit, and exponent bias and
- * initializes a detected_t structure with those properties.
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12 1996
+ * Function: DETECT_F
*
+ * Purpose: This macro takes a floating point type like `double' and
+ * a base name like `natd' and detects byte order, mantissa
+ * location, exponent location, sign bit location, presence or
+ * absence of implicit mantissa bit, and exponent bias and
+ * initializes a detected_t structure with those properties.
*-------------------------------------------------------------------------
*/
#define DETECT_F(TYPE,VAR,INFO) { \
@@ -395,20 +375,13 @@ precision (detected_t *d)
/*-------------------------------------------------------------------------
- * Function: DETECT_M
+ * Function: DETECT_M
*
- * Purpose: This macro takes only miscellaneous structures or pointer
- * (pointer, hvl_t, hobj_ref_t, hdset_reg_ref_t). It
- * constructs the names and decides the alignment in structure.
+ * Purpose: This macro takes only miscellaneous structures or pointer
+ * (pointer, hvl_t, hobj_ref_t, hdset_reg_ref_t). It
+ * constructs the names and decides the alignment in structure.
*
* Return: void
- *
- * Programmer: Raymond Lu
- * slu@ncsa.uiuc.edu
- * Dec 9, 2002
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
#define DETECT_M(TYPE,VAR,INFO) { \
@@ -438,29 +411,29 @@ precision (detected_t *d)
_buf = (char*)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \
if(H5SETJMP(jbuf_g)) _ano++; \
if(_ano < NELMTS(align_g)) { \
- *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \
- _val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/\
- /* Cray Check: This section helps detect alignment on Cray's */ \
+ *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \
+ _val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/\
+ /* Cray Check: This section helps detect alignment on Cray's */ \
/* vector machines (like the SV1) which mask off */ \
- /* pointer values when pointing to non-word aligned */ \
- /* locations with pointers that are supposed to be */ \
- /* word aligned. -QAK */ \
- HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \
- /*How to handle VAX types?*/ \
- if(INFO.perm[0]) /* Big-Endian */ \
- HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \
- else /* Little-Endian */ \
- HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \
- _val2 = *((TYPE*)(_buf+align_g[_ano])); \
- H5_GCC_DIAG_OFF(float-equal) \
- if(_val!=_val2) \
- H5LONGJMP(jbuf_g, 1); \
- H5_GCC_DIAG_ON(float-equal) \
- /* End Cray Check */ \
- (INFO.align)=align_g[_ano]; \
+ /* pointer values when pointing to non-word aligned */ \
+ /* locations with pointers that are supposed to be */ \
+ /* word aligned. -QAK */ \
+ HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \
+ /*How to handle VAX types?*/ \
+ if(INFO.perm[0]) /* Big-Endian */ \
+ HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \
+ else /* Little-Endian */ \
+ HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \
+ _val2 = *((TYPE*)(_buf+align_g[_ano])); \
+ H5_GCC_DIAG_OFF(float-equal) \
+ if(_val!=_val2) \
+ H5LONGJMP(jbuf_g, 1); \
+ H5_GCC_DIAG_ON(float-equal) \
+ /* End Cray Check */ \
+ (INFO.align)=align_g[_ano]; \
} else { \
(INFO.align)=0; \
- fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \
+ fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \
} \
HDfree(_buf); \
HDsignal(SIGBUS, _handler); /*restore original handler*/ \
@@ -477,20 +450,14 @@ precision (detected_t *d)
#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL)
/*-------------------------------------------------------------------------
- * Function: sigsegv_handler
+ * Function: sigsegv_handler
*
- * Purpose: Handler for SIGSEGV. We use signal() instead of sigaction()
- * because it's more portable to non-Posix systems. Although
- * it's not nearly as nice to work with, it does the job for
- * this simple stuff.
+ * Purpose: Handler for SIGSEGV. We use signal() instead of sigaction()
+ * because it's more portable to non-Posix systems. Although
+ * it's not nearly as nice to work with, it does the job for
+ * this simple stuff.
*
* Return: Returns via H5LONGJMP to jbuf_g.
- *
- * Programmer: Robb Matzke
- * Thursday, March 18, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -515,20 +482,14 @@ sigsegv_handler(int H5_ATTR_UNUSED signo)
#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL)
/*-------------------------------------------------------------------------
- * Function: sigbus_handler
+ * Function: sigbus_handler
*
- * Purpose: Handler for SIGBUS. We use signal() instead of sigaction()
- * because it's more portable to non-Posix systems. Although
- * it's not nearly as nice to work with, it does the job for
- * this simple stuff.
+ * Purpose: Handler for SIGBUS. We use signal() instead of sigaction()
+ * because it's more portable to non-Posix systems. Although
+ * it's not nearly as nice to work with, it does the job for
+ * this simple stuff.
*
* Return: Returns via H5LONGJMP to jbuf_g.
- *
- * Programmer: Robb Matzke
- * Thursday, March 18, 1999
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -553,18 +514,14 @@ sigbus_handler(int H5_ATTR_UNUSED signo)
#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL)
/*-------------------------------------------------------------------------
- * Function: sigill_handler
+ * Function: sigill_handler
*
- * Purpose: Handler for SIGILL. We use signal() instead of sigaction()
- * because it's more portable to non-Posix systems. Although
- * it's not nearly as nice to work with, it does the job for
- * this simple stuff.
+ * Purpose: Handler for SIGILL. We use signal() instead of sigaction()
+ * because it's more portable to non-Posix systems. Although
+ * it's not nearly as nice to work with, it does the job for
+ * this simple stuff.
*
* Return: Returns via H5LONGJMP to jbuf_g.
- *
- * Programmer: Raymond Lu
- * 28 October 2013
- *
*-------------------------------------------------------------------------
*/
static void
@@ -588,18 +545,11 @@ sigill_handler(int H5_ATTR_UNUSED signo)
/*-------------------------------------------------------------------------
- * Function: print_results
+ * Function: print_results
*
- * Purpose: Prints information about the detected data types.
+ * Purpose: Prints information about the detected data types.
*
* Return: void
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 14, 1996
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -609,7 +559,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
int i, j;
/* Include files */
- printf("\
+ fprintf(rawoutstream, "\
/****************/\n\
/* Module Setup */\n\
/****************/\n\
@@ -662,7 +612,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/*********************/\n\
\n\
\n");
- printf("\n\
+ fprintf(rawoutstream, "\n\
/*******************/\n\
/* Local Variables */\n\
/*******************/\n\
@@ -670,7 +620,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/* The interface initialization function */
- printf("\n\
+ fprintf(rawoutstream, "\n\
\n\
/*-------------------------------------------------------------------------\n\
* Function: H5T__init_native\n\
@@ -713,12 +663,12 @@ H5T__init_native(void)\n\
}
/* Print a comment to describe this section of definitions. */
- printf("\n /*\n");
+ fprintf(rawoutstream, "\n /*\n");
iprint(d+i);
- printf(" */\n");
+ fprintf(rawoutstream, " */\n");
/* The part common to fixed and floating types */
- printf("\
+ fprintf(rawoutstream, "\
if(NULL == (dt = H5T__alloc()))\n\
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\
dt->shared->state = H5T_STATE_IMMUTABLE;\n\
@@ -728,16 +678,16 @@ H5T__init_native(void)\n\
d[i].size); /*size */
if(byte_order==-1)
- printf("\
+ fprintf(rawoutstream, "\
dt->shared->u.atomic.order = H5T_ORDER_VAX;\n");
else if(byte_order==0)
- printf("\
+ fprintf(rawoutstream, "\
dt->shared->u.atomic.order = H5T_ORDER_LE;\n");
else
- printf("\
+ fprintf(rawoutstream, "\
dt->shared->u.atomic.order = H5T_ORDER_BE;\n");
- printf("\
+ fprintf(rawoutstream, "\
dt->shared->u.atomic.offset = %d;\n\
dt->shared->u.atomic.prec = %d;\n\
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\
@@ -748,12 +698,13 @@ H5T__init_native(void)\n\
if (0 == d[i].msize) {
/* The part unique to fixed point types */
- printf("\
+ fprintf(rawoutstream, "\
dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n",
d[i].sign ? "2" : "NONE");
- } else {
+ }
+ else {
/* The part unique to floating point types */
- printf("\
+ fprintf(rawoutstream, "\
dt->shared->u.atomic.u.f.sign = %d;\n\
dt->shared->u.atomic.u.f.epos = %d;\n\
dt->shared->u.atomic.u.f.esize = %d;\n\
@@ -772,11 +723,11 @@ H5T__init_native(void)\n\
}
/* Atomize the type */
- printf("\
+ fprintf(rawoutstream, "\
if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\")\n",
d[i].varname);
- printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n",
+ fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n",
d[i].varname, (unsigned long)(d[i].align));
/* Variables for alignment of compound datatype */
@@ -784,28 +735,29 @@ H5T__init_native(void)\n\
!HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") ||
!HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") ||
!HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) {
- printf(" H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n",
+ fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n",
d[i].varname, (unsigned long)(d[i].comp_align));
}
}
/* Consider VAX a little-endian machine */
if(byte_order==0 || byte_order==-1) {
- printf("\n\
+ fprintf(rawoutstream, "\n\
/* Set the native order for this machine */\n\
H5T_native_order_g = H5T_ORDER_%s;\n", "LE");
- } else {
- printf("\n\
+ }
+ else {
+ fprintf(rawoutstream, "\n\
/* Set the native order for this machine */\n\
H5T_native_order_g = H5T_ORDER_%s;\n", "BE");
}
/* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */
- printf("\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n");
+ fprintf(rawoutstream, "\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n");
for(j=0; j<na; j++)
- printf(" H5T_%s_COMP_ALIGN_g = %lu;\n", misc_align[j].name, (unsigned long)(misc_align[j].comp_align));
+ fprintf(rawoutstream, " H5T_%s_COMP_ALIGN_g = %lu;\n", misc_align[j].name, (unsigned long)(misc_align[j].comp_align));
- printf("\
+ fprintf(rawoutstream, "\
\n\
done:\n\
if(ret_value < 0) {\n\
@@ -818,73 +770,66 @@ done:\n\
FUNC_LEAVE_NOAPI(ret_value);\n} /* end H5T__init_native() */\n");
/* Print the ALIGNMENT and signal-handling status as comments */
- printf("\n"
+ fprintf(rawoutstream, "\n"
"/****************************************/\n"
"/* ALIGNMENT and signal-handling status */\n"
"/****************************************/\n");
if (align_status_g & STA_NoALIGNMENT)
- printf("/* ALIGNAMENT test is not available */\n");
+ fprintf(rawoutstream, "/* ALIGNAMENT test is not available */\n");
if (align_status_g & STA_NoHandlerVerify)
- printf("/* Signal handlers verify test is not available */\n");
+ fprintf(rawoutstream, "/* Signal handlers verify test is not available */\n");
/* The following is available in H5pubconf.h. Printing them here for */
/* convenience. */
#ifdef H5_HAVE_SIGNAL
- printf("/* Signal() support: yes */\n");
+ fprintf(rawoutstream, "/* Signal() support: yes */\n");
#else
- printf("/* Signal() support: no */\n");
+ fprintf(rawoutstream, "/* Signal() support: no */\n");
#endif
#ifdef H5_HAVE_SETJMP
- printf("/* setjmp() support: yes */\n");
+ fprintf(rawoutstream, "/* setjmp() support: yes */\n");
#else
- printf("/* setjmp() support: no */\n");
+ fprintf(rawoutstream, "/* setjmp() support: no */\n");
#endif
#ifdef H5_HAVE_LONGJMP
- printf("/* longjmp() support: yes */\n");
+ fprintf(rawoutstream, "/* longjmp() support: yes */\n");
#else
- printf("/* longjmp() support: no */\n");
+ fprintf(rawoutstream, "/* longjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGSETJMP
- printf("/* sigsetjmp() support: yes */\n");
+ fprintf(rawoutstream, "/* sigsetjmp() support: yes */\n");
#else
- printf("/* sigsetjmp() support: no */\n");
+ fprintf(rawoutstream, "/* sigsetjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGLONGJMP
- printf("/* siglongjmp() support: yes */\n");
+ fprintf(rawoutstream, "/* siglongjmp() support: yes */\n");
#else
- printf("/* siglongjmp() support: no */\n");
+ fprintf(rawoutstream, "/* siglongjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGPROCMASK
- printf("/* sigprocmask() support: yes */\n");
+ fprintf(rawoutstream, "/* sigprocmask() support: yes */\n");
#else
- printf("/* sigprocmask() support: no */\n");
+ fprintf(rawoutstream, "/* sigprocmask() support: no */\n");
#endif
/* Print the statics of signal handlers called for debugging */
- printf("\n"
+ fprintf(rawoutstream, "\n"
"/******************************/\n"
"/* signal handlers statistics */\n"
"/******************************/\n");
- printf("/* signal_handlers tested: %d times */\n", signal_handler_tested_g);
- printf("/* sigbus_handler called: %d times */\n", sigbus_handler_called_g);
- printf("/* sigsegv_handler called: %d times */\n", sigsegv_handler_called_g);
- printf("/* sigill_handler called: %d times */\n", sigill_handler_called_g);
+ fprintf(rawoutstream, "/* signal_handlers tested: %d times */\n", signal_handler_tested_g);
+ fprintf(rawoutstream, "/* sigbus_handler called: %d times */\n", sigbus_handler_called_g);
+ fprintf(rawoutstream, "/* sigsegv_handler called: %d times */\n", sigsegv_handler_called_g);
+ fprintf(rawoutstream, "/* sigill_handler called: %d times */\n", sigill_handler_called_g);
} /* end print_results() */
/*-------------------------------------------------------------------------
- * Function: iprint
+ * Function: iprint
*
- * Purpose: Prints information about the fields of a floating point
- * format.
+ * Purpose: Prints information about the fields of a floating point format.
*
* Return: void
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
- *
- * Modifications:
- *
+
*-------------------------------------------------------------------------
*/
static void
@@ -897,41 +842,48 @@ iprint(detected_t *d)
/*
* Print the byte ordering above the bit fields.
*/
- printf(" * ");
+ fprintf(rawoutstream, " * ");
for (i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) {
- printf("%4d", d->perm[i]);
- if (i > pass * 4) HDfputs(" ", stdout);
- if (!i) break;
+ fprintf(rawoutstream, "%4d", d->perm[i]);
+ if (i > pass * 4)
+ HDfputs(" ", stdout);
+ if (!i)
+ break;
}
/*
* Print the bit fields
*/
- printf("\n * ");
+ fprintf(rawoutstream, "\n * ");
for (i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31,
8 * d->size - 1); i >= pass * 4; --i) {
unsigned int j;
for (j = 8; j > 0; --j) {
if (k == d->sign && d->msize) {
- HDputchar('S');
- } else if (k >= d->epos && k < d->epos + d->esize) {
- HDputchar('E');
- } else if (k >= d->mpos && k < d->mpos + d->msize) {
- HDputchar('M');
- } else if (d->msize) {
- HDputchar('?'); /*unknown floating point bit */
- } else if (d->sign) {
- HDputchar('I');
- } else {
- HDputchar('U');
+ HDfputc('S', rawoutstream);
+ }
+ else if (k >= d->epos && k < d->epos + d->esize) {
+ HDfputc('E', rawoutstream);
+ }
+ else if (k >= d->mpos && k < d->mpos + d->msize) {
+ HDfputc('M', rawoutstream);
+ }
+ else if (d->msize) {
+ HDfputc('?', rawoutstream); /*unknown floating point bit */
+ }
+ else if (d->sign) {
+ HDfputc('I', rawoutstream);
+ }
+ else {
+ HDfputc('U', rawoutstream);
}
--k;
}
- if (i > pass * 4) HDputchar(' ');
+ if (i > pass * 4) HDfputc(' ', rawoutstream);
if (!i) break;
}
- HDputchar('\n');
+ HDfputc('\n', rawoutstream);
if (!pass) break;
}
@@ -939,41 +891,35 @@ iprint(detected_t *d)
* Is there an implicit bit in the mantissa.
*/
if (d->msize) {
- printf(" * Implicit bit? %s\n", d->imp ? "yes" : "no");
+ fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no");
}
/*
* Alignment
*/
if (0 == d->align) {
- printf(" * Alignment: NOT CALCULATED\n");
- } else if (1 == d->align) {
- printf(" * Alignment: none\n");
- } else {
- printf(" * Alignment: %lu\n", (unsigned long) (d->align));
+ fprintf(rawoutstream, " * Alignment: NOT CALCULATED\n");
+ }
+ else if (1 == d->align) {
+ fprintf(rawoutstream, " * Alignment: none\n");
+ }
+ else {
+ fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long) (d->align));
}
}
/*-------------------------------------------------------------------------
- * Function: byte_cmp
+ * Function: byte_cmp
*
- * Purpose: Compares two chunks of memory A and B and returns the
- * byte index into those arrays of the first byte that
- * differs between A and B. Ignores differences where the
- * corresponding bit in pad_mask is set to 0.
+ * Purpose: Compares two chunks of memory A and B and returns the
+ * byte index into those arrays of the first byte that
+ * differs between A and B. Ignores differences where the
+ * corresponding bit in pad_mask is set to 0.
*
* Return: Success: Index of differing byte.
- *
- * Failure: -1 if all bytes are the same.
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12, 1996
- *
- * Modifications:
- *
+ * Failure: -1 if all bytes are the same.
*-------------------------------------------------------------------------
*/
static int
@@ -992,13 +938,13 @@ byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask)
/*-------------------------------------------------------------------------
- * Function: bit_cmp
+ * Function: bit_cmp
*
- * Purpose: Compares two bit vectors and returns the index for the
- * first bit that differs between the two vectors. The
- * size of the vector is NBYTES. PERM is a mapping from
- * actual order to little endian. Ignores differences where
- * the corresponding bit in pad_mask is set to 0.
+ * Purpose: Compares two bit vectors and returns the index for the
+ * first bit that differs between the two vectors. The
+ * size of the vector is NBYTES. PERM is a mapping from
+ * actual order to little endian. Ignores differences where
+ * the corresponding bit in pad_mask is set to 0.
*
* Return: Index of first differing bit.
*
@@ -1033,24 +979,17 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b,
/*-------------------------------------------------------------------------
- * Function: fix_order
+ * Function: fix_order
*
- * Purpose: Given an array PERM with elements FIRST through LAST
- * initialized with zero origin byte numbers, this function
- * creates a permutation vector that maps the actual order
- * of a floating point number to little-endian.
+ * Purpose: Given an array PERM with elements FIRST through LAST
+ * initialized with zero origin byte numbers, this function
+ * creates a permutation vector that maps the actual order
+ * of a floating point number to little-endian.
*
- * This function assumes that the mantissa byte ordering
- * implies the total ordering.
+ * This function assumes that the mantissa byte ordering
+ * implies the total ordering.
*
* Return: void
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -1059,60 +998,69 @@ fix_order(int n, int last, int *perm, const char **mesg)
int i;
if (last > 1) {
- /*
- * We have at least three points to consider.
- */
- if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) {
/*
- * Little endian.
- */
- if (mesg) *mesg = "Little-endian";
- for (i = 0; i < n; i++) perm[i] = i;
+ * We have at least three points to consider.
+ */
+ if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) {
+ /*
+ * Little endian.
+ */
+ if (mesg)
+ *mesg = "Little-endian";
+ for (i = 0; i < n; i++)
+ perm[i] = i;
- } else if (perm[last] > perm[last-1] && perm[last-1] > perm[last-2]) {
- /*
- * Big endian.
- */
- if (mesg) *mesg = "Big-endian";
- for (i = 0; i < n; i++) perm[i] = (n - 1) - i;
+ }
+ else if (perm[last] > perm[last - 1]
+ && perm[last - 1] > perm[last - 2]) {
+ /*
+ * Big endian.
+ */
+ if (mesg)
+ *mesg = "Big-endian";
+ for (i = 0; i < n; i++)
+ perm[i] = (n - 1) - i;
- } else {
- /*
- * Bi-endian machines like VAX.
+ }
+ else {
+ /*
+ * Bi-endian machines like VAX.
* (NOTE: This is not an actual determination of the VAX-endianness.
* It could have some other endianness and fall into this
* case - JKM & QAK)
- */
- HDassert(0 == n % 2);
- if (mesg) *mesg = "VAX";
- for (i = 0; i < n; i += 2) {
- perm[i] = (n - 2) - i;
- perm[i + 1] = (n - 1) - i;
+ */
+ HDassert(0 == n % 2);
+ if (mesg)
+ *mesg = "VAX";
+ for (i = 0; i < n; i += 2) {
+ perm[i] = (n - 2) - i;
+ perm[i + 1] = (n - 1) - i;
+ }
}
}
- } else {
- fprintf(stderr,
- "Failed to detect byte order of %d-byte floating point.\n", n);
- HDexit(1);
+ else {
+ fprintf(stderr,
+ "Failed to detect byte order of %d-byte floating point.\n", n);
+ HDexit(1);
}
}
/*-------------------------------------------------------------------------
- * Function: imp_bit
+ * Function: imp_bit
*
- * Purpose: Looks for an implicit bit in the mantissa. The value
- * of _A should be 1.0 and the value of _B should be 0.5.
- * Some floating-point formats discard the most significant
- * bit of the mantissa after normalizing since it will always
- * be a one (except for 0.0). If this is true for the native
- * floating point values stored in _A and _B then the function
- * returns non-zero.
+ * Purpose: Looks for an implicit bit in the mantissa. The value
+ * of _A should be 1.0 and the value of _B should be 0.5.
+ * Some floating-point formats discard the most significant
+ * bit of the mantissa after normalizing since it will always
+ * be a one (except for 0.0). If this is true for the native
+ * floating point values stored in _A and _B then the function
+ * returns non-zero.
*
- * This function assumes that the exponent occupies higher
- * order bits than the mantissa and that the most significant
- * bit of the mantissa is next to the least significant bit
- * of the exponent.
+ * This function assumes that the exponent occupies higher
+ * order bits than the mantissa and that the most significant
+ * bit of the mantissa is next to the least significant bit
+ * of the exponent.
*
*
* Return: Success: Non-zero if the most significant bit
@@ -1121,15 +1069,9 @@ fix_order(int n, int last, int *perm, const char **mesg)
* most significant bit). Otherwise,
* returns zero.
*
- * Failure: exit(1)
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Failure: 1
*
* Modifications:
- *
- * Robb Matzke, 6 Nov 1996
* Fixed a bug that occurs with non-implicit architectures.
*
*-------------------------------------------------------------------------
@@ -1162,22 +1104,14 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_
/*-------------------------------------------------------------------------
- * Function: find_bias
+ * Function: find_bias
*
- * Purpose: Determines the bias of the exponent. This function should
- * be called with _A having a value of `1'.
+ * Purpose: Determines the bias of the exponent. This function should
+ * be called with _A having a value of `1'.
*
- * Return: Success: The exponent bias.
- *
- * Failure:
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Return: The exponent bias.
*
* Modifications:
- *
- * Robb Matzke, 6 Nov 1996
* Fixed a bug with non-implicit architectures returning the
* wrong exponent bias.
*
@@ -1205,32 +1139,25 @@ find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a)
/*-------------------------------------------------------------------------
- * Function: print_header
+ * 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
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Mar 12 1997
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
print_header(void)
{
- time_t now = HDtime(NULL);
- struct tm *tm = HDlocaltime(&now);
- char real_name[30];
- char host_name[256];
+ time_t now = HDtime(NULL);
+ struct tm *tm = HDlocaltime(&now);
+ char real_name[30];
+ char host_name[256];
int i;
- const char *s;
+ const char *s;
#ifdef H5_HAVE_GETPWUID
- struct passwd *pwd = NULL;
+ struct passwd *pwd = NULL;
#else
int pwd = 1;
#endif
@@ -1281,20 +1208,22 @@ bit.\n";
*/
#ifdef H5_HAVE_GETPWUID
{
- size_t n;
- char *comma;
- if ((pwd = HDgetpwuid(HDgetuid()))) {
- if ((comma = HDstrchr(pwd->pw_gecos, ','))) {
- n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos));
- HDstrncpy(real_name, pwd->pw_gecos, n);
- real_name[n] = '\0';
- } else {
- HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
- real_name[sizeof(real_name) - 1] = '\0';
+ size_t n;
+ char *comma;
+ if ((pwd = HDgetpwuid(HDgetuid()))) {
+ if ((comma = HDstrchr(pwd->pw_gecos, ','))) {
+ n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos));
+ HDstrncpy(real_name, pwd->pw_gecos, n);
+ real_name[n] = '\0';
+ }
+ else {
+ HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
+ real_name[sizeof(real_name) - 1] = '\0';
+ }
+ }
+ else {
+ real_name[0] = '\0';
}
- } else {
- real_name[0] = '\0';
- }
}
#else
real_name[0] = '\0';
@@ -1305,7 +1234,7 @@ bit.\n";
*/
#ifdef H5_HAVE_GETHOSTNAME
if (HDgethostname(host_name, sizeof(host_name)) < 0) {
- host_name[0] = '\0';
+ host_name[0] = '\0';
}
#else
host_name[0] = '\0';
@@ -1314,78 +1243,71 @@ bit.\n";
/*
* The file header: warning, copyright notice, build information.
*/
- printf("/* Generated automatically by H5detect -- do not edit */\n\n\n");
- HDputs(FileHeader); /*the copyright notice--see top of this file */
+ fprintf(rawoutstream, "/* Generated automatically by H5detect -- do not edit */\n\n\n");
+ HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */
- printf(" *\n * Created:\t\t%s %2d, %4d\n",
+ fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n",
month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
if (pwd || real_name[0] || host_name[0]) {
- printf(" *\t\t\t");
- if (real_name[0]) printf("%s <", real_name);
+ fprintf(rawoutstream, " *\t\t\t");
+ if (real_name[0])
+ fprintf(rawoutstream, "%s <", real_name);
#ifdef H5_HAVE_GETPWUID
- if (pwd) HDfputs(pwd->pw_name, stdout);
+ if (pwd) HDfputs(pwd->pw_name, rawoutstream);
#endif
- if (host_name[0]) printf("@%s", host_name);
- if (real_name[0]) printf(">");
- HDputchar('\n');
+ if (host_name[0])
+ fprintf(rawoutstream, "@%s", host_name);
+ if (real_name[0])
+ fprintf(rawoutstream, ">");
+ HDfputc('\n', rawoutstream);
}
- printf(" *\n * Purpose:\t\t");
+ fprintf(rawoutstream, " *\n * Purpose:\t\t");
for (s = purpose; *s; s++) {
- HDputchar(*s);
- if ('\n' == *s && s[1]) printf(" *\t\t\t");
+ HDfputc(*s, rawoutstream);
+ if ('\n' == *s && s[1])
+ fprintf(rawoutstream, " *\t\t\t");
}
- printf(" *\n * Modifications:\n *\n");
- printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
- printf(" *\tIt was generated by code in `H5detect.c'.\n");
+ fprintf(rawoutstream, " *\n * Modifications:\n *\n");
+ fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
+ fprintf(rawoutstream, " *\tIt was generated by code in `H5detect.c'.\n");
- printf(" *\n *");
- for (i = 0; i < 73; i++) HDputchar('-');
- printf("\n */\n\n");
+ fprintf(rawoutstream, " *\n *");
+ for (i = 0; i < 73; i++)
+ HDfputc('-', rawoutstream);
+ fprintf(rawoutstream, "\n */\n\n");
}
/*-------------------------------------------------------------------------
- * Function: detect_C89_integers
+ * Function: detect_C89_integers
*
- * Purpose: Detect C89 integer types
+ * Purpose: Detect C89 integer types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
detect_C89_integers(void)
{
- DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); nd_g++;
- DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); nd_g++;
- DETECT_I(short, SHORT, d_g[nd_g]); nd_g++;
- DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++;
- DETECT_I(int, INT, d_g[nd_g]); nd_g++;
- DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++;
- DETECT_I(long, LONG, d_g[nd_g]); nd_g++;
- DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); nd_g++;
+ DETECT_I(short, SHORT, d_g[nd_g]); nd_g++;
+ DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++;
+ DETECT_I(int, INT, d_g[nd_g]); nd_g++;
+ DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++;
+ DETECT_I(long, LONG, d_g[nd_g]); nd_g++;
+ DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++;
}
/*-------------------------------------------------------------------------
- * Function: detect_C89_floats
+ * Function: detect_C89_floats
*
- * Purpose: Detect C89 floating point types
+ * Purpose: Detect C89 floating point types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1397,17 +1319,11 @@ detect_C89_floats(void)
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers8
+ * Function: detect_C99_integers8
*
- * Purpose: Detect C99 8 bit integer types
+ * Purpose: Detect C99 8 bit integer types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1415,61 +1331,55 @@ detect_C99_integers8(void)
{
#if H5_SIZEOF_INT8_T>0
#if H5_SIZEOF_INT8_T==1
- DETECT_BYTE(int8_t, INT8, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(int8_t, INT8, d_g[nd_g]); nd_g++;
#else
- DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++;
+ DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++;
#endif
#endif
#if H5_SIZEOF_UINT8_T>0
#if H5_SIZEOF_UINT8_T==1
- DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); nd_g++;
#else
- DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++;
+ DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++;
#endif
#endif
#if H5_SIZEOF_INT_LEAST8_T>0
#if H5_SIZEOF_INT_LEAST8_T==1
- DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++;
#else
- DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++;
+ DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++;
#endif
#endif
#if H5_SIZEOF_UINT_LEAST8_T>0
#if H5_SIZEOF_UINT_LEAST8_T==1
- DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++;
#else
- DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++;
#endif
#endif
#if H5_SIZEOF_INT_FAST8_T>0
#if H5_SIZEOF_INT_FAST8_T==1
- DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++;
#else
DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++;
#endif
#endif
#if H5_SIZEOF_UINT_FAST8_T>0
#if H5_SIZEOF_UINT_FAST8_T==1
- DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++;
+ DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++;
#else
- DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++;
#endif
#endif
}
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers16
+ * Function: detect_C99_integers16
*
- * Purpose: Detect C99 16 bit integer types
+ * Purpose: Detect C99 16 bit integer types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1479,35 +1389,29 @@ detect_C99_integers16(void)
DETECT_I(int16_t, INT16, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT16_T>0
- DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++;
+ DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_INT_LEAST16_T>0
- DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++;
+ DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT_LEAST16_T>0
- DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_INT_FAST16_T>0
- DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++;
+ DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT_FAST16_T>0
- DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++;
#endif
}
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers32
+ * Function: detect_C99_integers32
*
- * Purpose: Detect C99 32 bit integer types
+ * Purpose: Detect C99 32 bit integer types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1517,35 +1421,30 @@ detect_C99_integers32(void)
DETECT_I(int32_t, INT32, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT32_T>0
- DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++;
+ DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_INT_LEAST32_T>0
- DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++;
+ DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT_LEAST32_T>0
- DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_INT_FAST32_T>0
- DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++;
+ DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT_FAST32_T>0
- DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++;
#endif
}
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers64
+ * Function: detect_C99_integers64
*
- * Purpose: Detect C99 64 bit integer types
+ * Purpose: Detect C99 64 bit integer types
*
* Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1555,24 +1454,24 @@ detect_C99_integers64(void)
DETECT_I(int64_t, INT64, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT64_T>0
- DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++;
+ DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_INT_LEAST64_T>0
- DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++;
+ DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT_LEAST64_T>0
- DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_INT_FAST64_T>0
- DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++;
+ DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_UINT_FAST64_T>0
- DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++;
+ DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++;
#endif
#if H5_SIZEOF_LONG_LONG>0
DETECT_I(long long, LLONG, d_g[nd_g]); nd_g++;
- DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++;
+ DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++;
#else
/*
* This architecture doesn't support an integer type larger than `long'
@@ -1580,23 +1479,17 @@ detect_C99_integers64(void)
* `long long' is probably equivalent to `long' here anyway.
*/
DETECT_I(long, LLONG, d_g[nd_g]); nd_g++;
- DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++;
+ DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++;
#endif
}
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers
+ * Function: detect_C99_integers
*
- * Purpose: Detect C99 integer types
+ * Purpose: Detect C99 integer types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1612,17 +1505,11 @@ detect_C99_integers(void)
/*-------------------------------------------------------------------------
- * Function: detect_C99_floats
+ * Function: detect_C99_floats
*
- * Purpose: Detect C99 floating point types
+ * Purpose: Detect C99 floating point types
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1643,17 +1530,11 @@ detect_C99_floats(void)
/*-------------------------------------------------------------------------
- * Function: detect_alignments
+ * Function: detect_alignments
*
- * Purpose: Detect structure alignments
+ * Purpose: Detect structure alignments
*
* Return: void
- *
- * Programmer: Albert Cheng
- * 2004/05/20
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void HDF_NO_UBSAN
@@ -1685,60 +1566,54 @@ static int verify_signal_handlers(int signum, void (*handler)(int))
#endif
void (*save_handler)(int) = HDsignal(signum, handler);
volatile int i, val;
- int ntries=5;
- volatile int nfailures=0;
- volatile int nsuccesses=0;
-
- for (i=0;i<ntries; i++){
- val=H5SETJMP(jbuf_g);
- if (val==0)
- {
- /* send self the signal to trigger the handler */
- signal_handler_tested_g++;
- HDraise(signum);
- /* Should not reach here. Record error. */
- nfailures++;
- }else{
- if (val==signum){
- /* return from signum handler. Record a sucess. */
- nsuccesses++;
- }else{
- fprintf(stderr, "Unknown return value (%d) from H5SETJMP",
- val);
- nfailures++;
+ int ntries = 5;
+ volatile int nfailures = 0;
+ volatile int nsuccesses = 0;
+
+ for (i=0;i<ntries; i++) {
+ val=H5SETJMP(jbuf_g);
+ if (val==0) {
+ /* send self the signal to trigger the handler */
+ signal_handler_tested_g++;
+ HDraise(signum);
+ /* Should not reach here. Record error. */
+ nfailures++;
+ }
+ else {
+ if (val==signum) {
+ /* return from signum handler. Record a sucess. */
+ nsuccesses++;
+ }
+ else {
+ fprintf(stderr, "Unknown return value (%d) from H5SETJMP", val);
+ nfailures++;
+ }
}
- }
}
/* restore save handler, check results and report failures */
HDsignal(signum, save_handler);
- if (nfailures>0 || nsuccesses != ntries){
- fprintf(stderr, "verify_signal_handlers for signal %d did %d tries. "
- "Found %d failures and %d successes\n",
- signum, ntries, nfailures, nsuccesses);
- return(-1);
- }else{
- /* all succeeded */
- return(0);
+ if (nfailures>0 || nsuccesses != ntries) {
+ fprintf(stderr, "verify_signal_handlers for signal %d did %d tries. "
+ "Found %d failures and %d successes\n",
+ signum, ntries, nfailures, nsuccesses);
+ return -1;
+ }
+ else {
+ /* all succeeded */
+ return 0;
}
}
#endif
/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Main entry point.
- *
- * Return: Success: exit(0)
+ * Function: main
*
- * Failure: exit(1)
+ * Purpose: Main entry point.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12, 1996
+ * Return: Success: 0
*
* Modifications:
- * Albert Cheng, 2004/05/20
* Some compilers, e.g., Intel C v7.0, took a long time to compile
* with optimization when a module routine contains many code lines.
* Divide up all those types detections macros into subroutines, both
@@ -1747,8 +1622,24 @@ static int verify_signal_handlers(int signum, void (*handler)(int))
*-------------------------------------------------------------------------
*/
int HDF_NO_UBSAN
-main(void)
+main(int argc, char *argv[])
{
+ char *fname = NULL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawoutstream is changed only when succeeded */
+
+ if (argc > 1) {
+ fname = argv[1];
+ }
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawoutstream = f;
+ }
+ }
+ if (!rawoutstream)
+ rawoutstream = stdout;
#if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS)
#if defined(UAC_NOPRINT) && defined(UAC_SIGBUS)
@@ -1760,7 +1651,7 @@ main(void)
nvpairs[0] = SSIN_UACPROC;
nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS;
if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) {
- fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n",
+ fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n",
HDstrerror(errno));
}
#endif
@@ -1803,5 +1694,12 @@ main(void)
print_results (nd_g, d_g, na_g, m_g);
- return 0;
+ if (rawoutstream && rawoutstream != stdout) {
+ if (HDfclose(rawoutstream))
+ fprintf(stderr, "closing rawoutstream");
+ else
+ rawoutstream = NULL;
+ }
+
+ return EXIT_SUCCESS;
}
diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c
index 1892806..d4caabb 100644
--- a/src/H5make_libsettings.c
+++ b/src/H5make_libsettings.c
@@ -26,13 +26,8 @@ static const char *FileHeader = "\n\
* help@hdfgroup.org. *\n\
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
/*
- *
- * Created: H5make_libsettings.c
- * 17 Mar 2010
- * Quincey Koziol
- *
- * Purpose: Generate the H5libsettings.c file from the
- * libhdf5.settings file.
+ * Purpose: Generate the H5libsettings.c file from the
+ * libhdf5.settings file.
*
*-------------------------------------------------------------------------
*/
@@ -43,33 +38,30 @@ static const char *FileHeader = "\n\
#define LIBSETTINGSFNAME "libhdf5.settings"
-
+FILE *rawoutstream = NULL;
+
/*-------------------------------------------------------------------------
- * Function: insert_libhdf5_settings
- *
- * 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.
+ * Function: insert_libhdf5_settings
*
- * Return: void
- *
- * Programmer: Albert Cheng
- * Apr 20, 2009
+ * 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
*-------------------------------------------------------------------------
*/
static void
insert_libhdf5_settings(FILE *flibinfo)
{
#ifdef H5_HAVE_EMBEDDED_LIBINFO
- FILE *fsettings; /* for files libhdf5.settings */
+ FILE *fsettings; /* for files libhdf5.settings */
int inchar;
- int bol = 0; /* indicates the beginning of a new line */
+ int bol = 0; /* indicates the beginning of a new line */
if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) {
HDperror(LIBSETTINGSFNAME);
- HDexit(1);
+ HDexit(EXIT_FAILURE);
} /* end if */
/* print variable definition and the string */
@@ -77,33 +69,33 @@ insert_libhdf5_settings(FILE *flibinfo)
fprintf(flibinfo, "char H5libhdf5_settings[]=\n");
bol++;
while(EOF != (inchar = HDgetc(fsettings))) {
- if(bol) {
- /* Start a new line */
- fprintf(flibinfo, "\t\"");
- bol = 0;
- } /* end if */
- if(inchar == '\n') {
- /* end of a line */
- fprintf(flibinfo, "\\n\"\n");
- bol++;
+ if(bol) {
+ /* Start a new line */
+ fprintf(flibinfo, "\t\"");
+ bol = 0;
+ } /* end if */
+ if(inchar == '\n') {
+ /* end of a line */
+ fprintf(flibinfo, "\\n\"\n");
+ bol++;
} /* end if */
- else
- HDputc(inchar, flibinfo);
+ else
+ HDputc(inchar, flibinfo);
} /* end while */
if(HDfeof(fsettings)) {
- /* wrap up */
- if(!bol)
- /* EOF found without a new line */
- fprintf(flibinfo, "\\n\"\n");
- fprintf(flibinfo, ";\n\n");
+ /* wrap up */
+ if(!bol)
+ /* EOF found without a new line */
+ fprintf(flibinfo, "\\n\"\n");
+ fprintf(flibinfo, ";\n\n");
} /* end if */
else {
- fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
- HDexit(1);
+ fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
+ HDexit(EXIT_FAILURE);
} /* end else */
if(0 != HDfclose(fsettings)) {
- HDperror(LIBSETTINGSFNAME);
- HDexit(1);
+ HDperror(LIBSETTINGSFNAME);
+ HDexit(EXIT_FAILURE);
} /* end if */
#else
/* print variable definition and an empty string */
@@ -112,61 +104,52 @@ insert_libhdf5_settings(FILE *flibinfo)
#endif
} /* insert_libhdf5_settings() */
-
+
/*-------------------------------------------------------------------------
- * 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.
+ * Function: make_libinfo
*
- * Return: void
- *
- * Programmer: Albert Cheng
- * Sep 15, 2009
+ * 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
*-------------------------------------------------------------------------
*/
static void
make_libinfo(void)
{
/* print variable definition and then the string as a macro. */
- insert_libhdf5_settings(stdout);
+ insert_libhdf5_settings(rawoutstream);
}
-
+
/*-------------------------------------------------------------------------
- * Function: print_header
+ * Function: print_header
*
- * Purpose: Prints the header for the generated file.
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Mar 12 1997
+ * Purpose: Prints the header for the generated file.
*
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
print_header(void)
{
- time_t now = HDtime(NULL);
- struct tm *tm = HDlocaltime(&now);
- char real_name[30];
- char host_name[256];
- int i;
- const char *s;
+ time_t now = HDtime(NULL);
+ struct tm *tm = HDlocaltime(&now);
+ char real_name[30];
+ char host_name[256];
+ int i;
+ const char *s;
#ifdef H5_HAVE_GETPWUID
- struct passwd *pwd = NULL;
+ struct passwd *pwd = NULL;
#else
- int pwd = 1;
+ int pwd = 1;
#endif
- static const char *month_name[] =
+ static const char *month_name[] =
{
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- static const char *purpose = "\
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+ static const char *purpose = "\
This machine-generated source code contains\n\
information about the library build configuration\n";
@@ -175,22 +158,22 @@ information about the library build configuration\n";
*/
#ifdef H5_HAVE_GETPWUID
{
- size_t n;
- char *comma;
+ size_t n;
+ char *comma;
- if((pwd = HDgetpwuid(HDgetuid()))) {
- if((comma = HDstrchr(pwd->pw_gecos, ','))) {
- n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
- HDstrncpy(real_name, pwd->pw_gecos, n);
- real_name[n] = '\0';
- } /* end if */
+ if((pwd = HDgetpwuid(HDgetuid()))) {
+ if((comma = HDstrchr(pwd->pw_gecos, ','))) {
+ n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
+ HDstrncpy(real_name, pwd->pw_gecos, n);
+ real_name[n] = '\0';
+ } /* end if */
else {
- HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
- real_name[sizeof(real_name) - 1] = '\0';
- } /* end else */
- } /* end if */
+ HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
+ real_name[sizeof(real_name) - 1] = '\0';
+ } /* end else */
+ } /* end if */
else
- real_name[0] = '\0';
+ real_name[0] = '\0';
}
#else
real_name[0] = '\0';
@@ -201,7 +184,7 @@ information about the library build configuration\n";
*/
#ifdef H5_HAVE_GETHOSTNAME
if(HDgethostname(host_name, sizeof(host_name)) < 0)
- host_name[0] = '\0';
+ host_name[0] = '\0';
#else
host_name[0] = '\0';
#endif
@@ -209,54 +192,49 @@ information about the library build configuration\n";
/*
* The file header: warning, copyright notice, build information.
*/
- printf("/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
- HDputs(FileHeader); /*the copyright notice--see top of this file */
+ fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
+ HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */
- printf(" *\n * Created:\t\t%s %2d, %4d\n",
- month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
+ fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n",
+ month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
if(pwd || real_name[0] || host_name[0]) {
- printf(" *\t\t\t");
- if(real_name[0])
- printf("%s <", real_name);
+ fprintf(rawoutstream, " *\t\t\t");
+ if(real_name[0])
+ fprintf(rawoutstream, "%s <", real_name);
#ifdef H5_HAVE_GETPWUID
- if(pwd)
- HDfputs(pwd->pw_name, stdout);
+ if(pwd)
+ HDfputs(pwd->pw_name, rawoutstream);
#endif
- if(host_name[0])
- printf("@%s", host_name);
- if(real_name[0])
- printf(">");
- HDputchar('\n');
+ if(host_name[0])
+ fprintf(rawoutstream, "@%s", host_name);
+ if(real_name[0])
+ fprintf(rawoutstream, ">");
+ HDfputc('\n', rawoutstream);
} /* end if */
- printf(" *\n * Purpose:\t\t");
+ fprintf(rawoutstream, " *\n * Purpose:\t\t");
for(s = purpose; *s; s++) {
- HDputchar(*s);
- if('\n' == *s && s[1])
- printf(" *\t\t\t");
+ HDfputc(*s, rawoutstream);
+ if('\n' == *s && s[1])
+ fprintf(rawoutstream, " *\t\t\t");
} /* end for */
- printf(" *\n * Modifications:\n *\n");
- printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
- printf(" *\tIt was generated by code in `H5make_libsettings.c'.\n");
+ fprintf(rawoutstream, " *\n * Modifications:\n *\n");
+ fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
+ fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n");
- printf(" *\n *");
+ fprintf(rawoutstream, " *\n *");
for(i = 0; i < 73; i++)
- HDputchar('-');
- printf("\n */\n\n");
+ HDfputc('-', rawoutstream);
+ fprintf(rawoutstream, "\n */\n\n");
}
-
+
/*-------------------------------------------------------------------------
- * Function: print_footer
- *
- * Purpose: Prints the file footer for the generated file.
+ * Function: print_footer
*
- * Return: void
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Mar 31 2010
+ * Purpose: Prints the file footer for the generated file.
*
+ * Return: void
*-------------------------------------------------------------------------
*/
static void
@@ -265,24 +243,35 @@ print_footer(void)
/* nothing */
}
-
+
/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Main entry point.
- *
- * Return: Success: exit(0)
- *
- * Failure: exit(1)
+ * Function: main
*
- * Programmer: Albert Cheng
- * 2010/4/1
+ * Purpose: Main entry point.
*
+ * Return: Success: 0
*-------------------------------------------------------------------------
*/
int
-main(void)
+main(int argc, char *argv[])
{
+ char *fname = NULL;
+ FILE *f; /* temporary holding place for the stream pointer
+ * so that rawoutstream is changed only when succeeded */
+
+ if (argc > 1) {
+ fname = argv[1];
+ }
+ /* First check if filename is string "NULL" */
+ if (fname != NULL) {
+ /* binary output */
+ if ((f = HDfopen(fname, "w")) != NULL) {
+ rawoutstream = f;
+ }
+ }
+ if (!rawoutstream)
+ rawoutstream = stdout;
+
print_header();
/* Generate embedded library information variable definition */
@@ -290,5 +279,12 @@ main(void)
print_footer();
- HDexit(0);
+ if (rawoutstream && rawoutstream != stdout) {
+ if (HDfclose(rawoutstream))
+ fprintf(stderr, "closing rawoutstream");
+ else
+ rawoutstream = NULL;
+ }
+
+ HDexit(EXIT_SUCCESS);
}
diff --git a/src/Makefile.am b/src/Makefile.am
index a0defad..bc5c09e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -153,7 +153,7 @@ settings_DATA=libhdf5.settings
H5Tinit.c: H5detect$(EXEEXT)
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
sed -e 's/-L/:/g' -e 's/ //g'`" \
- $(RUNSERIAL) ./H5detect$(EXEEXT) > $@ || \
+ $(RUNSERIAL) ./H5detect$(EXEEXT) $@ || \
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
($(RM) $@ ; exit 1)
@@ -165,7 +165,7 @@ H5Tinit.c: H5detect$(EXEEXT)
H5lib_settings.c: H5make_libsettings$(EXEEXT) libhdf5.settings
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
sed -e 's/-L/:/g' -e 's/ //g'`" \
- $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > $@ || \
+ $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) $@ || \
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
($(RM) $@ ; exit 1)