summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2008-09-18 20:54:36 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2008-09-18 20:54:36 (GMT)
commit8436735388f192ecc19b76ac043117a3d883fa14 (patch)
tree135291f3dcf477f2aedce7a88f45cea2f9474e3a /configure.in
parent6ddb6ed83f9a662559b83bb672244818177ebe0d (diff)
downloadhdf5-8436735388f192ecc19b76ac043117a3d883fa14.zip
hdf5-8436735388f192ecc19b76ac043117a3d883fa14.tar.gz
hdf5-8436735388f192ecc19b76ac043117a3d883fa14.tar.bz2
[svn-r15657] Purpose: fix bug 1286
Description: Added configure test to see if pointer alignment restrictions are enforced (as in dereferencing an unaligned pointer causes an error). Added code in H5Tvlen.c to avoid dereferencing unaligned pointers, conditionally compiled based on the configure test. Added test case in dtypes.c which would previously cause such machines to fail. Tested: kagiso, smirom, linew (h5committest); linew64
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in47
1 files changed, 47 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index b6a9065..dc8cb0f 100644
--- a/configure.in
+++ b/configure.in
@@ -3764,6 +3764,53 @@ esac
dnl ----------------------------------------------------------------------
+dnl Check if pointer alignments are enforced
+dnl
+AC_MSG_CHECKING([if alignment restrictions are strictly enforced])
+AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([
+ #include <stdlib.h>
+ #include <string.h>
+
+ typedef struct {
+ size_t len;
+ void *p;
+ } hvl_t;
+ ], [
+ char *chp = "beefs";
+ char **chpp = malloc (2 * sizeof (char *));
+ char **chpp2;
+ hvl_t vl = { 12345, (void *) chp };
+ hvl_t *vlp;
+ hvl_t *vlp2;
+
+ memcpy ((void *) ((char *) chpp + 1), &chp, sizeof (char *));
+ chpp2 = (char **) ((char *) chpp + 1);
+ if (strcmp (*chpp2, chp)) {
+ free (chpp);
+ return 1;
+ }
+ free (chpp);
+
+ vlp = malloc (2 * sizeof (hvl_t));
+ memcpy ((void *) ((char *) vlp + 1), &vl, sizeof (hvl_t));
+ vlp2 = (hvl_t *) ((char *) vlp + 1);
+ if (vlp2->len != vl.len || vlp2->p != vl.p) {
+ free (vlp);
+ return 1;
+ }
+ free (vlp);
+ ])
+ ], [
+ AC_DEFINE([NO_ALIGNMENT_RESTRICTIONS], [1], [Define if we can violate pointer alignment restrictions])
+ AC_MSG_RESULT([no])
+ ], [
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([unknown, assuming yes])
+ ])
+
+dnl ----------------------------------------------------------------------
dnl Create automake conditionals to tell automake makefiles which directories
dnl need to be compiled