update usertrace
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 31 Oct 2006 20:49:43 +0000 (20:49 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 31 Oct 2006 20:49:43 +0000 (20:49 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2224 04897980-b3bd-0310-b5e0-8ef037075253

ltt-usertrace/ltt/kernelutils-arm.h [new file with mode: 0644]

diff --git a/ltt-usertrace/ltt/kernelutils-arm.h b/ltt-usertrace/ltt/kernelutils-arm.h
new file mode 100644 (file)
index 0000000..dce42ef
--- /dev/null
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * kernelutils-arm.h
+ *
+ * This file holds the code needed by LTT usertrace that comes from the
+ * kernel headers.  Since including kernel headers is not recommended in
+ * userspace programs/libraries, we rewrote implementations HIGHLY INSPIRED
+ * (i.e. copied/pasted) from the original kernel headers (2.6.18).
+ *
+ * Do not use these functions within signal handlers, as the architecture offers
+ * no atomic operations. (Mathieu Desnoyers) It is safe to do multithreaded
+ * tracing though, as the buffers are per thread.
+ *
+ * Deepak Saxena, October 2006
+ */
+
+#ifndef _KERNELUTILS_ARM_H
+#define _KERNELUTILS_ARM_H
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define atomic_read(v) ((v)->counter)
+
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+       unsigned long flags;
+       int val;
+
+       val = v->counter;
+       v->counter = val += i;
+
+       return val;
+}
+
+#define atomic_add(i, v)       (void) atomic_add_return(i, v)
+#define atomic_inc(v)          (void) atomic_add_return(1, v)
+
+static inline unsigned long cmpxchg(volatile void *ptr,
+                                   unsigned long old,
+                                   unsigned long new)
+{
+       unsigned long flags, prev;
+       volatile unsigned long *p = ptr;
+
+       if ((prev = *p) == old)
+               *p = new;
+       return(prev);
+}
+
+static inline unsigned long long get_cycles(void)
+{
+       struct timespec tp;
+       clock_gettime(CLOCK_MONOTONIC, &tp);    
+       return tp.tv_sec * 1000000000 + tp.tv_nsec;
+}
+
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
+
+#endif
This page took 0.025701 seconds and 4 git commands to generate.