#endif
#ifdef __KERNEL__
-#ifdef HAVE_KERNEL_CONFIG_H
+#ifndef AUTOCONF_INCLUDED
# include <linux/config.h>
#endif
# include <linux/kernel.h>
# include <linux/kmod.h>
# include <linux/notifier.h>
# include <linux/fs.h>
-# include <asm/segment.h>
# include <linux/miscdevice.h>
# include <linux/vmalloc.h>
# include <linux/time.h>
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)
# 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>
-#ifdef CRAY_XT3
-# include <ioctl.h>
-#elif defined(__CYGWIN__)
+#if defined(__CYGWIN__)
# include <cygwin-ioctl.h>
#else
# include <stdint.h>
# include <limits.h>
# include <errno.h>
# include <sys/ioctl.h> /* for _IOWR */
+#ifndef _IOWR
+#include "ioctl.h"
+#endif
# define CFS_MODULE_PARM(name, t, type, perm, desc)
#define PORTAL_SYMBOL_GET(x) inter_module_get(#x)
# 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))) || defined(HAVE_U64_LONG_LONG)
/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
# define LPU64 "%Lu"
# define LPD64 "%Ld"
# 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"
# error "No word size defined"
#endif
+#undef _LWORDSIZE
+
#endif