Skip to content

Commit

Permalink
[build] Fix detection macro for aligned accesses required
Browse files Browse the repository at this point in the history
  • Loading branch information
jbnote committed Jan 13, 2008
1 parent 8efb986 commit ef8b8c2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions ac_macros/ax_check_aligned_access_required.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dnl should be accessed per-byte in that case to avoid segfault type errors.
dnl
dnl @category C
dnl @author Guido U. Draheim <[email protected]>
dnl @author Jean-Baptiste Note <[email protected]>
dnl @version 2006-08-17
dnl @license GPLWithACException

Expand All @@ -26,22 +27,28 @@ AC_DEFUN([AX_CHECK_ALIGNED_ACCESS_REQUIRED],
int main()
{
char* string = malloc(40);
char* string = malloc(2*sizeof(int)+1);
const int offset = sizeof(int) + 1;
int i;
for (i=0; i < 40; i++) string[[i]] = i;
for (i=0; i < sizeof(int); i++)
string[i] = i;
for (i=0; i < sizeof(int); i++)
string[i+offset] = i;
{
void* s = string;
int* p = s+1;
int* q = s+2;
int* p = (int *)s;
int* q = (int *)(s+offset);
if (*p == *q) { return 1; }
if (*p != *q) {
return 1;
}
}
return 0;
}
],
[ax_cv_have_aligned_access_required=yes],
[ax_cv_have_aligned_access_required=no],
[ax_cv_have_aligned_access_required=no])
[ax_cv_have_aligned_access_required=yes],
[ax_cv_have_aligned_access_required=yes])
])
if test "$ax_cv_have_aligned_access_required" = yes ; then
AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], [1],
Expand Down

0 comments on commit ef8b8c2

Please sign in to comment.