1 # Autoconf macros for zziplib.
2 # Copyright (C) 2006, 2009 Guido U. Draheim <guidod@gmx.de>
3 # Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>
5 # This file is free software; the copyright holders
6 # give unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # While the x86 CPUs allow access to memory objects to be unaligned
10 # it happens that most of the modern designs require objects to be
11 # aligned - or they will fail with a buserror. That mode is quite known
12 # by big-endian machines (sparc, etc) however the alpha cpu is little-
15 AC_DEFUN([ZZIPLIB_CHECK_ALIGNED_ACCESS],
16 [AC_REQUIRE([AC_CANONICAL_HOST])
17 AC_CACHE_CHECK([if pointers to integers require aligned access],
18 [zziplib_cv_aligned_access],
19 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
21 #include <stdlib.h>]],
23 char* string = malloc(40);
25 for (i=0; i < 40; i++) string[i] = i;
30 if (*p == *q) { return 1; }
32 [zziplib_cv_aligned_access=no],
33 [zziplib_cv_aligned_access=yes],
35 [alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1],
36 [zziplib_cv_aligned_access=yes],
37 [zziplib_cv_aligned_access=no])])])
38 if test "x$zziplib_cv_aligned_access" = xyes ; then
39 AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], 1,
40 [Define if pointers to integers require aligned access])
42 ]) # ZZIPLIB_CHECK_ALIGNED_ACCESS