summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-01-30 21:21:07 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-01-30 21:21:07 (GMT)
commit1711c3727e11d41268da1c6d4ae0204e081c5e1d (patch)
treefbb1d50808b8598f23be85f2494aaacac5818cec
parentdc384f474d65116dc1b70db1aea9a671076a89b2 (diff)
downloadhdf5-1711c3727e11d41268da1c6d4ae0204e081c5e1d.zip
hdf5-1711c3727e11d41268da1c6d4ae0204e081c5e1d.tar.gz
hdf5-1711c3727e11d41268da1c6d4ae0204e081c5e1d.tar.bz2
HDFFV-10398 avoid sanitizer failures
-rw-r--r--src/H5detect.c1038
1 files changed, 527 insertions, 511 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index 75a1dba..2cc8366 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -27,23 +27,23 @@ static const char *FileHeader = "\n\
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
/*
*
- * Created: H5detect.c
- * 10 Aug 1997
- * Robb Matzke
+ * 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.
+ * Purpose: This code was borrowed heavily from the `detect.c'
+ * program in the AIO distribution from Lawrence
+ * Livermore National Laboratory.
*
- * Detects machine byte order and floating point
- * format and generates a C source file (H5Tinit.c)
- * to describe those paramters.
+ * Detects machine byte order and floating point
+ * format and generates a C source file (H5Tinit.c)
+ * to describe those paramters.
*
* Assumptions: We have an ANSI compiler. We're on a Unix like
- * system or configure has detected those Unix
- * features which aren't available. We're not
- * running on a Vax or other machine with mixed
- * endianess.
+ * system or configure has detected those Unix
+ * features which aren't available. We're not
+ * running on a Vax or other machine with mixed
+ * endianess.
*
* Modifications:
*
@@ -54,9 +54,19 @@ static const char *FileHeader = "\n\
#include "H5Tpublic.h"
#include "H5Rpublic.h"
+#if defined(__has_attribute)
+#if __has_attribute(no_sanitize)
+#define HDF_NO_UBSAN __attribute__((no_sanitize("undefined")))
+#else
+#define HDF_NO_UBSAN
+#endif
+#else
+#define HDF_NO_UBSAN
+#endif
+
#define MAXDETECT 64
-/* The ALIGNMENT test code may generate the SIGBUS, SIGSEGV, or SIGILL signals.
+/* The ALIGNMENT test code may generate the SIGBUS, SIGSEGV, or SIGILL signals.
* We use setjmp/longjmp in the signal handlers for recovery. But setjmp/longjmp
* do not necessary restore the signal blocking status while sigsetjmp/siglongjmp
* do. If sigsetjmp/siglongjmp are not supported, need to use sigprocmask to
@@ -66,19 +76,19 @@ static const char *FileHeader = "\n\
/* supported. */
#if defined(H5_HAVE_SIGSETJMP) && defined(H5_HAVE_SIGLONGJMP)
/* Always save blocked signals to be restore by siglongjmp. */
-#define H5JMP_BUF sigjmp_buf
-#define H5SETJMP(buf) HDsigsetjmp(buf, 1)
-#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val)
-#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */
+#define H5JMP_BUF sigjmp_buf
+#define H5SETJMP(buf) HDsigsetjmp(buf, 1)
+#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val)
+#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */
#elif defined(H5_HAVE_LONGJMP)
-#define H5JMP_BUF jmp_buf
-#define H5SETJMP(buf) HDsetjmp(buf)
-#define H5LONGJMP(buf, val) HDlongjmp(buf, val)
+#define H5JMP_BUF jmp_buf
+#define H5SETJMP(buf) HDsetjmp(buf)
+#define H5LONGJMP(buf, val) HDlongjmp(buf, val)
#endif
/* ALIGNMENT and signal-handling status codes */
-#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */
-#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */
+#define STA_NoALIGNMENT 0x0001 /* No ALIGNMENT Test */
+#define STA_NoHandlerVerify 0x0002 /* No signal handler Tests */
/*
@@ -133,11 +143,11 @@ 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 sigbus_handler_called_g = 0; /* how many times called */
+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 sigill_handler_called_g = 0; /* how many times called */
-static int signal_handler_tested_g = 0; /* how many times tested */
+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)
static int verify_signal_handlers(int signum, void (*handler)(int));
#endif
@@ -145,16 +155,16 @@ static int verify_signal_handlers(int signum, void (*handler)(int));
static H5JMP_BUF jbuf_g;
#endif
-
+
/*-------------------------------------------------------------------------
- * Function: precision
+ * Function: precision
*
- * Purpose: Determine the precision and offset.
+ * Purpose: Determine the precision and offset.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * Thursday, June 18, 1998
+ * Programmer: Robb Matzke
+ * Thursday, June 18, 1998
*
* Modifications:
*
@@ -167,7 +177,7 @@ precision (detected_t *d)
if (0 == d->msize) {
/*
- * An integer. The permutation can have negative values at the
+ * An integer. The permutation can have negative values at the
* beginning or end which represent padding of bytes. We must adjust
* the precision and offset accordingly.
*/
@@ -201,36 +211,36 @@ 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.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12 1996
*
* Modifications:
*
- * Robb Matzke, 4 Nov 1996
- * The INFO.perm now contains `-1' for bytes that aren't used and
- * are always zero. This happens on the Cray for `short' where
- * sizeof(short) is 8, but only the low-order 4 bytes are ever used.
+ * Robb Matzke, 4 Nov 1996
+ * The INFO.perm now contains `-1' for bytes that aren't used and
+ * are always zero. This happens on the Cray for `short' where
+ * sizeof(short) is 8, but only the low-order 4 bytes are ever used.
*
- * Robb Matzke, 4 Nov 1996
- * Added a `padding' field to indicate how many zero bytes appear to
- * the left (N) or right (-N) of the value.
+ * Robb Matzke, 4 Nov 1996
+ * Added a `padding' field to indicate how many zero bytes appear to
+ * the left (N) or right (-N) of the value.
*
- * Robb Matzke, 5 Nov 1996
- * Removed HFILE and CFILE arguments.
+ * Robb Matzke, 5 Nov 1996
+ * Removed HFILE and CFILE arguments.
*
* Neil Fortner, 6 Sep 2013
* Split macro into DETECT_I and DETECT_BYTE macros, extracted
@@ -273,27 +283,27 @@ precision (detected_t *d)
DETECT_I_BYTE_CORE(TYPE,VAR,INFO,int) \
}
-#define DETECT_I(TYPE,VAR,INFO) { \
+#define DETECT_I(TYPE,VAR,INFO) { \
HDcompile_assert(sizeof(TYPE) > 1); \
\
DETECT_I_BYTE_CORE(TYPE,VAR,INFO,TYPE) \
}
-
+
/*-------------------------------------------------------------------------
- * Function: DETECT_F
+ * 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.
+ * 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
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12 1996
*
*-------------------------------------------------------------------------
*/
@@ -383,31 +393,31 @@ precision (detected_t *d)
} \
}
-
+
/*-------------------------------------------------------------------------
- * Function: DETECT_M
+ * Function: DETECT_M
*
- * Purpose: This macro takes only miscellaneous structures or pointer
+ * 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.
+ * constructs the names and decides the alignment in structure.
*
- * Return: void
+ * Return: void
*
- * Programmer: Raymond Lu
- * slu@ncsa.uiuc.edu
- * Dec 9, 2002
+ * Programmer: Raymond Lu
+ * slu@ncsa.uiuc.edu
+ * Dec 9, 2002
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-#define DETECT_M(TYPE,VAR,INFO) { \
- INFO.name = #VAR; \
- COMP_ALIGNMENT(TYPE, INFO.comp_align); \
+#define DETECT_M(TYPE,VAR,INFO) { \
+ INFO.name = #VAR; \
+ COMP_ALIGNMENT(TYPE, INFO.comp_align); \
}
/* Detect alignment for C structure */
-#define COMP_ALIGNMENT(TYPE,COMP_ALIGN) { \
+#define COMP_ALIGNMENT(TYPE,COMP_ALIGN) { \
struct { \
char c; \
TYPE x; \
@@ -417,67 +427,67 @@ precision (detected_t *d)
}
#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
-#define ALIGNMENT(TYPE,INFO) { \
- char *volatile _buf = NULL; \
- TYPE _val = 1, _val2; \
- volatile size_t _ano = 0; \
- void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \
- void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler);\
- void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \
- \
- _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 */ \
+#define ALIGNMENT(TYPE,INFO) { \
+ char *volatile _buf = NULL; \
+ TYPE _val = 1, _val2; \
+ volatile size_t _ano = 0; \
+ void (*_handler)(int) = HDsignal(SIGBUS, sigbus_handler); \
+ void (*_handler2)(int) = HDsignal(SIGSEGV, sigsegv_handler);\
+ void (*_handler3)(int) = HDsignal(SIGILL, sigill_handler); \
+ \
+ _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 */ \
/* 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]); \
+ /* 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); \
- } \
- HDfree(_buf); \
- HDsignal(SIGBUS, _handler); /*restore original handler*/ \
- HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \
- HDsignal(SIGILL, _handler3); /*restore original handler*/ \
+ 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); \
+ } \
+ HDfree(_buf); \
+ HDsignal(SIGBUS, _handler); /*restore original handler*/ \
+ HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \
+ HDsignal(SIGILL, _handler3); /*restore original handler*/ \
}
#else
-#define ALIGNMENT(TYPE,INFO) { \
- align_status_g |= STA_NoALIGNMENT; \
- (INFO.align)=0; \
+#define ALIGNMENT(TYPE,INFO) { \
+ align_status_g |= STA_NoALIGNMENT; \
+ (INFO.align)=0; \
}
#endif
-
+
#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.
+ * Return: Returns via H5LONGJMP to jbuf_g.
*
- * Programmer: Robb Matzke
- * Thursday, March 18, 1999
+ * Programmer: Robb Matzke
+ * Thursday, March 18, 1999
*
* Modifications:
*
@@ -502,20 +512,20 @@ sigsegv_handler(int H5_ATTR_UNUSED signo)
}
#endif
-
+
#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.
+ * Return: Returns via H5LONGJMP to jbuf_g.
*
- * Programmer: Robb Matzke
- * Thursday, March 18, 1999
+ * Programmer: Robb Matzke
+ * Thursday, March 18, 1999
*
* Modifications:
*
@@ -540,20 +550,20 @@ sigbus_handler(int H5_ATTR_UNUSED signo)
}
#endif
-
+
#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.
+ * Return: Returns via H5LONGJMP to jbuf_g.
*
- * Programmer: Raymond Lu
- * 28 October 2013
+ * Programmer: Raymond Lu
+ * 28 October 2013
*
*-------------------------------------------------------------------------
*/
@@ -576,17 +586,17 @@ sigill_handler(int H5_ATTR_UNUSED signo)
}
#endif
-
+
/*-------------------------------------------------------------------------
- * Function: print_results
+ * Function: print_results
*
- * Purpose: Prints information about the detected data types.
+ * Purpose: Prints information about the detected data types.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 14, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 14, 1996
*
* Modifications:
*
@@ -596,7 +606,7 @@ static void
print_results(int nd, detected_t *d, int na, malign_t *misc_align)
{
int byte_order=0; /*byte order of data types*/
- int i, j;
+ int i, j;
/* Include files */
printf("\
@@ -610,11 +620,11 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/***********/\n\
/* Headers */\n\
/***********/\n\
-#include \"H5private.h\" /* Generic Functions */\n\
-#include \"H5Eprivate.h\" /* Error handling */\n\
-#include \"H5FLprivate.h\" /* Free Lists */\n\
-#include \"H5Iprivate.h\" /* IDs */\n\
-#include \"H5Tpkg.h\" /* Datatypes */\n\
+#include \"H5private.h\" /* Generic Functions */\n\
+#include \"H5Eprivate.h\" /* Error handling */\n\
+#include \"H5FLprivate.h\" /* Free Lists */\n\
+#include \"H5Iprivate.h\" /* IDs */\n\
+#include \"H5Tpkg.h\" /* Datatypes */\n\
\n\
\n\
/****************/\n\
@@ -663,15 +673,15 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
printf("\n\
\n\
/*-------------------------------------------------------------------------\n\
- * Function: H5T__init_native\n\
+ * Function: H5T__init_native\n\
*\n\
- * Purpose: Initialize pre-defined native datatypes from code generated\n\
+ * Purpose: Initialize pre-defined native datatypes from code generated\n\
* during the library configuration by H5detect.\n\
*\n\
- * Return: Success: non-negative\n\
- * Failure: negative\n\
+ * Return: Success: non-negative\n\
+ * Failure: negative\n\
*\n\
- * Programmer: Robb Matzke\n\
+ * Programmer: Robb Matzke\n\
* Wednesday, December 16, 1998\n\
*\n\
*-------------------------------------------------------------------------\n\
@@ -679,8 +689,8 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
herr_t\n\
H5T__init_native(void)\n\
{\n\
- H5T_t *dt = NULL;\n\
- herr_t ret_value = SUCCEED;\n\
+ H5T_t *dt = NULL;\n\
+ herr_t ret_value = SUCCEED;\n\
\n\
FUNC_ENTER_PACKAGE\n");
@@ -702,20 +712,20 @@ H5T__init_native(void)\n\
}
}
- /* Print a comment to describe this section of definitions. */
- printf("\n /*\n");
- iprint(d+i);
- printf(" */\n");
+ /* Print a comment to describe this section of definitions. */
+ printf("\n /*\n");
+ iprint(d+i);
+ printf(" */\n");
- /* The part common to fixed and floating types */
- printf("\
+ /* The part common to fixed and floating types */
+ printf("\
if(NULL == (dt = H5T__alloc()))\n\
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\
dt->shared->state = H5T_STATE_IMMUTABLE;\n\
dt->shared->type = H5T_%s;\n\
dt->shared->size = %d;\n",
- d[i].msize ? "FLOAT" : "INTEGER",/*class */
- d[i].size); /*size */
+ d[i].msize ? "FLOAT" : "INTEGER",/*class */
+ d[i].size); /*size */
if(byte_order==-1)
printf("\
@@ -732,18 +742,18 @@ H5T__init_native(void)\n\
dt->shared->u.atomic.prec = %d;\n\
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n",
- d[i].offset, /*offset */
- d[i].precision); /*precision */
+ d[i].offset, /*offset */
+ d[i].precision); /*precision */
/*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */
- if (0 == d[i].msize) {
- /* The part unique to fixed point types */
- printf("\
+ if (0 == d[i].msize) {
+ /* The part unique to fixed point types */
+ printf("\
dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n",
- d[i].sign ? "2" : "NONE");
- } else {
- /* The part unique to floating point types */
- printf("\
+ d[i].sign ? "2" : "NONE");
+ } else {
+ /* The part unique to floating point types */
+ printf("\
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\
@@ -752,22 +762,22 @@ H5T__init_native(void)\n\
dt->shared->u.atomic.u.f.msize = %d;\n\
dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
- d[i].sign, /*sign location */
- d[i].epos, /*exponent loc */
- d[i].esize, /*exponent size */
- (unsigned long)(d[i].bias), /*exponent bias */
- d[i].mpos, /*mantissa loc */
- d[i].msize, /*mantissa size */
- d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
- }
-
- /* Atomize the type */
- printf("\
+ d[i].sign, /*sign location */
+ d[i].epos, /*exponent loc */
+ d[i].esize, /*exponent size */
+ (unsigned long)(d[i].bias), /*exponent bias */
+ d[i].mpos, /*mantissa loc */
+ d[i].msize, /*mantissa size */
+ d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
+ }
+
+ /* Atomize the type */
+ printf("\
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",
- d[i].varname, (unsigned long)(d[i].align));
+ d[i].varname);
+ printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n",
+ d[i].varname, (unsigned long)(d[i].align));
/* Variables for alignment of compound datatype */
if(!HDstrcmp(d[i].varname, "SCHAR") || !HDstrcmp(d[i].varname, "SHORT") ||
@@ -809,69 +819,69 @@ done:\n\
/* Print the ALIGNMENT and signal-handling status as comments */
printf("\n"
- "/****************************************/\n"
- "/* ALIGNMENT and signal-handling status */\n"
- "/****************************************/\n");
+ "/****************************************/\n"
+ "/* ALIGNMENT and signal-handling status */\n"
+ "/****************************************/\n");
if (align_status_g & STA_NoALIGNMENT)
- printf("/* ALIGNAMENT test is not available */\n");
+ printf("/* ALIGNAMENT test is not available */\n");
if (align_status_g & STA_NoHandlerVerify)
- printf("/* Signal handlers verify test is not available */\n");
+ printf("/* 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");
+ printf("/* Signal() support: yes */\n");
#else
- printf("/* Signal() support: no */\n");
+ printf("/* Signal() support: no */\n");
#endif
#ifdef H5_HAVE_SETJMP
- printf("/* setjmp() support: yes */\n");
+ printf("/* setjmp() support: yes */\n");
#else
- printf("/* setjmp() support: no */\n");
+ printf("/* setjmp() support: no */\n");
#endif
#ifdef H5_HAVE_LONGJMP
- printf("/* longjmp() support: yes */\n");
+ printf("/* longjmp() support: yes */\n");
#else
- printf("/* longjmp() support: no */\n");
+ printf("/* longjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGSETJMP
- printf("/* sigsetjmp() support: yes */\n");
+ printf("/* sigsetjmp() support: yes */\n");
#else
- printf("/* sigsetjmp() support: no */\n");
+ printf("/* sigsetjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGLONGJMP
- printf("/* siglongjmp() support: yes */\n");
+ printf("/* siglongjmp() support: yes */\n");
#else
- printf("/* siglongjmp() support: no */\n");
+ printf("/* siglongjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGPROCMASK
- printf("/* sigprocmask() support: yes */\n");
+ printf("/* sigprocmask() support: yes */\n");
#else
- printf("/* sigprocmask() support: no */\n");
+ printf("/* sigprocmask() support: no */\n");
#endif
/* Print the statics of signal handlers called for debugging */
printf("\n"
- "/******************************/\n"
- "/* signal handlers statistics */\n"
- "/******************************/\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);
} /* 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
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
@@ -945,22 +955,22 @@ iprint(detected_t *d)
}
-
+
/*-------------------------------------------------------------------------
- * 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
+ * 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.
+ * Return: Success: Index of differing byte.
*
- * Failure: -1 if all bytes are the same.
+ * Failure: -1 if all bytes are the same.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12, 1996
*
* Modifications:
*
@@ -980,17 +990,17 @@ byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask)
return -1;
}
-
+
/*-------------------------------------------------------------------------
- * 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
+ * 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.
+ * Return: Index of first differing bit.
*
*-------------------------------------------------------------------------
*/
@@ -1021,23 +1031,23 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b,
return 0;
}
-
+
/*-------------------------------------------------------------------------
- * 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
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
@@ -1046,81 +1056,81 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b,
static void
fix_order(int n, int last, int *perm, const char **mesg)
{
- int i;
+ 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;
-
- } 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.
+ /*
+ * 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 {
+ /*
+ * Bi-endian machines like VAX.
* (NOTE: This is not an actual determination of the VAX-endianess.
* It could have some other endianess 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);
+ 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 signficant 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 signficant bit
+ * of the exponent.
*
*
- * Return: Success: Non-zero if the most significant bit
- * of the mantissa is discarded (ie, the
- * mantissa has an implicit `one' as the
- * most significant bit). Otherwise,
- * returns zero.
+ * Return: Success: Non-zero if the most significant bit
+ * of the mantissa is discarded (ie, the
+ * mantissa has an implicit `one' as the
+ * most significant bit). Otherwise,
+ * returns zero.
*
- * Failure: exit(1)
+ * Failure: exit(1)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
- * Robb Matzke, 6 Nov 1996
- * Fixed a bug that occurs with non-implicit architectures.
+ * Robb Matzke, 6 Nov 1996
+ * Fixed a bug that occurs with non-implicit architectures.
*
*-------------------------------------------------------------------------
*/
@@ -1150,26 +1160,26 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_
return (a[perm[major]] >> minor) & 0x01 ? 0 : 1;
}
-
+
/*-------------------------------------------------------------------------
- * 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.
+ * Return: Success: The exponent bias.
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
- * Robb Matzke, 6 Nov 1996
- * Fixed a bug with non-implicit architectures returning the
- * wrong exponent bias.
+ * Robb Matzke, 6 Nov 1996
+ * Fixed a bug with non-implicit architectures returning the
+ * wrong exponent bias.
*
*-------------------------------------------------------------------------
*/
@@ -1193,17 +1203,17 @@ find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a)
return bias;
}
-
+
/*-------------------------------------------------------------------------
- * 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
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Mar 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Mar 12 1997
*
* Modifications:
*
@@ -1213,22 +1223,22 @@ 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 various integer and\n\
floating point numeric formats found on this\n\
@@ -1240,7 +1250,7 @@ Each of the numeric formats listed below are\n\
printed from most significant bit to least\n\
significant bit even though the actual bytes\n\
might be stored in a different order in\n\
-memory. The integers above each binary byte\n\
+memory. The integers above each binary byte\n\
indicate the relative order of the bytes in\n\
memory; little-endian machines have\n\
decreasing numbers while big-endian machines\n\
@@ -1251,8 +1261,8 @@ letters with `S' for the mantissa sign bit,\n\
`M' for the mantissa magnitude, and `E' for\n\
the exponent. The exponent has an associated\n\
bias which can be subtracted to find the\n\
-true exponent. The radix point is assumed\n\
-to be before the first `M' bit. Any bit\n\
+true exponent. The radix point is assumed\n\
+to be before the first `M' bit. Any bit\n\
of a floating-point value not falling into one\n\
of these categories is printed as a question\n\
mark. Bits of integer types are printed as\n\
@@ -1271,20 +1281,20 @@ 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';
- }
- } else {
- real_name[0] = '\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';
@@ -1295,7 +1305,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';
@@ -1305,24 +1315,24 @@ 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 */
+ HDputs(FileHeader); /*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);
+ 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);
+ printf(" *\t\t\t");
+ if (real_name[0]) printf("%s <", real_name);
#ifdef H5_HAVE_GETPWUID
- if (pwd) HDfputs(pwd->pw_name, stdout);
+ if (pwd) HDfputs(pwd->pw_name, stdout);
#endif
- if (host_name[0]) printf("@%s", host_name);
- if (real_name[0]) printf(">");
- HDputchar('\n');
+ if (host_name[0]) printf("@%s", host_name);
+ if (real_name[0]) printf(">");
+ HDputchar('\n');
}
printf(" *\n * Purpose:\t\t");
for (s = purpose; *s; s++) {
- HDputchar(*s);
- if ('\n' == *s && s[1]) printf(" *\t\t\t");
+ HDputchar(*s);
+ if ('\n' == *s && s[1]) printf(" *\t\t\t");
}
printf(" *\n * Modifications:\n *\n");
@@ -1335,84 +1345,84 @@ bit.\n";
}
-
+
/*-------------------------------------------------------------------------
- * Function: detect_C89_integers
+ * Function: detect_C89_integers
*
- * Purpose: Detect C89 integer types
+ * Purpose: Detect C89 integer types
*
- * Return: void
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C89_integers(void)
+detect_C89_integers(void) HDF_NO_UBSAN
{
- 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
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C89_floats(void)
+detect_C89_floats(void) HDF_NO_UBSAN
{
DETECT_F(float, FLOAT, d_g[nd_g]); nd_g++;
DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++;
}
-
+
/*-------------------------------------------------------------------------
- * Function: detect_C99_integers8
+ * Function: detect_C99_integers8
*
- * Purpose: Detect C99 8 bit integer types
+ * Purpose: Detect C99 8 bit integer types
*
- * Return: void
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C99_integers8(void)
+detect_C99_integers8(void) HDF_NO_UBSAN
{
#if H5_SIZEOF_INT8_T>0
#if H5_SIZEOF_INT8_T==1
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++;
#endif
@@ -1421,147 +1431,147 @@ detect_C99_integers8(void)
#if H5_SIZEOF_INT_LEAST8_T==1
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++;
#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++;
#else
- DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++;
+ 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++;
#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
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C99_integers16(void)
+detect_C99_integers16(void) HDF_NO_UBSAN
{
#if H5_SIZEOF_INT16_T>0
- DETECT_I(int16_t, INT16, d_g[nd_g]); nd_g++;
+ 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
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C99_integers32(void)
+detect_C99_integers32(void) HDF_NO_UBSAN
{
#if H5_SIZEOF_INT32_T>0
- DETECT_I(int32_t, INT32, d_g[nd_g]); nd_g++;
+ 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
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C99_integers64(void)
+detect_C99_integers64(void) HDF_NO_UBSAN
{
#if H5_SIZEOF_INT64_T>0
- DETECT_I(int64_t, INT64, d_g[nd_g]); nd_g++;
+ 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(long long, LLONG, d_g[nd_g]); nd_g++;
DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++;
#else
/*
@@ -1569,28 +1579,28 @@ detect_C99_integers64(void)
* so we'll just make H5T_NATIVE_LLONG the same as H5T_NATIVE_LONG since
* `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(long, LLONG, 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
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C99_integers(void)
+detect_C99_integers(void) HDF_NO_UBSAN
{
/* break it down to more subroutines so that each module subroutine */
/* is smaller and takes less time to compile with optimization on. */
@@ -1600,23 +1610,23 @@ detect_C99_integers(void)
detect_C99_integers64();
}
-
+
/*-------------------------------------------------------------------------
- * Function: detect_C99_floats
+ * Function: detect_C99_floats
*
- * Purpose: Detect C99 floating point types
+ * Purpose: Detect C99 floating point types
*
- * Return: void
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_C99_floats(void)
+detect_C99_floats(void) HDF_NO_UBSAN
{
#if H5_SIZEOF_DOUBLE == H5_SIZEOF_LONG_DOUBLE
/*
@@ -1625,29 +1635,29 @@ detect_C99_floats(void)
* some systems and `long double' is probably the same as `double' here
* anyway.
*/
- DETECT_F(double, LDOUBLE, d_g[nd_g]); nd_g++;
+ DETECT_F(double, LDOUBLE, d_g[nd_g]); nd_g++;
#elif H5_SIZEOF_LONG_DOUBLE !=0
- DETECT_F(long double, LDOUBLE, d_g[nd_g]); nd_g++;
+ DETECT_F(long double, LDOUBLE, d_g[nd_g]); nd_g++;
#endif
}
-
+
/*-------------------------------------------------------------------------
- * Function: detect_alignments
+ * Function: detect_alignments
*
- * Purpose: Detect structure alignments
+ * Purpose: Detect structure alignments
*
- * Return: void
+ * Return: void
*
- * Programmer: Albert Cheng
- * 2004/05/20
+ * Programmer: Albert Cheng
+ * 2004/05/20
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-detect_alignments(void)
+detect_alignments(void) HDF_NO_UBSAN
{
/* Detect structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */
DETECT_M(void *, POINTER, m_g[na_g]); na_g++;
@@ -1656,7 +1666,7 @@ detect_alignments(void)
DETECT_M(hdset_reg_ref_t, HDSETREGREF, m_g[na_g]); na_g++;
}
-
+
#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
/* Verify the signal handler for signal signum works correctly multiple times.
* One possible cause of failure is that the signal handling is blocked or
@@ -1664,64 +1674,70 @@ detect_alignments(void)
* Return 0 for success, -1 for failure.
*/
static int verify_signal_handlers(int signum, void (*handler)(int))
-{
- void (*save_handler)(int) = HDsignal(signum, handler);
+{
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer) || __has_feature(thread_sanitizer)
+ /* Under the address and thread sanitizers, don't raise any signals. */
+ return 0;
+#endif
+#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++;
- }
- }
- }
+
+ 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);
+ 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);
+ /* all succeeded */
+ return(0);
}
-}
+}
#endif
-
+
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Main entry point.
+ * Purpose: Main entry point.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(1)
+ * Failure: exit(1)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12, 1996
*
* Modifications:
- * Albert Cheng, 2004/05/20
- * Some compilers, e.g., Intel C v7.0, took a long time to compile
+ * 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
* to avoid the compiler optimization error and cleaner codes.
@@ -1729,7 +1745,7 @@ static int verify_signal_handlers(int signum, void (*handler)(int))
*-------------------------------------------------------------------------
*/
int
-main(void)
+main(void) HDF_NO_UBSAN
{
#if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS)
@@ -1738,12 +1754,12 @@ main(void)
* Make sure unaligned access generates SIGBUS and doesn't print warning
* messages so that we can detect alignment constraints on the DEC Alpha.
*/
- int nvpairs[2];
+ int nvpairs[2];
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",
- HDstrerror(errno));
+ fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n",
+ HDstrerror(errno));
}
#endif
#endif