| 1 |
# Autoconf macros for zziplib. |
| 2 |
# Copyright (C) 2006, 2009 Guido U. Draheim <[email protected]> |
| 3 |
# Copyright (C) 2010 Peter Breitenlohner <[email protected]> |
| 4 |
# |
| 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. |
| 8 |
|
| 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- |
| 13 |
# endian. |
| 14 |
|
| 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([[ |
| 20 |
#include <stdio.h> |
| 21 |
#include <stdlib.h>]], |
| 22 |
[[ |
| 23 |
char* string = malloc(40); |
| 24 |
int i; |
| 25 |
for (i=0; i < 40; i++) string[i] = i; |
| 26 |
{ |
| 27 |
void* s = string; |
| 28 |
int* p = s+1; |
| 29 |
int* q = s+2; |
| 30 |
if (*p == *q) { return 1; } |
| 31 |
}]])], |
| 32 |
[zziplib_cv_aligned_access=no], |
| 33 |
[zziplib_cv_aligned_access=yes], |
| 34 |
[AS_CASE([$host_cpu], |
| 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]) |
| 41 |
fi |
| 42 |
]) # ZZIPLIB_CHECK_ALIGNED_ACCESS |
| 43 |
|