1 /*****************************************************************************
4 * This file holds the code needed by LTT usertrace that comes from the
5 * kernel headers. Since including kernel headers is not recommended in
6 * userspace programs/libraries, we rewrote implementations HIGHLY INSPIRED
7 * (i.e. copied/pasted) from the original kernel headers (2.6.18).
9 * Do not use these functions within signal handlers, as the architecture offers
10 * no atomic operations. (Mathieu Desnoyers) It is safe to do multithreaded
11 * tracing though, as the buffers are per thread.
13 * Deepak Saxena, October 2006
16 #ifndef _KERNELUTILS_ARM_H
17 #define _KERNELUTILS_ARM_H
25 typedef struct { volatile int counter
; } atomic_t
;
27 #define atomic_read(v) ((v)->counter)
29 static inline int atomic_add_return(int i
, atomic_t
*v
)
35 v
->counter
= val
+= i
;
40 #define atomic_add(i, v) (void) atomic_add_return(i, v)
41 #define atomic_inc(v) (void) atomic_add_return(1, v)
43 static inline unsigned long cmpxchg(volatile void *ptr
,
47 unsigned long flags
, prev
;
48 volatile unsigned long *p
= ptr
;
50 if ((prev
= *p
) == old
)
55 static inline unsigned long long get_cycles(void)
58 clock_gettime(CLOCK_MONOTONIC
, &tp
);
59 return tp
.tv_sec
* 1000000000 + tp
.tv_nsec
;
64 } /* end of extern "C" */
This page took 0.029568 seconds and 4 git commands to generate.