From: compudj Date: Tue, 31 Oct 2006 20:49:43 +0000 (+0000) Subject: update usertrace X-Git-Tag: v0.12.20~1265 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=5f31354b2a7d42819fcb4bb25fd8ba7e138dd37a;p=lttv.git update usertrace git-svn-id: http://ltt.polymtl.ca/svn@2224 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt-usertrace/ltt/kernelutils-arm.h b/ltt-usertrace/ltt/kernelutils-arm.h new file mode 100644 index 00000000..dce42ef5 --- /dev/null +++ b/ltt-usertrace/ltt/kernelutils-arm.h @@ -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 + +#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