diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2008-09-18 20:54:36 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2008-09-18 20:54:36 (GMT) |
commit | 8436735388f192ecc19b76ac043117a3d883fa14 (patch) | |
tree | 135291f3dcf477f2aedce7a88f45cea2f9474e3a /configure | |
parent | 6ddb6ed83f9a662559b83bb672244818177ebe0d (diff) | |
download | hdf5-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')
-rwxr-xr-x | configure | 110 |
1 files changed, 110 insertions, 0 deletions
@@ -50567,6 +50567,116 @@ echo "${ECHO_T}no" >&6; } esac +{ echo "$as_me:$LINENO: checking if alignment restrictions are strictly enforced" >&5 +echo $ECHO_N "checking if alignment restrictions are strictly enforced... $ECHO_C" >&6; } +if test "$cross_compiling" = yes; then + + { echo "$as_me:$LINENO: result: unknown, assuming yes" >&5 +echo "${ECHO_T}unknown, assuming yes" >&6; } + +else + cat >conftest.$ac_ext <<_ACEOF + + /* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include <stdlib.h> + #include <string.h> + + typedef struct { + size_t len; + void *p; + } hvl_t; + +#ifdef FC_DUMMY_MAIN +#ifndef FC_DUMMY_MAIN_EQ_F77 +# ifdef __cplusplus + extern "C" +# endif + int FC_DUMMY_MAIN() { return 1; } +#endif +#endif +int +main () +{ + + 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); + + ; + return 0; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + +cat >>confdefs.h <<\_ACEOF +#define NO_ALIGNMENT_RESTRICTIONS 1 +_ACEOF + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "X$HDF_CXX" = "Xyes"; then BUILD_CXX_CONDITIONAL_TRUE= |