Whamcloud - gitweb
b=20339
[fs/lustre-release.git] / libcfs / include / libcfs / linux / kp30.h
index 2f9ef67..ae23e8c 100644 (file)
@@ -16,8 +16,8 @@
  * in the LICENSE file that accompanied this code).
  *
  * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
@@ -76,6 +76,7 @@
 # include <linux/kallsyms.h>
 # include <linux/moduleparam.h>
 #endif
+#include <linux/scatterlist.h>
 
 #include <libcfs/linux/portals_compat25.h>
 
@@ -132,11 +133,19 @@ static inline void our_cond_resched(void)
 
 #ifdef CONFIG_SMP
 #define LASSERT_SPIN_LOCKED(lock) LASSERT(spin_is_locked(lock))
+#define LINVRNT_SPIN_LOCKED(lock) LINVRNT(spin_is_locked(lock))
 #else
-#define LASSERT_SPIN_LOCKED(lock) do {} while(0)
+#define LASSERT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0)
+#define LINVRNT_SPIN_LOCKED(lock) do {(void)sizeof(lock);} while(0)
 #endif
 #define LASSERT_SEM_LOCKED(sem) LASSERT(down_trylock(sem) != 0)
 
+#ifdef HAVE_SEM_COUNT_ATOMIC
+#define SEM_COUNT(sem)          (atomic_read(&(sem)->count))
+#else
+#define SEM_COUNT(sem)          ((sem)->count)
+#endif
+
 #define LIBCFS_PANIC(msg)            panic(msg)
 
 /* ------------------------------------------------------------------- */
@@ -342,7 +351,8 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 
 #define _LWORDSIZE BITS_PER_LONG
 
-#if defined(HAVE_U64_LONG_LONG)
+#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
+    (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
@@ -354,6 +364,18 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 # define LPF64 "l"
 #endif
 
+/*
+ * long_ptr_t & ulong_ptr_t, same to "long" for gcc
+ */
+# define LPLU "%lu"
+# define LPLD "%ld"
+# define LPLX "%#lx"
+
+/*
+ * pid_t
+ */
+# define LPPID "%d"
+
 #ifdef HAVE_SIZE_T_LONG
 # define LPSZ  "%lu"
 #else
@@ -372,4 +394,28 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 
 #undef _LWORDSIZE
 
+/* compat macroses */
+#ifndef HAVE_SCATTERLIST_SETPAGE
+static inline void sg_set_page(struct scatterlist *sg, struct page *page,
+                               unsigned int len, unsigned int offset)
+{
+        sg->page = page;
+        sg->offset = offset;
+        sg->length = len;
+}
+#endif
+
+#ifndef get_cpu
+# ifdef CONFIG_PREEMPT
+#  define cfs_get_cpu()  ({ preempt_disable(); smp_processor_id(); })
+#  define cfs_put_cpu()  preempt_enable()
+# else
+#  define cfs_get_cpu()  smp_processor_id()
+#  define cfs_put_cpu()
+# endif
+#else
+# define cfs_get_cpu()   get_cpu()
+# define cfs_put_cpu()   put_cpu()
+#endif /* get_cpu & put_cpu */
+
 #endif