1 #ifndef LINUX_3_1_COMPAT_H
2 #define LINUX_3_1_COMPAT_H
4 #include <linux/version.h>
6 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
8 #include <linux/security.h>
9 #include <linux/skbuff.h>
11 #include <linux/idr.h>
14 #ifndef CONFIG_COMPAT_SLES_11_3
15 static inline struct neighbour *dst_get_neighbour(struct dst_entry *dst)
17 return dst->neighbour;
20 static inline void dst_set_neighbour(struct dst_entry *dst, struct neighbour *neigh)
22 dst->neighbour = neigh;
25 static inline struct neighbour *dst_get_neighbour_raw(struct dst_entry *dst)
27 return rcu_dereference_raw(dst->neighbour);
29 #endif /* CONFIG_COMPAT_SLES_11_3 */
31 /* Backports 56f8a75c */
32 static inline bool ip_is_fragment(const struct iphdr *iph)
34 return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0;
37 /* mask __netdev_alloc_skb_ip_align as RHEL6.3 backports it */
38 #define __netdev_alloc_skb_ip_align(a, b, c) compat__netdev_alloc_skb_ip_align(a, b, c)
40 static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev,
41 unsigned int length, gfp_t gfp)
43 struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp);
45 if (NET_IP_ALIGN && skb)
46 skb_reserve(skb, NET_IP_ALIGN);
50 #ifndef NEED_MIN_DUMP_ALLOC_ARG
51 #include <linux/netlink.h>
53 #define netlink_dump_start(a, b, c, d, e, f) netlink_dump_start(a, b, c, d, e)
57 * Getting something that works in C and CPP for an arg that may or may
58 * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1"
59 * we match on the placeholder define, insert the "0," for arg1 and generate
60 * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one).
61 * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
62 * the last step cherry picks the 2nd arg, we get a zero.
64 #define __ARG_PLACEHOLDER_1 0,
65 #define config_enabled(cfg) _config_enabled(cfg)
66 #define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
67 #define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
68 #define ___config_enabled(__ignored, val, ...) val
69 #define genl_dump_check_consistent(cb, user_hdr, family)
72 * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
76 #define IS_ENABLED(option) \
77 (config_enabled(option) || config_enabled(option##_MODULE))
79 #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing
82 #define PCMCIA_DEVICE_MANF_CARD_PROD_ID3(manf, card, v3, vh3) { \
83 .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \
84 PCMCIA_DEV_ID_MATCH_CARD_ID| \
85 PCMCIA_DEV_ID_MATCH_PROD_ID3, \
88 .prod_id = { NULL, NULL, (v3), NULL }, \
89 .prod_id_hash = { 0, 0, (vh3), 0 }, }
92 * This has been defined in include/linux/security.h for some time, but was
93 * only given an EXPORT_SYMBOL for 3.1. Add a compat_* definition to avoid
94 * breaking the compile.
96 #define security_sk_clone(a, b) compat_security_sk_clone(a, b)
98 static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
103 * In many versions, several architectures do not seem to include an
104 * atomic64_t implementation, and do not include the software emulation from
105 * asm-generic/atomic64_t.
106 * Detect and handle this here.
108 #include <asm/atomic.h>
110 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && !defined(ATOMIC64_INIT) && !defined(CONFIG_X86) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64))
111 #include <asm-generic/atomic64.h>
114 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */
116 #endif /* LINUX_3_1_COMPAT_H */