オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /trunk/1.8.x/ccs-patch/security/ccsecurity/compat.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2854 - (show annotations) (download) (as text)
Wed Aug 5 11:57:20 2009 UTC (14 years, 9 months ago) by kumaneko
Original Path: branches/ccs-patch/fs/ccsecurity/compat.h
File MIME type: text/x-chdr
File size: 5706 byte(s)


1 /*
2 * fs/ccsecurity/compat.h
3 *
4 * Copyright (C) 2005-2009 NTT DATA CORPORATION
5 *
6 * 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.
9 * See README.ccs for ChangeLog.
10 *
11 */
12
13 #define false 0
14 #define true 1
15
16 #ifndef __user
17 #define __user
18 #endif
19
20 #ifndef current_uid
21 #define current_uid() (current->uid)
22 #endif
23 #ifndef current_gid
24 #define current_gid() (current->gid)
25 #endif
26 #ifndef current_euid
27 #define current_euid() (current->euid)
28 #endif
29 #ifndef current_egid
30 #define current_egid() (current->egid)
31 #endif
32 #ifndef current_suid
33 #define current_suid() (current->suid)
34 #endif
35 #ifndef current_sgid
36 #define current_sgid() (current->sgid)
37 #endif
38 #ifndef current_fsuid
39 #define current_fsuid() (current->fsuid)
40 #endif
41 #ifndef current_fsgid
42 #define current_fsgid() (current->fsgid)
43 #endif
44
45 #ifndef WARN_ON
46 #define WARN_ON(x) do { } while (0)
47 #endif
48
49 #ifndef DEFINE_SPINLOCK
50 #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
51 #endif
52
53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
54 #define bool _Bool
55 #endif
56
57 #ifndef KERN_CONT
58 #define KERN_CONT ""
59 #endif
60
61 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
62 #define mutex semaphore
63 #define mutex_init(mutex) init_MUTEX(mutex)
64 #define mutex_lock(mutex) down(mutex)
65 #define mutex_unlock(mutex) up(mutex)
66 #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
67 #define mutex_trylock(mutex) !down_trylock(mutex)
68 #define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname)
69 #endif
70
71 #ifndef container_of
72 #define container_of(ptr, type, member) ({ \
73 const typeof(((type *)0)->member) *__mptr = (ptr); \
74 (type *)((char *)__mptr - offsetof(type, member)); })
75 #endif
76
77 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
78 #define kzalloc(size, flags) ({ \
79 void *ret = kmalloc((size), (flags)); \
80 if (ret) \
81 memset(ret, 0, (size)); \
82 ret; })
83 #endif
84
85 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
86 #define smp_read_barrier_depends smp_rmb
87 #endif
88
89 #ifndef ACCESS_ONCE
90 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
91 #endif
92
93 #ifndef rcu_dereference
94 #define rcu_dereference(p) ({ \
95 typeof(p) _________p1 = ACCESS_ONCE(p); \
96 smp_read_barrier_depends(); /* see RCU */ \
97 (_________p1); \
98 })
99 #endif
100
101 #ifndef rcu_assign_pointer
102 #define rcu_assign_pointer(p, v) \
103 ({ \
104 if (!__builtin_constant_p(v) || \
105 ((v) != NULL)) \
106 smp_wmb(); /* see RCU */ \
107 (p) = (v); \
108 })
109 #endif
110
111 #ifndef list_for_each_rcu
112 #define list_for_each_rcu(pos, head) \
113 for (pos = rcu_dereference((head)->next); \
114 prefetch(pos->next), pos != (head); \
115 pos = rcu_dereference(pos->next))
116 #endif
117
118 #ifndef list_for_each_entry_rcu
119 #define list_for_each_entry_rcu(pos, head, member) \
120 for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), \
121 member); \
122 prefetch(pos->member.next), &pos->member != (head); \
123 pos = list_entry(rcu_dereference(pos->member.next), \
124 typeof(*pos), member))
125 #endif
126
127 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
128 static inline void __list_add_rcu(struct list_head *new,
129 struct list_head *prev,
130 struct list_head *next)
131 {
132 new->next = next;
133 new->prev = prev;
134 rcu_assign_pointer(prev->next, new);
135 next->prev = new;
136 }
137
138 static inline void list_add_tail_rcu(struct list_head *new,
139 struct list_head *head)
140 {
141 __list_add_rcu(new, head->prev, head);
142 }
143
144 static inline void list_add_rcu(struct list_head *new, struct list_head *head)
145 {
146 __list_add_rcu(new, head, head->next);
147 }
148
149 #ifndef LIST_POISON2
150 #define LIST_POISON2 ((void *) 0x00200200)
151 #endif
152
153 static inline void list_del_rcu(struct list_head *entry)
154 {
155 __list_del(entry->prev, entry->next);
156 entry->prev = LIST_POISON2;
157 }
158 #endif
159
160 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 30)
161 #undef ssleep
162 #define ssleep(secs) { \
163 set_current_state(TASK_UNINTERRUPTIBLE); \
164 schedule_timeout((HZ * secs) + 1); \
165 }
166 #endif
167
168 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
169 #define s_fs_info u.generic_sbp
170 #else
171 #include <linux/audit.h>
172 #ifdef AUDIT_APPARMOR_AUDIT
173 /* AppArmor patch adds "struct vfsmount" to VFS helper functions. */
174 #define HAVE_VFSMOUNT_IN_VFS_HELPER
175 #endif
176 #endif
177
178 #if defined(RHEL_MAJOR) && RHEL_MAJOR == 5
179 #define HAVE_NO_I_BLKSIZE_IN_INODE
180 #elif defined(AX_MAJOR) && AX_MAJOR == 3
181 #define HAVE_NO_I_BLKSIZE_IN_INODE
182 #endif
183
184 #ifndef list_for_each_entry_safe
185 #define list_for_each_entry_safe(pos, n, head, member) \
186 for (pos = list_entry((head)->next, typeof(*pos), member), \
187 n = list_entry(pos->member.next, typeof(*pos), member); \
188 &pos->member != (head); \
189 pos = n, n = list_entry(n->member.next, typeof(*n), member))
190 #endif
191
192 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
193 #define sk_family family
194 #define sk_protocol protocol
195 #define sk_type type
196 #define sk_receive_queue receive_queue
197 static inline struct socket *SOCKET_I(struct inode *inode)
198 {
199 return inode->i_sock ? &inode->u.socket_i : NULL;
200 }
201 #endif
202
203 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
204 #if defined(__LITTLE_ENDIAN)
205 #define HIPQUAD(addr) \
206 ((unsigned char *)&addr)[3], \
207 ((unsigned char *)&addr)[2], \
208 ((unsigned char *)&addr)[1], \
209 ((unsigned char *)&addr)[0]
210 #elif defined(__BIG_ENDIAN)
211 #define HIPQUAD NIPQUAD
212 #else
213 #error "Please fix asm/byteorder.h"
214 #endif /* __LITTLE_ENDIAN */
215 #endif
216
217 #ifndef _LINUX_SRCU_H
218
219 struct srcu_struct {
220 int counter_idx;
221 int counter[2];
222 };
223
224 static inline int init_srcu_struct(struct srcu_struct *sp)
225 {
226 return 0;
227 }
228
229 int srcu_read_lock(struct srcu_struct *sp);
230 void srcu_read_unlock(struct srcu_struct *sp, const int idx);
231 void synchronize_srcu(struct srcu_struct *sp);
232
233 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26