Index: configure.ac =================================================================== --- configure.ac (revision 341768) +++ configure.ac (working copy) @@ -538,6 +538,9 @@ AC_C_VOLATILE AC_CHECK_TYPES([ptrdiff_t]) +# Checks for processor features +AST_C_NO_MISALIGN + # Checks for library functions. AC_FUNC_CHOWN AC_FUNC_CLOSEDIR_VOID Index: include/asterisk/unaligned.h =================================================================== --- include/asterisk/unaligned.h (revision 341768) +++ include/asterisk/unaligned.h (working copy) @@ -68,7 +68,7 @@ pp->d = datum; } -#elif defined(SOLARIS) && defined(__sparc__) +#elif defined(HAVE_NO_MISALIGNMENT) static inline uint64_t get_unaligned_uint64(const void *p) { const unsigned char *cp = p; Index: include/asterisk/autoconfig.h.in =================================================================== --- include/asterisk/autoconfig.h.in (revision 341768) +++ include/asterisk/autoconfig.h.in (working copy) @@ -494,6 +494,9 @@ /* Define to 1 if you have the newt library. */ #undef HAVE_NEWT +/* Define to 1 if variable misalignment is not allowed. */ +#undef HAVE_NO_MISALIGNMENT + /* Define to 1 if you have the `ntohll' function. */ #undef HAVE_NTOHLL Index: main/utils.c =================================================================== --- main/utils.c (revision 341768) +++ main/utils.c (working copy) @@ -1666,7 +1666,7 @@ } result = (*pool_head)->base + (*pool_head)->used; -#ifdef __sparc__ +#ifdef HAVE_NO_MISALIGNMENT /* SPARC requires that the allocation field be aligned. */ if ((long) result % sizeof(ast_string_field_allocation)) { result++; @@ -1747,7 +1747,7 @@ } } else { target = (*pool_head)->base + (*pool_head)->used + sizeof(ast_string_field_allocation); -#ifdef __sparc__ +#ifdef HAVE_NO_MISALIGNMENT if ((long) target % sizeof(ast_string_field_allocation)) { target++; space--; --- /dev/null 2011-09-30 12:00:04.743749832 +0200 +++ autoconf/ast_c_no_misalign.m4 2011-10-26 22:17:12.714994354 +0200 @@ -0,0 +1,31 @@ +# AST_C_NO_MISALIGN +# ----------------- +AC_DEFUN([AST_C_NO_MISALIGN], +_AST_C_NO_MISALIGN() +if test "x$ac_cv_c_no_misalign_no_problem" = xcross; then + # Be on the safe side and force alignment + AC_DEFINE(HAVE_NO_MISALIGNMENT, 1, [Define to 1 if variable misalignment is not allowed.]) + #AC_MSG_WARN([result $ac_cv_c_no_misalign_no_problem guessed because of cross compilation]) +elif test "x$ac_cv_c_no_misalign_no_problem" = xbad; then + AC_DEFINE(HAVE_NO_MISALIGNMENT, 1, [Define to 1 if variable misalignment is not allowed.]) +fi +)# AST_C_NO_MISALIGN + +# _AST_C_NO_MISALIGN +# ------------------ +AC_DEFUN([_AST_C_NO_MISALIGN], + [AC_CACHE_CHECK(whether misalignment is allowed, ac_cv_c_no_misalign, + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], + [ + uint64_t buf64[[3]]; + uint8_t *p; + memcpy(buf64, "AAAAAAA" "BBBBBBBB" "CCCCCCCC", 24); /* 7+8+8+1 */ + p = (uint8_t*)&buf64[[0]] + 7; + /* Either bad result or SIGBUS on some systems */ + return (*((uint64_t*)p) == 0x4242424242424242ull) ? 0 : 1; + ])], + [ac_cv_c_no_misalign=ok], + [ac_cv_c_no_misalign=bad], + [ac_cv_c_no_misalign=cross])])] +)# _AST_C_NO_MISALIGN