]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add an autoconf test for whether unaligned int access is permitted.
authorNick Mathewson <nickm@torproject.org>
Sun, 21 Mar 2004 04:14:06 +0000 (04:14 +0000)
committerNick Mathewson <nickm@torproject.org>
Sun, 21 Mar 2004 04:14:06 +0000 (04:14 +0000)
It works on macos, and works correctly when I twiddle the test code to
generate a spurious segfault.  Will it work anywhere else?

svn:r1329

configure.in
src/common/util.c
src/common/util.h

index efccf2f7f3348135c247fdca25f70d66ce50d3eb..79b30b3144ecc58b82ee0cc61fa496f6e138c446 100644 (file)
@@ -163,6 +163,19 @@ AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
 AC_CHECK_SIZEOF(__int64)
 
+# Now, let's see about alignment requirements
+AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
+[AC_RUN_IFELSE([AC_LANG_SOURCE(
+[[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
+return *(int*)(&s[1]); }]])],
+       [tor_cv_unaligned_ok=yes],
+       [tor_cv_unaligned_ok=no],
+       [tor_cv_unaligned_ok=cross])])
+if test tor_cv_unaligned_ok = yes; then
+  AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
+            [Define to 1 iff unaligned int access is allowed])
+fi
+
 # $prefix stores the value of the --prefix command line option, or
 # NONE if the option wasn't set.  In the case that it wasn't set, make
 # it be the default, so that we can use it to expand directories now.
index edd785cb878c8fe7a1e7fddcea6317b8a615741a..80299c4e38de8d46cf1b46fe673854e2f01d7c1d 100644 (file)
@@ -86,7 +86,7 @@ void tor_strlower(char *s)
   }
 }
 
-#ifndef UNALIGNED_ACCESS_OK
+#ifndef UNALIGNED_INT_ACCESS_OK
 uint16_t get_uint16(char *cp)
 {
   uint16_t v;
index f05a012b4de2baeb44bc85906183df43ac5c507f..f7ac07fca71f149d58aaed7e6e73de3dfda246f9 100644 (file)
@@ -43,7 +43,7 @@ char *tor_strndup(const char *s, size_t n);
 #define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0)
 void tor_strlower(char *s);
 
-#ifdef UNALIGNED_ACCESS_OK
+#ifdef UNALIGNED_INT_ACCESS_OK
 /* XXX Not actually used yet, but would probably be faster on non-sun
  * hardare.
  */