1 # ====================================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_check_aligned_access_required.html
3 # ====================================================================================
7 # AC_CHECK_ALIGNED_ACCESS_REQUIRED
11 # While the x86 CPUs allow access to memory objects to be unaligned it
12 # happens that most of the modern designs require objects to be aligned -
13 # or they will fail with a buserror. That mode is quite known by
14 # big-endian machines (sparc, etc) however the alpha cpu is little-
17 # The following function will test for aligned access to be required and
18 # set a config.h define HAVE_ALIGNED_ACCESS_REQUIRED (name derived by
19 # standard usage). Structures loaded from a file (or mmapped to memory)
20 # should be accessed per-byte in that case to avoid segfault type errors.
24 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
26 # This program is free software; you can redistribute it and/or modify it
27 # under the terms of the GNU General Public License as published by the
28 # Free Software Foundation; either version 3 of the License, or (at your
29 # option) any later version.
31 # This program is distributed in the hope that it will be useful, but
32 # WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
34 # Public License for more details.
36 # You should have received a copy of the GNU General Public License along
37 # with this program. If not, see <http://www.gnu.org/licenses/>.
39 # As a special exception, the respective Autoconf Macro's copyright owner
40 # gives unlimited permission to copy, distribute and modify the configure
41 # scripts that are the output of Autoconf when processing the Macro. You
42 # need not follow the terms of the GNU General Public License when using
43 # or distributing such scripts, even though portions of the text of the
44 # Macro appear in them. The GNU General Public License (GPL) does govern
45 # all other use of the material that constitutes the Autoconf Macro.
47 # This special exception to the GPL applies to versions of the Autoconf
48 # Macro released by the Autoconf Archive. When you make and distribute a
49 # modified version of the Autoconf Macro, you may extend this special
50 # exception to the GPL to apply to your modified version as well.
54 AC_DEFUN([AX_CHECK_ALIGNED_ACCESS_REQUIRED],
55 [AC_CACHE_CHECK([if pointers to integers require aligned access],
56 [ax_cv_have_aligned_access_required],
63 char* string = malloc(40);
65 for (i=0; i < 40; i++) string[[i]] = i;
71 if (*p == *q) { return 1; }
76 [ax_cv_have_aligned_access_required=yes],
77 [ax_cv_have_aligned_access_required=no],
78 [ax_cv_have_aligned_access_required=no])
80 if test "$ax_cv_have_aligned_access_required" = yes ; then
81 AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], [1],
82 [Define if pointers to integers require aligned access])