From: Pierre-Marc Fournier Date: Sat, 7 Feb 2009 17:55:46 +0000 (-0500) Subject: ust: add usterr.h X-Git-Tag: v0.1~305 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c9b64079ec044b3004b9db71ebf9b263f7af3e97;p=ust.git ust: add usterr.h --- diff --git a/libmarkers/kernelcompat.h b/libmarkers/kernelcompat.h deleted file mode 100644 index b6615ee..0000000 --- a/libmarkers/kernelcompat.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef KERNELCOMPAT_H -#define KERNELCOMPAT_H - -#include - -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - -#define KERN_DEBUG -#define KERN_NOTICE - -static inline void *ERR_PTR(long error) -{ - return (void *) error; -} - - -#include - -typedef uint16_t u16; -typedef uint32_t u32; - - -#include - -#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER; - -#define mutex_lock(m) pthread_mutex_lock(m) - -#define mutex_unlock(m) pthread_mutex_unlock(m) - - -#include - -#define kmalloc(s, t) malloc(s) -#define kzalloc(s, t) malloc(s) -#define kfree(p) free((void *)p) -#define kstrdup(s, t) strdup(s) - - -#include -#define printk(fmt, args...) printf(fmt, ## args) - - - -#define smp_rmb() -#define smp_wmb() - - -#define read_barrier_depends() -#define smp_read_barrier_depends() - - -#define rcu_assign_pointer(a, b) -#endif /* KERNELCOMPAT_H */ diff --git a/share/kernelcompat.h b/share/kernelcompat.h new file mode 100644 index 0000000..b6615ee --- /dev/null +++ b/share/kernelcompat.h @@ -0,0 +1,56 @@ +#ifndef KERNELCOMPAT_H +#define KERNELCOMPAT_H + +#include + +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + +#define KERN_DEBUG +#define KERN_NOTICE + +static inline void *ERR_PTR(long error) +{ + return (void *) error; +} + + +#include + +typedef uint16_t u16; +typedef uint32_t u32; + + +#include + +#define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER; + +#define mutex_lock(m) pthread_mutex_lock(m) + +#define mutex_unlock(m) pthread_mutex_unlock(m) + + +#include + +#define kmalloc(s, t) malloc(s) +#define kzalloc(s, t) malloc(s) +#define kfree(p) free((void *)p) +#define kstrdup(s, t) strdup(s) + + +#include +#define printk(fmt, args...) printf(fmt, ## args) + + + +#define smp_rmb() +#define smp_wmb() + + +#define read_barrier_depends() +#define smp_read_barrier_depends() + + +#define rcu_assign_pointer(a, b) +#endif /* KERNELCOMPAT_H */ diff --git a/share/usterr.h b/share/usterr.h new file mode 100644 index 0000000..6b871ff --- /dev/null +++ b/share/usterr.h @@ -0,0 +1,8 @@ +#define DBG(fmt, args...) fprintf(stderr, fmt "\n", ## args) +#define WARN(fmt, args...) fprintf(stderr, "usertrace: WARNING: " fmt "\n", ## args) +#define ERR(fmt, args...) fprintf(stderr, "usertrace: ERROR: " fmt "\n", ## args) +#define PERROR(call) perror("usertrace: ERROR: " call) + +#define BUG_ON(condition) do { if (unlikely(condition)) ERR("condition not respected (BUG)"); } while(0) +#define WARN_ON(condition) do { if (unlikely(condition)) WARN("condition not respected"); } while(0) +