Whamcloud - gitweb
5a43a4568647a00b2e8073262be02416f8146a52
[fs/lustre-release.git] / lustre / portals / include / 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 _PORTALS_COMPAT_H
5 #define _PORTALS_COMPAT_H
6
7 // XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved
8 #if 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 CURRENT_SECONDS           get_seconds()
31 # define smp_num_cpus              NR_CPUS
32
33
34 #elif defined(CONFIG_RH_2_4_20) /* RH 2.4.x */
35
36 # define SIGNAL_MASK_LOCK(task, flags)                                  \
37   spin_lock_irqsave(&task->sighand->siglock, flags)
38 # define SIGNAL_MASK_UNLOCK(task, flags)                                \
39   spin_unlock_irqrestore(&task->sighand->siglock, flags)
40 # define USERMODEHELPER(path, argv, envp)                               \
41   call_usermodehelper(path, argv, envp)
42 # define RECALC_SIGPENDING         recalc_sigpending()
43 # define CURRENT_SECONDS           CURRENT_TIME
44
45 # define kernel_text_address(addr) is_kernel_text_address(addr)
46 extern int is_kernel_text_address(unsigned long addr);
47
48 #else /* 2.4.x */
49
50 # define SIGNAL_MASK_LOCK(task, flags)                                  \
51   spin_lock_irqsave(&task->sigmask_lock, flags)
52 # define SIGNAL_MASK_UNLOCK(task, flags)                                \
53   spin_unlock_irqrestore(&task->sigmask_lock, flags)
54 # define USERMODEHELPER(path, argv, envp)                               \
55   call_usermodehelper(path, argv, envp)
56 # define RECALC_SIGPENDING         recalc_sigpending(current)
57 # define CURRENT_SECONDS           CURRENT_TIME
58
59 # define kernel_text_address(addr) is_kernel_text_address(addr)
60 extern int is_kernel_text_address(unsigned long addr);
61
62 #endif
63
64 #if defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
65 # define THREAD_NAME(comm, len, fmt, a...)                              \
66         snprintf(comm, len, fmt "|%d", ## a, current->thread.extern_pid)
67 #elif defined(__arch_um__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
68 # define THREAD_NAME(comm, len, fmt, a...)                              \
69         snprintf(comm, len,fmt"|%d", ## a,current->thread.mode.tt.extern_pid)
70 #else
71 # define THREAD_NAME(comm, len, fmt, a...)                              \
72         snprintf(comm, len, fmt, ## a)
73 #endif
74
75 #ifdef HAVE_PAGE_LIST
76 /* 2.4 alloc_page users can use page->list */
77 #define PAGE_LIST_ENTRY list
78 #define PAGE_LIST(page) ((page)->list)
79 #else
80 /* 2.6 alloc_page users can use page->lru */
81 #define PAGE_LIST_ENTRY lru
82 #define PAGE_LIST(page) ((page)->lru)
83 #endif
84
85 #ifndef HAVE_CPU_ONLINE
86 #define cpu_online(cpu) (test_bit(cpu_online_map, &(cpu)))
87 #endif
88 #ifndef HAVE_CPUMASK_T
89 #define cpu_set(cpu, map) (set_bit(cpu, &(map)))
90 typedef unsigned long cpumask_t;
91 #endif
92
93 #endif /* _PORTALS_COMPAT_H */