1
#ifndef COMPAT_INCLUDE_XEN_PLATFORM_COMPAT_H
2
#define COMPAT_INCLUDE_XEN_PLATFORM_COMPAT_H
4
#include <linux/version.h>
5
#include <linux/spinlock.h>
8
#if defined(__LINUX_COMPILER_H) && !defined(__always_inline)
9
#define __always_inline inline
12
#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_SPINLOCK)
13
#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
16
#if defined(_LINUX_INIT_H) && !defined(__init)
20
#if defined(__LINUX_CACHE_H) && !defined(__read_mostly)
24
#if defined(_LINUX_SKBUFF_H) && !defined(NET_IP_ALIGN)
25
#define NET_IP_ALIGN 0
28
#if defined(_LINUX_SKBUFF_H) && !defined(CHECKSUM_HW)
29
#define CHECKSUM_HW CHECKSUM_PARTIAL
32
#if defined(_LINUX_ERR_H) && !defined(IS_ERR_VALUE)
33
#define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
36
#if defined(_ASM_IA64_PGTABLE_H) && !defined(_PGTABLE_NOPUD_H)
37
#include <asm-generic/pgtable-nopud.h>
40
/* Some kernels have this typedef backported so we cannot reliably
41
* detect based on version number, hence we forcibly #define it.
43
#if defined(__LINUX_TYPES_H) || defined(__LINUX_GFP_H) || defined(_LINUX_KERNEL_H)
44
#define gfp_t unsigned
47
#if defined(_LINUX_NOTIFIER_H) && !defined(ATOMIC_NOTIFIER_HEAD)
48
#define ATOMIC_NOTIFIER_HEAD(name) struct notifier_block *name
49
#define atomic_notifier_chain_register(chain,nb) notifier_chain_register(chain,nb)
50
#define atomic_notifier_chain_unregister(chain,nb) notifier_chain_unregister(chain,nb)
51
#define atomic_notifier_call_chain(chain,val,v) notifier_call_chain(chain,val,v)
54
#if defined(_LINUX_NOTIFIER_H) && !defined(BLOCKING_NOTIFIER_HEAD)
55
#define BLOCKING_NOTIFIER_HEAD(name) struct notifier_block *name
56
#define blocking_notifier_chain_register(chain,nb) notifier_chain_register(chain,nb)
57
#define blocking_notifier_chain_unregister(chain,nb) notifier_chain_unregister(chain,nb)
58
#define blocking_notifier_call_chain(chain,val,v) notifier_call_chain(chain,val,v)
61
#if defined(_LINUX_MM_H) && defined set_page_count
62
#define init_page_count(page) set_page_count(page, 1)
65
#if defined(__LINUX_GFP_H) && !defined __GFP_NOMEMALLOC
66
#define __GFP_NOMEMALLOC 0
69
#if defined(_LINUX_FS_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
70
#define nonseekable_open(inode, filp) /* Nothing to do */
73
#if defined(_LINUX_MM_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
74
unsigned long vmalloc_to_pfn(void *addr);
77
#if defined(__LINUX_COMPLETION_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
78
unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout);
81
#if defined(_LINUX_SCHED_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
82
signed long schedule_timeout_interruptible(signed long timeout);
85
#if defined(_LINUX_SLAB_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
86
void *kzalloc(size_t size, int flags);
89
#if defined(_LINUX_BLKDEV_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
90
#define end_that_request_last(req, uptodate) end_that_request_last(req)
93
#if defined(_LINUX_CAPABILITY_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
94
#define capable(cap) (1)
97
#if defined(_LINUX_KERNEL_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
98
extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
99
__attribute__ ((format (printf, 2, 3)));
102
#if defined(_LINUX_SYSRQ_H) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
103
#define handle_sysrq(x,y,z) handle_sysrq(x,y)
106
#if defined(_PAGE_PRESENT) && !defined(_PAGE_NX)
109
* This variable at present is referenced by netfront, but only in code that
110
* is dead when running in hvm guests. To detect potential active uses of it
111
* in the future, don't try to supply a 'valid' value here, so that any
112
* mappings created with it will fault when accessed.
114
#define __supported_pte_mask ((maddr_t)0)
117
/* This code duplication is not ideal, but || does not seem to properly
118
* short circuit in a #if condition.
120
#if defined(_LINUX_NETDEVICE_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
121
#if !defined(SLE_VERSION)
122
#define netif_tx_lock_bh(dev) spin_lock_bh(&(dev)->xmit_lock)
123
#define netif_tx_unlock_bh(dev) spin_unlock_bh(&(dev)->xmit_lock)
124
#elif SLE_VERSION_CODE < SLE_VERSION(10,1,0)
125
#define netif_tx_lock_bh(dev) spin_lock_bh(&(dev)->xmit_lock)
126
#define netif_tx_unlock_bh(dev) spin_unlock_bh(&(dev)->xmit_lock)
130
#if defined(__LINUX_SEQLOCK_H) && !defined(DEFINE_SEQLOCK)
131
#define DEFINE_SEQLOCK(x) seqlock_t x = SEQLOCK_UNLOCKED
134
/* Bug in RHEL4-U3: rw_lock_t is mistakenly defined in DEFINE_RWLOCK() macro */
135
#if defined(__LINUX_SPINLOCK_H) && defined(DEFINE_RWLOCK)
136
#define rw_lock_t rwlock_t
139
#if defined(__LINUX_SPINLOCK_H) && !defined(DEFINE_RWLOCK)
140
#define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED
143
#if defined(_LINUX_INTERRUPT_H) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
145
* RHEL4-U5 pulled back this feature into the older kernel
146
* Since it is a typedef, and not a macro - detect this kernel via
149
#if !defined(RHEL_VERSION) || (RHEL_VERSION == 4 && RHEL_UPDATE < 5)
150
#if !defined(RHEL_MAJOR) || (RHEL_MAJOR == 4 && RHEL_MINOR < 5)
151
typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *);
156
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
157
#define setup_xen_features xen_setup_features
160
#ifndef atomic_cmpxchg
161
#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))