[AC_DEFINE(HAVE_KOBJ_NS_DROP_EXPORTED, 1,
[kobj_ns_drop is exported by the kernel])],
[])
+
+ AC_MSG_CHECKING([if linux/hashtable.h exists])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/hashtable.h>
+ ],[
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_LINUX_HASHTABLE_H, 1,
+ [linux/hashtable.h exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if list.h hlist_for_each_entry has 3 params])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/list.h>
+
+ struct test_node {
+ struct hlist_node hlist;
+ };
+ ],[
+ struct test_node *hn;
+ struct hlist_head *hash;
+ hlist_for_each_entry(hn, hash, hlist);
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_HLIST_FOR_EACH_ENTRY_3_PARAMS, 1,
+ [hlist_for_each_entry has 3 params])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ # this checker will test if the function exist AND gets const
+ # otherwise it will fail.
+ AC_MSG_CHECKING([if if_vlan.h has is_vlan_dev get const])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/netdevice.h>
+ #include <linux/if_vlan.h>
+ ],[
+ const struct net_device *dev;
+ is_vlan_dev(dev);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_IS_VLAN_DEV_CONST, 1,
+ [is_vlan_dev get const])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if linux/security.h has register_lsm_notifier])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/security.h>
+ ],[
+ register_lsm_notifier(NULL);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_REGISTER_LSM_NOTIFIER, 1,
+ [linux/security.h has register_lsm_notifier])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if refcount.h exists])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/refcount.h>
+ ],[
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_REFCOUNT, 1,
+ [refcount.h exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if slab.h has kcalloc_node])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/slab.h>
+ ],[
+ kcalloc_node(0, 0, 0, 0);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KCALLOC_NODE, 1,
+ [kcalloc_node is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if mm.h has kvzalloc])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+ ],[
+ kvzalloc(0, 0);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KVZALLOC, 1,
+ [kvzalloc is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if mm.h has kvmalloc_array])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+ ],[
+ kvmalloc_array(0, 0, 0);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KVMALLOC_ARRAY, 1,
+ [kvmalloc_array is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if mm.h has kvmalloc_node])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+ ],[
+ kvmalloc_node(0, 0, 0);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KVMALLOC_NODE, 1,
+ [kvmalloc_node is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if mm.h has kvzalloc_node])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+ ],[
+ kvzalloc_node(0, 0, 0);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KVZALLOC_NODE, 1,
+ [kvzalloc_node is defined])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if linux/cdev.h has cdev_set_parent])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/cdev.h>
+ ],[
+ cdev_set_parent(NULL, NULL);
+
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_CDEV_SET_PARENT, 1,
+ [linux/cdev.h has cdev_set_parent])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if linux/sched/signal.h exists])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/sched/signal.h>
+ ],[
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SCHED_SIGNAL_H, 1,
+ [linux/sched/signal.h exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+
+ AC_MSG_CHECKING([if linux/sched/mm.h exists])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/sched/mm.h>
+ ],[
+ return 0;
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SCHED_MM_H, 1,
+ [linux/sched/mm.h exists])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
])
#
# COMPAT_CONFIG_HEADERS
--- /dev/null
+#ifndef COMPAT_CDEV_H
+#define COMPAT_CDEV_H
+
+#include "../../compat/config.h"
+
+#include_next <linux/cdev.h>
+
+#ifndef HAVE_CDEV_SET_PARENT
+#include <linux/device.h>
+
+#define cdev_set_parent LINUX_BACKPORT(cdev_set_parent)
+static inline void cdev_set_parent(struct cdev *p, struct kobject *kobj)
+{
+ WARN_ON(!kobj->state_initialized);
+ p->kobj.parent = kobj;
+}
+
+#define cdev_device_add LINUX_BACKPORT(cdev_device_add)
+static inline int cdev_device_add(struct cdev *cdev, struct device *dev)
+{
+ int rc = 0;
+
+ if (dev->devt) {
+ cdev_set_parent(cdev, &dev->kobj);
+
+ rc = cdev_add(cdev, dev->devt, 1);
+ if (rc)
+ return rc;
+ }
+
+ rc = device_add(dev);
+ if (rc)
+ cdev_del(cdev);
+
+ return rc;
+}
+
+#define cdev_device_del LINUX_BACKPORT(cdev_device_del)
+static inline void cdev_device_del(struct cdev *cdev, struct device *dev)
+{
+ device_del(dev);
+ if (dev->devt)
+ cdev_del(cdev);
+}
+
+#endif /* HAVE_CDEV_SET_PARENT */
+
+#endif /* COMPAT_CDEV_H */
--- /dev/null
+#ifndef COMPAT_LINUX_HASHTABLE_H
+#define COMPAT_LINUX_HASHTABLE_H
+
+#include "../../compat/config.h"
+
+#ifdef HAVE_LINUX_HASHTABLE_H
+#include_next <linux/hashtable.h>
+#endif
+
+#ifndef DECLARE_HASHTABLE
+#include <linux/types.h>
+#define DECLARE_HASHTABLE(name, bits) \
+ struct hlist_head name[1 << (bits)]
+#endif
+
+#ifndef hash_init
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/hash.h>
+
+#define HASH_SIZE(name) (ARRAY_SIZE(name))
+static inline void __hash_init(struct hlist_head *ht, unsigned int sz)
+{
+ unsigned int i;
+
+ for (i = 0; i < sz; i++)
+ INIT_HLIST_HEAD(&ht[i]);
+}
+
+/**
+ * hash_init - initialize a hash table
+ * @hashtable: hashtable to be initialized
+ *
+ * Calculates the size of the hashtable from the given parameter, otherwise
+ * same as hash_init_size.
+ *
+ * This has to be a macro since HASH_BITS() will not work on pointers since
+ * it calculates the size during preprocessing.
+ */
+#define hash_init(hashtable) __hash_init(hashtable, HASH_SIZE(hashtable))
+
+#define HASH_SIZE(name) (ARRAY_SIZE(name))
+#define HASH_BITS(name) ilog2(HASH_SIZE(name))
+/* Use hash_32 when possible to allow for fast 32bit hashing in 64bit kernels. */
+#define hash_min(val, bits) \
+ (sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits))
+
+#define hash_for_each_possible(name, obj, node, member, key) \
+ hlist_for_each_entry(obj, node, &name[hash_min(key, HASH_BITS(name))], member)
+
+/**
+ * hash_add - add an object to a hashtable
+ * @hashtable: hashtable to add to
+ * @node: the &struct hlist_node of the object to be added
+ * @key: the key of the object to be added
+ */
+#define hash_add(hashtable, node, key) \
+ hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
+
+static inline bool __hash_empty(struct hlist_head *ht, unsigned int sz)
+{
+ unsigned int i;
+
+ for (i = 0; i < sz; i++)
+ if (!hlist_empty(&ht[i]))
+ return false;
+
+ return true;
+}
+
+/**
+ * hash_empty - check whether a hashtable is empty
+ * @hashtable: hashtable to check
+ *
+ * This has to be a macro since HASH_BITS() will not work on pointers since
+ * it calculates the size during preprocessing.
+ */
+#define hash_empty(hashtable) __hash_empty(hashtable, HASH_SIZE(hashtable))
+
+/**
+ * hash_del - remove an object from a hashtable
+ * @node: &struct hlist_node of the object to remove
+ */
+static inline void hash_del(struct hlist_node *node)
+{
+ hlist_del_init(node);
+}
+
+#endif /* hash_init */
+
+#endif /* COMPAT_LINUX_HASHTABLE_H */
--- /dev/null
+#ifndef COMPAT_LIST_H
+#define COMPAT_LIST_H
+
+#include_next <linux/list.h>
+
+/* Include the autogenerated header file */
+#include "../../compat/config.h"
+
+#ifdef HAVE_HLIST_FOR_EACH_ENTRY_3_PARAMS
+#define compat_hlist_for_each_entry_safe(pos, n, head, member) \
+ hlist_for_each_entry_safe(pos, n, head, member)
+
+#define compat_hlist_for_each_entry(pos, head, member) \
+ hlist_for_each_entry(pos, head, member)
+
+#define COMPAT_HL_NODE
+#else
+#define compat_hlist_for_each_entry_safe(pos, n, head, member) \
+ hlist_for_each_entry_safe(pos, hlnode, n, head, member)
+
+#define compat_hlist_for_each_entry(pos, head, member) \
+ hlist_for_each_entry(pos, hlnode, head, member) \
+
+#define COMPAT_HL_NODE struct hlist_node *hlnode;
+#endif
+
+#ifndef list_prev_entry
+#define list_prev_entry(pos, member) \
+ list_entry((pos)->member.prev, typeof(*(pos)), member)
+#endif
+
+#ifndef list_next_entry
+#define list_next_entry(pos, member) \
+ list_entry((pos)->member.next, typeof(*(pos)), member)
+#endif
+
+#ifndef list_first_entry_or_null
+#define list_first_entry_or_null(ptr, type, member) \
+ (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
+#endif
+#endif /* COMPAT_LIST_H */
--- /dev/null
+#ifndef _COMPAT_LINUX_MM_H
+#define _COMPAT_LINUX_MM_H
+
+#include "../../compat/config.h"
+
+#include_next <linux/mm.h>
+
+#ifndef HAVE_KVZALLOC
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+
+static inline void *kvzalloc(unsigned long size,...) {
+ void *rtn;
+
+ rtn = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
+ if (!rtn)
+ rtn = vzalloc(size);
+ return rtn;
+}
+#endif
+
+#ifndef HAVE_KVMALLOC_ARRAY
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+
+static inline void *kvmalloc_array(size_t n, size_t size,...) {
+ void *rtn;
+
+ rtn = kcalloc(n, size, GFP_KERNEL | __GFP_NOWARN);
+ if (!rtn)
+ rtn = vzalloc(n * size);
+ return rtn;
+}
+#endif
+
+#ifndef HAVE_KVMALLOC_NODE
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+
+static inline void *kvmalloc_node(size_t size, gfp_t flags, int node) {
+ void *rtn;
+
+ rtn = kmalloc_node(size, GFP_KERNEL | __GFP_NOWARN, node);
+ if (!rtn)
+ rtn = vmalloc(size);
+ return rtn;
+}
+#endif
+
+#ifndef HAVE_KVZALLOC_NODE
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+
+static inline void *kvzalloc_node(size_t size, gfp_t flags, int node)
+{
+ void *p = kvmalloc_node(size, flags, node);
+ if (p)
+ memset(p, 0, size);
+ return p;
+}
+#endif
+
+#endif /* _COMPAT_LINUX_MM_H */
--- /dev/null
+#ifndef _MLNX_LINUX_REFCOUNT_H
+#define _MLNX_LINUX_REFCOUNT_H
+
+#include "../../compat/config.h"
+
+#ifdef HAVE_REFCOUNT
+#include_next <linux/refcount.h>
+#else /* HAVE_REFCOUNT */
+
+/* simply map back to atomic interface */
+
+#include <linux/atomic.h>
+
+#define refcount_t atomic_t
+#define refcount_set atomic_set
+#define refcount_inc atomic_inc
+#define refcount_dec atomic_dec
+#define refcount_read atomic_read
+#define refcount_inc_not_zero atomic_inc_not_zero
+#define refcount_dec_and_test atomic_dec_and_test
+
+#endif /* HAVE_REFCOUNT */
+
+
+#endif /* _MLNX_LINUX_REFCOUNT_H */
--- /dev/null
+#ifndef COMPAT_LINUX_SCHED_MM_H
+#define COMPAT_LINUX_SCHED_MM_H
+
+#include "../../../compat/config.h"
+
+#ifdef HAVE_SCHED_MM_H
+#include_next <linux/sched/mm.h>
+#endif
+
+#endif /* COMPAT_LINUX_SCHED_MM_H */
--- /dev/null
+#ifndef COMPAT_LINUX_SCHED_SIGNAL_H
+#define COMPAT_LINUX_SCHED_SIGNAL_H
+
+#include "../../../compat/config.h"
+
+#ifdef HAVE_SCHED_SIGNAL_H
+#include_next <linux/sched/signal.h>
+#endif
+
+#endif /* COMPAT_LINUX_SCHED_SIGNAL_H */