ust: fix several segfaults, now seems to trace without errors
[ust.git] / share / kernelcompat.h
index c5512b8d4c848f4c35ee91c8cc23c9e4f080b3f6..b442718e2af19a7e611aa36d03f04118834f6ab8 100644 (file)
@@ -63,6 +63,7 @@ typedef uint64_t u64;
 #include <pthread.h>
 
 #define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
+#define DECLARE_MUTEX(m) extern pthread_mutex_t (m);
 
 #define mutex_lock(m) pthread_mutex_lock(m)
 
@@ -82,10 +83,12 @@ typedef int spinlock_t;
 #include <stdlib.h>
 
 #define kmalloc(s, t) malloc(s)
-#define kzalloc(s, t) malloc(s)
+#define kzalloc(s, t) zmalloc(s)
 #define kfree(p) free((void *)p)
 #define kstrdup(s, t) strdup(s)
 
+#define zmalloc(s) calloc(1, s)
+
 #define GFP_KERNEL
 
 /* PRINTK */
@@ -108,6 +111,8 @@ typedef int spinlock_t;
 #define rcu_assign_pointer(a, b) do {} while(0)
 #define call_rcu_sched(a,b) do {} while(0)
 #define rcu_barrier_sched() do {} while(0)
+#define rcu_read_lock_sched_notrace() do{} while (0)
+#define rcu_read_unlock_sched_notrace() do{} while (0)
 
 /* ATOMICITY */
 
@@ -181,37 +186,44 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
        return old;
 }
 
-#define local_cmpxchg cmpxchg
+//#define local_cmpxchg cmpxchg
+#define local_cmpxchg(l, o, n) (cmpxchg(&((l)->a.counter), (o), (n)))
+
 #define atomic_long_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
 
 
 /* LOCAL OPS */
 
-typedef int local_t;
+//typedef int local_t;
+typedef struct
+{
+       atomic_long_t a;
+} local_t;
 
-static inline void local_inc(local_t *a)
+
+static inline void local_inc(local_t *l)
 {
-       (*a)++;
+       (l->a.counter)++;
 }
 
-static inline void local_set(local_t *a, int v)
+static inline void local_set(local_t *l, int v)
 {
-       *a = v;
+       l->a.counter = v;
 }
 
-static inline void local_add(int v, local_t *a)
+static inline void local_add(int v, local_t *l)
 {
-       *a += v;
+       l->a.counter += v;
 }
 
-static int local_add_return(int v, local_t *a)
+static int local_add_return(int v, local_t *l)
 {
-       return *a += v;
+       return l->a.counter += v;
 }
 
-static inline int local_read(local_t *a)
+static inline int local_read(local_t *l)
 {
-       return *a;
+       return l->a.counter;
 }
 
 
@@ -302,4 +314,6 @@ static inline u32 trace_clock_freq_scale(void)
 
 #define EXPORT_SYMBOL_GPL(a) /*nothing*/
 
+#define smp_processor_id() (-1)
+
 #endif /* KERNELCOMPAT_H */
This page took 0.023751 seconds and 4 git commands to generate.