1 dnl @synopsis AX_CHECK_ALIGNED_ACCESS_REQUIRED
3 dnl Copyright (C) 2006, 2009 Guido U. Draheim <guidod@gmx.de>
4 dnl Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>
6 dnl This file is free software; the copyright holders
7 dnl give unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
10 dnl While the x86 CPUs allow access to memory objects to be unaligned
11 dnl it happens that most of the modern designs require objects to be
12 dnl aligned - or they will fail with a buserror. That mode is quite known
13 dnl by big-endian machines (sparc, etc) however the alpha cpu is little-
16 dnl The following function will test for aligned access to be required and
17 dnl set a config.h define HAVE_ALIGNED_ACCESS_REQUIRED (name derived by
18 dnl standard usage). Structures loaded from a file (or mmapped to memory)
19 dnl should be accessed per-byte in that case to avoid segfault type errors.
22 dnl @author Guido U. Draheim <guidod@gmx.de>
23 dnl @author Peter Breitenlohner <tex-live@tug.org>
24 dnl @version 2010-02-01
25 dnl @license GPLWithACException
28 AC_DEFUN([AX_CHECK_ALIGNED_ACCESS_REQUIRED],
29 [AC_CACHE_CHECK([if pointers to integers require aligned access],
30 [ax_cv_have_aligned_access_required],
31 [if test "$cross_compiling" = "yes"; then
32 case "$host_cpu" in alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
33 ax_cv_have_aligned_access_required="yes"
42 char* string = malloc(40);
44 for (i=0; i < 40; i++) string[[i]] = i;
50 if (*p == *q) { return 1; }
55 [ax_cv_have_aligned_access_required=yes],
56 [ax_cv_have_aligned_access_required=no],
57 [ax_cv_have_aligned_access_required=no])
60 if test "$ax_cv_have_aligned_access_required" = yes ; then
61 AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], [1],
62 [Define if pointers to integers require aligned access])