Whamcloud - gitweb
Branch b1_4
[fs/lustre-release.git] / lnet / include / libcfs / linux / kp30.h
index be2cd34..fb1ae3e 100644 (file)
@@ -9,7 +9,7 @@
 #endif
 
 #ifdef __KERNEL__
-#ifdef HAVE_KERNEL_CONFIG_H
+#ifndef AUTOCONF_INCLUDED
 # include <linux/config.h>
 #endif
 # include <linux/kernel.h>
@@ -68,14 +68,30 @@ static inline void our_cond_resched(void)
         if (current->need_resched)
                schedule ();
 }
-#define work_struct_t       struct tq_struct
-
+#define work_struct_t                   struct tq_struct
+#define cfs_get_work_data(type,field,data)   (data)
 #else
 
+#ifdef HAVE_3ARGS_INIT_WORK
+
 #define prepare_work(wq,cb,cbdata)                                            \
 do {                                                                          \
         INIT_WORK((wq), (void *)(cb), (void *)(cbdata));                      \
 } while (0)
+
+#define cfs_get_work_data(type,field,data)   (data)
+
+#else
+
+#define prepare_work(wq,cb,cbdata)                                            \
+do {                                                                          \
+        INIT_WORK((wq), (void *)(cb));                                        \
+} while (0)
+
+#define cfs_get_work_data(type,field,data) container_of(data,type,field)
+
+#endif
+
 #define wait_on_page wait_on_page_locked
 #define our_recalc_sigpending(current) recalc_sigpending()
 #define strtok(a,b) strpbrk(a, b)
@@ -157,6 +173,13 @@ static inline void our_cond_resched(void)
 # define printf(format, b...) CDEBUG(D_OTHER, format , ## b)
 # define time(a) CURRENT_TIME
 
+#ifndef num_possible_cpus
+#define num_possible_cpus() NR_CPUS
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#define i_size_read(a) ((a)->i_size)
+#endif
+
 #else  /* !__KERNEL__ */
 # include <stdio.h>
 # include <stdlib.h>
@@ -309,7 +332,15 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 # define LP_POISON ((void *)(long)0x5a5a5a5a)
 #endif
 
-#if (defined(__x86_64__) && defined(__KERNEL__))
+/* this is a bit chunky */
+
+#if defined(__KERNEL__)
+ #define _LWORDSIZE BITS_PER_LONG
+#else
+ #define _LWORDSIZE __WORDSIZE
+#endif
+
+#if (defined(__x86_64__) && (defined(__KERNEL__) || defined(CRAY_XT3)))
 /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
@@ -317,14 +348,14 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 # define LPF64 "L"
 # define LPSZ  "%lu"
 # define LPSSZ "%ld"
-#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
+#elif (_LWORDSIZE == 32)
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
 # define LPF64 "L"
 # define LPSZ  "%u"
 # define LPSSZ "%d"
-#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
+#elif (_LWORDSIZE == 64)
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
@@ -336,4 +367,6 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 # error "No word size defined"
 #endif
 
+#undef _LWORDSIZE
+
 #endif