#include "curproc.h"
#ifndef offsetof
-# define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb)))
+# define offsetof(typ,memb) ((long)(long_ptr_t)((char *)&(((typ *)0)->memb)))
#endif
-/* cardinality of array */
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) ((sizeof (a)) / (sizeof ((a)[0])))
#endif
/* given a pointer @ptr to the field @member embedded into type (usually
* struct) @type, return pointer to the embedding instance of @type. */
#define container_of(ptr, type, member) \
- ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+ ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
#endif
-#define container_of0(ptr, type, member) \
-({ \
- typeof(ptr) __ptr = (ptr); \
- type *__res; \
- \
- if (unlikely(IS_ERR(__ptr) || __ptr == NULL)) \
- __res = (type *)__ptr; \
- else \
- __res = container_of(__ptr, type, member); \
- __res; \
-})
+static inline int __is_po2(unsigned long long val)
+{
+ return !(val & (val - 1));
+}
-/*
- * true iff @i is power-of-2
- */
-#define IS_PO2(i) \
-({ \
- typeof(i) __i; \
- \
- __i = (i); \
- !(__i & (__i - 1)); \
-})
+#define IS_PO2(val) __is_po2((unsigned long long)(val))
#define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
-
/*
* Lustre Error Checksum: calculates checksum
* of Hex number by XORing each bit.
#include <libcfs/list.h>
+/* for_each_possible_cpu is defined newly, the former is
+ * for_each_cpu(eg. sles9 and sles10) b=15878 */
+#ifndef for_each_possible_cpu
+# ifdef for_each_cpu
+# define for_each_possible_cpu(cpu) for_each_cpu(cpu)
+# else
+# error for_each_possible_cpu is not supported by kernel!
+# endif
+#endif
+
/* libcfs tcpip */
int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
int libcfs_ipif_enumerate(char ***names);
void *data);
/* Enables a watchdog and resets its timer. */
-void lc_watchdog_touch_ms(struct lc_watchdog *lcw, int timeout_ms);
-void lc_watchdog_touch(struct lc_watchdog *lcw);
+void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout);
+#define GET_TIMEOUT(svc) (max_t(int, obd_timeout, \
+ AT_OFF ? 0 : at_get(&svc->srv_at_estimate)) * \
+ svc->srv_watchdog_factor)
/* Disable a watchdog; touch it to restart it. */
void lc_watchdog_disable(struct lc_watchdog *lcw);
* struct cfs_psdev_t and
* cfs_psdev_register() and
* cfs_psdev_deregister() are declared in
- * libcfs/<os>/cfs_prim.h
+ * libcfs/<os>/<os>-prim.h
*
* It's just draft now.
*/
#include <libcfs/libcfs_ioctl.h>
#include <libcfs/libcfs_prim.h>
#include <libcfs/libcfs_time.h>
+#include <libcfs/libcfs_string.h>
+#include <libcfs/libcfs_kernelcomm.h>
+#include <libcfs/libcfs_hash.h>
+
+/* container_of depends on "likely" which is defined in libcfs_private.h */
+static inline void *__container_of(void *ptr, unsigned long shift)
+{
+ if (unlikely(IS_ERR(ptr) || ptr == NULL))
+ return ptr;
+ else
+ return (char *)ptr - shift;
+}
+
+#define container_of0(ptr, type, member) \
+ ((type *)__container_of((void *)(ptr), offsetof(type, member)))
#define _LIBCFS_H