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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3534 - (hide annotations) (download) (as text)
Thu Mar 25 06:16:09 2010 UTC (14 years, 2 months ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/security/ccsecurity/compat.h
File MIME type: text/x-chdr
File size: 5478 byte(s)
Use mutex_lock_interruptible() rather than mutex_lock().
1 kumaneko 2037 /*
2 kumaneko 2864 * security/ccsecurity/compat.h
3 kumaneko 2037 *
4 kumaneko 3502 * Copyright (C) 2005-2010 NTT DATA CORPORATION
5 kumaneko 2037 *
6 kumaneko 3519 * Version: 1.7.2-pre 2010/03/21
7 kumaneko 2037 *
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_unlock(mutex) up(mutex)
65     #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
66 kumaneko 3512 #define mutex_trylock(mutex) (!down_trylock(mutex))
67 kumaneko 2037 #define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname)
68     #endif
69    
70     #ifndef container_of
71     #define container_of(ptr, type, member) ({ \
72     const typeof(((type *)0)->member) *__mptr = (ptr); \
73     (type *)((char *)__mptr - offsetof(type, member)); })
74     #endif
75    
76     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
77 kumaneko 2943 #define kzalloc(size, flags) ({ \
78     void *ret = kmalloc((size), (flags)); \
79     if (ret) \
80     memset(ret, 0, (size)); \
81 kumaneko 2037 ret; })
82     #endif
83    
84 kumaneko 2690 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
85     #define smp_read_barrier_depends smp_rmb
86 kumaneko 2037 #endif
87    
88 kumaneko 2690 #ifndef ACCESS_ONCE
89     #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
90     #endif
91    
92     #ifndef rcu_dereference
93 kumaneko 2943 #define rcu_dereference(p) ({ \
94     typeof(p) _________p1 = ACCESS_ONCE(p); \
95     smp_read_barrier_depends(); /* see RCU */ \
96     (_________p1); \
97     })
98 kumaneko 2690 #endif
99    
100     #ifndef rcu_assign_pointer
101 kumaneko 2943 #define rcu_assign_pointer(p, v) \
102     ({ \
103     if (!__builtin_constant_p(v) || \
104     ((v) != NULL)) \
105     smp_wmb(); /* see RCU */ \
106     (p) = (v); \
107 kumaneko 2690 })
108     #endif
109    
110     #ifndef list_for_each_rcu
111 kumaneko 2943 #define list_for_each_rcu(pos, head) \
112     for (pos = rcu_dereference((head)->next); \
113     prefetch(pos->next), pos != (head); \
114     pos = rcu_dereference(pos->next))
115 kumaneko 2690 #endif
116    
117     #ifndef list_for_each_entry_rcu
118 kumaneko 2943 #define list_for_each_entry_rcu(pos, head, member) \
119 kumaneko 2690 for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), \
120 kumaneko 2943 member); \
121     prefetch(pos->member.next), &pos->member != (head); \
122     pos = list_entry(rcu_dereference(pos->member.next), \
123     typeof(*pos), member))
124 kumaneko 2037 #endif
125    
126     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
127 kumaneko 2718 static inline void __list_add_rcu(struct list_head *new,
128     struct list_head *prev,
129     struct list_head *next)
130     {
131     new->next = next;
132     new->prev = prev;
133     rcu_assign_pointer(prev->next, new);
134     next->prev = new;
135     }
136    
137     static inline void list_add_tail_rcu(struct list_head *new,
138     struct list_head *head)
139     {
140     __list_add_rcu(new, head->prev, head);
141     }
142    
143     static inline void list_add_rcu(struct list_head *new, struct list_head *head)
144     {
145     __list_add_rcu(new, head, head->next);
146     }
147    
148     #ifndef LIST_POISON2
149     #define LIST_POISON2 ((void *) 0x00200200)
150     #endif
151    
152     static inline void list_del_rcu(struct list_head *entry)
153     {
154     __list_del(entry->prev, entry->next);
155     entry->prev = LIST_POISON2;
156     }
157     #endif
158    
159     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 30)
160 kumaneko 2720 #undef ssleep
161 kumaneko 2943 #define ssleep(secs) { \
162     set_current_state(TASK_UNINTERRUPTIBLE); \
163     schedule_timeout((HZ * secs) + 1); \
164     }
165 kumaneko 2718 #endif
166    
167     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
168 kumaneko 2037 #define s_fs_info u.generic_sbp
169     #endif
170    
171     #ifndef list_for_each_entry_safe
172     #define list_for_each_entry_safe(pos, n, head, member) \
173     for (pos = list_entry((head)->next, typeof(*pos), member), \
174     n = list_entry(pos->member.next, typeof(*pos), member); \
175     &pos->member != (head); \
176     pos = n, n = list_entry(n->member.next, typeof(*n), member))
177     #endif
178    
179     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
180     #define sk_family family
181     #define sk_protocol protocol
182     #define sk_type type
183     #define sk_receive_queue receive_queue
184 kumaneko 2281 static inline struct socket *SOCKET_I(struct inode *inode)
185     {
186     return inode->i_sock ? &inode->u.socket_i : NULL;
187     }
188 kumaneko 2037 #endif
189 kumaneko 2402
190     #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
191     #if defined(__LITTLE_ENDIAN)
192 kumaneko 2943 #define HIPQUAD(addr) \
193     ((unsigned char *)&addr)[3], \
194     ((unsigned char *)&addr)[2], \
195     ((unsigned char *)&addr)[1], \
196     ((unsigned char *)&addr)[0]
197 kumaneko 2402 #elif defined(__BIG_ENDIAN)
198     #define HIPQUAD NIPQUAD
199     #else
200     #error "Please fix asm/byteorder.h"
201     #endif /* __LITTLE_ENDIAN */
202     #endif
203 kumaneko 2716
204 kumaneko 2911 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
205 kumaneko 3464 #ifndef _STRUCT_PATH_DEFINED
206 kumaneko 2911 struct path {
207 kumaneko 2943 struct vfsmount *mnt;
208     struct dentry *dentry;
209 kumaneko 2911 };
210     #endif
211 kumaneko 3464 #endif
212 kumaneko 2911
213     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
214    
215     #include <linux/mount.h>
216    
217     static inline void path_get(struct path *path)
218     {
219     dget(path->dentry);
220     mntget(path->mnt);
221     }
222    
223     static inline void path_put(struct path *path)
224     {
225     dput(path->dentry);
226     mntput(path->mnt);
227     }
228    
229     #endif

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