summaryrefslogtreecommitdiff
path: root/kerncompat.h
diff options
context:
space:
mode:
authorYan <yanzheng@21cn.com>2008-01-04 10:38:22 -0500
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-01-04 10:38:22 -0500
commit7777e63b425f1444d2472ea05a6b2b9cf865f35b (patch)
tree257d9645b094cd3bae9051f7bb5b24d862764bf4 /kerncompat.h
parent088f78aeaadac6cc877975c6974731968c0093d1 (diff)
Update btrfs-progs to match kernel sources
Diffstat (limited to 'kerncompat.h')
-rw-r--r--kerncompat.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/kerncompat.h b/kerncompat.h
index 18f508f3..8536832d 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -67,10 +67,36 @@ struct vm_area_struct {
unsigned long vm_end;
struct vma_shared shared;
};
+
struct page {
unsigned long index;
};
+struct mutex {
+ unsigned long lock;
+};
+
+#define mutex_init(m) \
+do { \
+ (m)->lock = 1; \
+} while (0)
+
+static inline void mutex_lock(struct mutex *m)
+{
+ m->lock--;
+}
+
+static inline void mutex_unlock(struct mutex *m)
+{
+ m->lock++;
+}
+
+static inline int mutex_is_locked(struct mutex *m)
+{
+ return (m->lock != 1);
+}
+
+#define cond_resched() do { } while (0)
#define preempt_enable() do { } while (0)
#define preempt_disable() do { } while (0)
@@ -112,7 +138,61 @@ static inline int test_bit(int nr, const volatile unsigned long *addr)
return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
}
+/*
+ * error pointer
+ */
+#define MAX_ERRNO 4095
+#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
+
+static inline void *ERR_PTR(long error)
+{
+ return (void *) error;
+}
+
+static inline long PTR_ERR(const void *ptr)
+{
+ return (long) ptr;
+}
+
+static inline long IS_ERR(const void *ptr)
+{
+ return IS_ERR_VALUE((unsigned long)ptr);
+}
+
+/*
+ * max/min macro
+ */
+#define min(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x < _y ? _x : _y; })
+
+#define max(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x > _y ? _x : _y; })
+
+#define min_t(type,x,y) \
+ ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
+#define max_t(type,x,y) \
+ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
+
+/*
+ * printk
+ */
+#define printk(fmt, args...) fprintf(stderr, fmt, ##args)
+#define KERN_CRIT ""
+
+/*
+ * kmalloc/kfree
+ */
+#define kmalloc(x, y) malloc(x)
+#define kfree(x) free(x)
+
#define BUG_ON(c) do { if (c) abort(); } while (0)
+#define WARN_ON(c) do { if (c) abort(); } while (0)
#undef offsetof
#ifdef __compiler_offsetof
@@ -162,3 +242,7 @@ typedef u64 __bitwise __be64;
#define le16_to_cpu(x) ((__force u16)(__le16)(x))
#endif
#endif
+
+#ifndef noinline
+#define noinline
+#endif