Whamcloud - gitweb
Branch b1_6
[fs/lustre-release.git] / lnet / include / libcfs / linux / portals_compat25.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 #ifndef __LIBCFS_LINUX_PORTALS_COMPAT_H__
5 #define __LIBCFS_LINUX_PORTALS_COMPAT_H__
6
7 // XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved
8 #if defined(SPINLOCK_DEBUG) && SPINLOCK_DEBUG
9 # if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) || defined(CONFIG_RH_2_4_20)
10 #  define SIGNAL_MASK_ASSERT() \
11    LASSERT(current->sighand->siglock.magic == SPINLOCK_MAGIC)
12 # else
13 #  define SIGNAL_MASK_ASSERT() \
14    LASSERT(current->sigmask_lock.magic == SPINLOCK_MAGIC)
15 # endif
16 #else
17 # define SIGNAL_MASK_ASSERT()
18 #endif
19 // XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved
20
21 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
22
23 # define SIGNAL_MASK_LOCK(task, flags)                                  \
24   spin_lock_irqsave(&task->sighand->siglock, flags)
25 # define SIGNAL_MASK_UNLOCK(task, flags)                                \
26   spin_unlock_irqrestore(&task->sighand->siglock, flags)
27 # define USERMODEHELPER(path, argv, envp)                               \
28   call_usermodehelper(path, argv, envp, 1)
29 # define RECALC_SIGPENDING         recalc_sigpending()
30 # define CLEAR_SIGPENDING          clear_tsk_thread_flag(current,       \
31                                                          TIF_SIGPENDING)
32 # define CURRENT_SECONDS           get_seconds()
33 # define smp_num_cpus              num_online_cpus()
34
35
36 #elif defined(CONFIG_RH_2_4_20) /* RH 2.4.x */
37
38 # define SIGNAL_MASK_LOCK(task, flags)                                  \
39   spin_lock_irqsave(&task->sighand->siglock, flags)
40 # define SIGNAL_MASK_UNLOCK(task, flags)                                \
41   spin_unlock_irqrestore(&task->sighand->siglock, flags)
42 # define USERMODEHELPER(path, argv, envp)                               \
43   call_usermodehelper(path, argv, envp)
44 # define RECALC_SIGPENDING         recalc_sigpending()
45 # define CLEAR_SIGPENDING          (current->sigpending = 0)
46 # define CURRENT_SECONDS           CURRENT_TIME
47 # define wait_event_interruptible_exclusive(wq, condition)              \
48         wait_event_interruptible(wq, condition)
49
50 #else /* 2.4.x */
51
52 # define SIGNAL_MASK_LOCK(task, flags)                                  \
53   spin_lock_irqsave(&task->sigmask_lock, flags)
54 # define SIGNAL_MASK_UNLOCK(task, flags)                                \
55   spin_unlock_irqrestore(&task->sigmask_lock, flags)
56 # define USERMODEHELPER(path, argv, envp)                               \
57   call_usermodehelper(path, argv, envp)
58 # define RECALC_SIGPENDING         recalc_sigpending(current)
59 # define CLEAR_SIGPENDING          (current->sigpending = 0)
60 # define CURRENT_SECONDS           CURRENT_TIME
61 # define wait_event_interruptible_exclusive(wq, condition)              \
62         wait_event_interruptible(wq, condition)
63
64 #endif
65
66 #if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
67 #define UML_PID(tsk) ((tsk)->thread.extern_pid)
68 #elif defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
69 #define UML_PID(tsk) ((tsk)->thread.mode.tt.extern_pid)
70 #else
71 #define UML_PID(tsk) ((tsk)->pid)
72 #endif
73
74 #if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
75 # define THREAD_NAME(comm, len, fmt, a...)                              \
76         snprintf(comm, len,fmt"|%d", ## a, UML_PID(current))
77 #else
78 # define THREAD_NAME(comm, len, fmt, a...)                              \
79         snprintf(comm, len, fmt, ## a)
80 #endif
81
82 #ifdef HAVE_PAGE_LIST
83 /* 2.4 alloc_page users can use page->list */
84 #define PAGE_LIST_ENTRY list
85 #define PAGE_LIST(page) ((page)->list)
86 #else
87 /* 2.6 alloc_page users can use page->lru */
88 #define PAGE_LIST_ENTRY lru
89 #define PAGE_LIST(page) ((page)->lru)
90 #endif
91
92 #ifndef HAVE_CPU_ONLINE
93 #define cpu_online(cpu) ((1<<cpu) & (cpu_online_map))
94 #endif
95 #ifndef HAVE_CPUMASK_T
96 typedef unsigned long cpumask_t;
97 #define cpu_set(cpu, map) set_bit(cpu, &(map))
98 #define cpus_clear(map) memset(&(map), 0, sizeof(cpumask_t))
99 #endif
100
101 #ifndef __user
102 #define __user
103 #endif
104
105 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
106 #define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
107         proc_dointvec(table, write, filp, buffer, lenp)
108 #define ll_proc_dostring(table, write, filp, buffer, lenp, ppos)        \
109         proc_dostring(table, write, filp, buffer, lenp)
110 #define LL_PROC_PROTO(name)                                             \
111         name(cfs_sysctl_table_t *table, int write, struct file *filp,   \
112              void __user *buffer, size_t *lenp)
113 #else
114 #define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
115         proc_dointvec(table, write, filp, buffer, lenp, ppos);
116 #define ll_proc_dostring(table, write, filp, buffer, lenp, ppos)        \
117         proc_dostring(table, write, filp, buffer, lenp, ppos);
118 #define LL_PROC_PROTO(name)                                             \
119         name(cfs_sysctl_table_t *table, int write, struct file *filp,   \
120              void __user *buffer, size_t *lenp, loff_t *ppos)
121 #endif
122
123 #endif /* _PORTALS_COMPAT_H */