armv5 archs require write alignment
authorJason Wessel <jason.wessel@windriver.com>
Wed, 4 May 2011 19:35:20 +0000 (15:35 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 4 May 2011 19:35:20 +0000 (15:35 -0400)
Reads and writes to unsigned int 32 bit numbers must be address
aligned or the l2 cache can return junk in the high order 16 bits on
reads.

This patch activates the original work done for alignment in ltt for
the UST code.  The config.ac changes will isolate the use of alignment
to the known arch type with the problem.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
configure.ac
include/Makefile.am
include/ust/config.h.in [new file with mode: 0644]
include/ust/core.h

index 8ca32ff59570bc858bce406f7d518076cacdfa54..1f3cb33f8279720e6e35c5d53d85b583c1029aee 100644 (file)
@@ -9,7 +9,8 @@ AC_CONFIG_MACRO_DIR([config])
 AM_INIT_AUTOMAKE([foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AC_CONFIG_SRCDIR([ustctl/ustctl.c])
-AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_HEADERS([config.h include/ust/config.h])
+AH_TEMPLATE([HAVE_EFFICIENT_UNALIGNED_ACCESS], [Use efficient unaligned access.])
 
 # Checks for programs.
 AC_PROG_CC
@@ -108,6 +109,7 @@ changequote([,])dnl
        ppc64) LIBFORMAT="elf64-powerpc" ;;
        s390) LIBFORMAT="elf32-s390" ;;
        s390x) LIBFORMAT="elf64-s390" ;;
+        armv5) LIBFORMAT="elf32-littlearm"; NO_UNALIGNED_ACCESS=1 ;;
        arm) LIBFORMAT="elf32-littlearm" ;;
        mips*) LIBFORMAT="" ;;
        *) AC_MSG_ERROR([unable to detect library format (unsupported architecture ($host_cpu)?)]) ;;
@@ -115,6 +117,30 @@ esac
 AC_SUBST(LIBFORMAT)
 AC_MSG_RESULT($LIBFORMAT)
 
+if test "x$host_cpu" = "xarm" ; then
+AC_MSG_CHECKING([checking for armv5])
+AC_TRY_COMPILE(
+[
+],
+[
+#ifndef __ARM_ARCH_5TEJ__
+#error "no arm5 here"
+#endif
+],
+[
+       AC_MSG_RESULT([yes])
+       NO_UNALIGNED_ACCESS=1
+]
+,
+[
+       AC_MSG_RESULT([no])
+]
+)
+fi
+if test x$NO_UNALIGNED_ACCESS = x ; then
+AC_DEFINE([HAVE_EFFICIENT_UNALIGNED_ACCESS], [1])
+fi
+
 AC_CONFIG_FILES([
        Makefile
        doc/Makefile
index 2133efdc7f0a0b51b95de847e42862c7e1a6e1bb..7f9d15e30db033511ebc8eb8d836671905c83f0a 100644 (file)
@@ -7,6 +7,7 @@ nobase_include_HEADERS = \
        ust/probe.h \
        ust/ust.h \
        ust/tracectl.h \
+       ust/config.h \
        ust/core.h \
        ust/clock.h \
        ust/type-serializer.h \
diff --git a/include/ust/config.h.in b/include/ust/config.h.in
new file mode 100644 (file)
index 0000000..b619095
--- /dev/null
@@ -0,0 +1,5 @@
+/* ust/config.h.in. Manually generated for control over the contained defs. */
+
+/* Use efficient unaligned access. */
+#undef HAVE_EFFICIENT_UNALIGNED_ACCESS
+
index e781a3a6c5542e85f98898ee8beb3314be8869a8..d0e2750f1fab74253c9f2bcd2c843ccf7943241c 100644 (file)
 #define UST_CORE_H
 
 #include <sys/types.h>
+#include <ust/config.h>
 
 #define likely(x)      __builtin_expect(!!(x), 1)
 #define unlikely(x)    __builtin_expect(!!(x), 0)
 
-#if defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT)
+#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
 
 /*
  * Calculate the offset needed to align the type.
@@ -42,7 +43,7 @@ static inline int ltt_get_alignment(void)
        return sizeof(void *);
 }
 
-#else
+#else /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
 
 static inline unsigned int ltt_align(size_t align_drift,
                 size_t size_of_type)
@@ -56,7 +57,7 @@ static inline int ltt_get_alignment(void)
 {
        return 0;
 }
-#endif /* defined(CONFIG_LTT) && defined(CONFIG_LTT_ALIGNMENT) */
+#endif /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
 
 
 /* ARRAYS */
This page took 0.025577 seconds and 4 git commands to generate.