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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2718 - (hide annotations) (download) (as text)
Thu Jul 2 01:30:12 2009 UTC (14 years, 10 months ago) by kumaneko
Original Path: branches/ccs-patch/include/linux/ccs_compat.h
File MIME type: text/x-chdr
File size: 5761 byte(s)


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

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