diff options
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 51 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/coucal.c | 2 |
4 files changed, 58 insertions, 1 deletions
diff --git a/config.h.in b/config.h.in index c146b78..af17a1b 100644 --- a/config.h.in +++ b/config.h.in @@ -6,6 +6,9 @@ /* Check for ftime */ #undef FTIME +/* Define if pointers to integers require aligned access */ +#undef HAVE_ALIGNED_ACCESS_REQUIRED + /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H @@ -12456,6 +12456,57 @@ $as_echo "#define sa_family_t uint16_t" >>confdefs.h fi +# check wether misaligned access is possible or not +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if pointers to integers require aligned access" >&5 +$as_echo_n "checking if pointers to integers require aligned access... " >&6; } +if ${ax_cv_have_aligned_access_required+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ax_cv_have_aligned_access_required=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + char* string = malloc(40); + int i; + for (i=0; i < 40; i++) string[[i]] = i; + { + void* s = string; + int* p = s+1; + int* q = s+2; + + if (*p == *q) { return 1; } + } + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ax_cv_have_aligned_access_required=yes +else + ax_cv_have_aligned_access_required=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_aligned_access_required" >&5 +$as_echo "$ax_cv_have_aligned_access_required" >&6; } +if test "$ax_cv_have_aligned_access_required" = yes ; then + +$as_echo "#define HAVE_ALIGNED_ACCESS_REQUIRED 1" >>confdefs.h + +fi + + ### zlib # # Handle user hints diff --git a/configure.ac b/configure.ac index 58bae04..cb55b6c 100644 --- a/configure.ac +++ b/configure.ac @@ -113,6 +113,9 @@ AC_CHECK_TYPE(sa_family_t, [], [AC_DEFINE([sa_family_t], [uint16_t], [sa_family_ #include <netinet/in.h> ]) +# check wether misaligned access is possible or not +AX_CHECK_ALIGNED_ACCESS_REQUIRED + ### zlib CHECK_ZLIB() diff --git a/src/coucal.c b/src/coucal.c index d4ab9e4..b1d6de9 100644 --- a/src/coucal.c +++ b/src/coucal.c @@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if (!defined(HTS_INTHASH_USES_MD5) && !defined(HTS_INTHASH_USES_MURMUR)) /* Temporry: fixing Invalid address alignment issues */ -#if defined(__ANDROID__) +#if (defined(__ANDROID__) || defined(HAVE_ALIGNED_ACCESS_REQUIRED)) #define HTS_INTHASH_USES_MD5 1 #else #define HTS_INTHASH_USES_MURMUR 1 |