1 |
/* |
/* |
2 |
* include/linux/ccs_compat.h |
* security/ccsecurity/compat.h |
|
* |
|
|
* For compatibility for older kernels. |
|
3 |
* |
* |
4 |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
5 |
* |
* |
6 |
* Version: 1.6.7-rc 2009/03/03 |
* Version: 1.7.0-pre 2009/07/03 |
7 |
* |
* |
8 |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
9 |
* See README.ccs for ChangeLog. |
* See README.ccs for ChangeLog. |
58 |
#define KERN_CONT "" |
#define KERN_CONT "" |
59 |
#endif |
#endif |
60 |
|
|
61 |
|
/* To support PID namespace. */ |
62 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) |
63 |
|
#define find_task_by_pid find_task_by_vpid |
64 |
|
#endif |
65 |
|
|
66 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) |
67 |
#define mutex semaphore |
#define mutex semaphore |
68 |
#define mutex_init(mutex) init_MUTEX(mutex) |
#define mutex_init(mutex) init_MUTEX(mutex) |
69 |
#define mutex_lock(mutex) down(mutex) |
#define mutex_lock(mutex) down(mutex) |
70 |
#define mutex_unlock(mutex) up(mutex) |
#define mutex_unlock(mutex) up(mutex) |
71 |
#define mutex_lock_interruptible(mutex) down_interruptible(mutex) |
#define mutex_lock_interruptible(mutex) down_interruptible(mutex) |
72 |
|
#define mutex_trylock(mutex) !down_trylock(mutex) |
73 |
#define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname) |
#define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname) |
74 |
#endif |
#endif |
75 |
|
|
130 |
#endif |
#endif |
131 |
|
|
132 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) |
133 |
|
static inline void __list_add_rcu(struct list_head *new, |
134 |
|
struct list_head *prev, |
135 |
|
struct list_head *next) |
136 |
|
{ |
137 |
|
new->next = next; |
138 |
|
new->prev = prev; |
139 |
|
rcu_assign_pointer(prev->next, new); |
140 |
|
next->prev = new; |
141 |
|
} |
142 |
|
|
143 |
|
static inline void list_add_tail_rcu(struct list_head *new, |
144 |
|
struct list_head *head) |
145 |
|
{ |
146 |
|
__list_add_rcu(new, head->prev, head); |
147 |
|
} |
148 |
|
|
149 |
|
static inline void list_add_rcu(struct list_head *new, struct list_head *head) |
150 |
|
{ |
151 |
|
__list_add_rcu(new, head, head->next); |
152 |
|
} |
153 |
|
|
154 |
|
#ifndef LIST_POISON2 |
155 |
|
#define LIST_POISON2 ((void *) 0x00200200) |
156 |
|
#endif |
157 |
|
|
158 |
|
static inline void list_del_rcu(struct list_head *entry) |
159 |
|
{ |
160 |
|
__list_del(entry->prev, entry->next); |
161 |
|
entry->prev = LIST_POISON2; |
162 |
|
} |
163 |
|
#endif |
164 |
|
|
165 |
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 30) |
166 |
|
#undef ssleep |
167 |
|
#define ssleep(secs) { \ |
168 |
|
set_current_state(TASK_UNINTERRUPTIBLE); \ |
169 |
|
schedule_timeout((HZ * secs) + 1); \ |
170 |
|
} |
171 |
|
#endif |
172 |
|
|
173 |
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) |
174 |
#define s_fs_info u.generic_sbp |
#define s_fs_info u.generic_sbp |
175 |
#else |
#else |
176 |
#include <linux/audit.h> |
#include <linux/audit.h> |
199 |
#define sk_protocol protocol |
#define sk_protocol protocol |
200 |
#define sk_type type |
#define sk_type type |
201 |
#define sk_receive_queue receive_queue |
#define sk_receive_queue receive_queue |
202 |
|
static inline struct socket *SOCKET_I(struct inode *inode) |
203 |
|
{ |
204 |
|
return inode->i_sock ? &inode->u.socket_i : NULL; |
205 |
|
} |
206 |
|
#endif |
207 |
|
|
208 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) |
209 |
|
#if defined(__LITTLE_ENDIAN) |
210 |
|
#define HIPQUAD(addr) \ |
211 |
|
((unsigned char *)&addr)[3], \ |
212 |
|
((unsigned char *)&addr)[2], \ |
213 |
|
((unsigned char *)&addr)[1], \ |
214 |
|
((unsigned char *)&addr)[0] |
215 |
|
#elif defined(__BIG_ENDIAN) |
216 |
|
#define HIPQUAD NIPQUAD |
217 |
|
#else |
218 |
|
#error "Please fix asm/byteorder.h" |
219 |
|
#endif /* __LITTLE_ENDIAN */ |
220 |
|
#endif |
221 |
|
|
222 |
|
#ifndef _LINUX_SRCU_H |
223 |
|
|
224 |
|
struct srcu_struct { |
225 |
|
int counter_idx; |
226 |
|
int counter[2]; |
227 |
|
}; |
228 |
|
|
229 |
|
static inline int init_srcu_struct(struct srcu_struct *sp) |
230 |
|
{ |
231 |
|
return 0; |
232 |
|
} |
233 |
|
|
234 |
|
int srcu_read_lock(struct srcu_struct *sp); |
235 |
|
void srcu_read_unlock(struct srcu_struct *sp, const int idx); |
236 |
|
void synchronize_srcu(struct srcu_struct *sp); |
237 |
|
|
238 |
#endif |
#endif |