Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _LINUX_COMPAT_H |
2 | #define _LINUX_COMPAT_H | |
3 | /* | |
4 | * These are the type definitions for the architecture specific | |
5 | * syscall compatibility layer. | |
6 | */ | |
1da177e4 LT |
7 | |
8 | #ifdef CONFIG_COMPAT | |
9 | ||
10 | #include <linux/stat.h> | |
11 | #include <linux/param.h> /* for HZ */ | |
12 | #include <linux/sem.h> | |
13 | ||
14 | #include <asm/compat.h> | |
15 | #include <asm/siginfo.h> | |
3f2e05e9 | 16 | #include <asm/signal.h> |
1da177e4 LT |
17 | |
18 | #define compat_jiffies_to_clock_t(x) \ | |
19 | (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) | |
20 | ||
202e5979 SR |
21 | typedef __compat_uid32_t compat_uid_t; |
22 | typedef __compat_gid32_t compat_gid_t; | |
23 | ||
1da177e4 LT |
24 | struct rusage; |
25 | ||
26 | struct compat_itimerspec { | |
27 | struct compat_timespec it_interval; | |
28 | struct compat_timespec it_value; | |
29 | }; | |
30 | ||
31 | struct compat_utimbuf { | |
32 | compat_time_t actime; | |
33 | compat_time_t modtime; | |
34 | }; | |
35 | ||
36 | struct compat_itimerval { | |
37 | struct compat_timeval it_interval; | |
38 | struct compat_timeval it_value; | |
39 | }; | |
40 | ||
41 | struct compat_tms { | |
42 | compat_clock_t tms_utime; | |
43 | compat_clock_t tms_stime; | |
44 | compat_clock_t tms_cutime; | |
45 | compat_clock_t tms_cstime; | |
46 | }; | |
47 | ||
88959ea9 SR |
48 | struct compat_timex { |
49 | compat_uint_t modes; | |
50 | compat_long_t offset; | |
51 | compat_long_t freq; | |
52 | compat_long_t maxerror; | |
53 | compat_long_t esterror; | |
54 | compat_int_t status; | |
55 | compat_long_t constant; | |
56 | compat_long_t precision; | |
57 | compat_long_t tolerance; | |
58 | struct compat_timeval time; | |
59 | compat_long_t tick; | |
60 | compat_long_t ppsfreq; | |
61 | compat_long_t jitter; | |
62 | compat_int_t shift; | |
63 | compat_long_t stabil; | |
64 | compat_long_t jitcnt; | |
65 | compat_long_t calcnt; | |
66 | compat_long_t errcnt; | |
67 | compat_long_t stbcnt; | |
153b5d05 | 68 | compat_int_t tai; |
88959ea9 SR |
69 | |
70 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | |
71 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | |
153b5d05 | 72 | compat_int_t :32; compat_int_t :32; compat_int_t :32; |
88959ea9 SR |
73 | }; |
74 | ||
1da177e4 LT |
75 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) |
76 | ||
77 | typedef struct { | |
78 | compat_sigset_word sig[_COMPAT_NSIG_WORDS]; | |
79 | } compat_sigset_t; | |
80 | ||
81 | extern int cp_compat_stat(struct kstat *, struct compat_stat __user *); | |
82 | extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); | |
83 | extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); | |
84 | ||
85 | struct compat_iovec { | |
86 | compat_uptr_t iov_base; | |
87 | compat_size_t iov_len; | |
88 | }; | |
89 | ||
90 | struct compat_rlimit { | |
91 | compat_ulong_t rlim_cur; | |
92 | compat_ulong_t rlim_max; | |
93 | }; | |
94 | ||
95 | struct compat_rusage { | |
96 | struct compat_timeval ru_utime; | |
97 | struct compat_timeval ru_stime; | |
98 | compat_long_t ru_maxrss; | |
99 | compat_long_t ru_ixrss; | |
100 | compat_long_t ru_idrss; | |
101 | compat_long_t ru_isrss; | |
102 | compat_long_t ru_minflt; | |
103 | compat_long_t ru_majflt; | |
104 | compat_long_t ru_nswap; | |
105 | compat_long_t ru_inblock; | |
106 | compat_long_t ru_oublock; | |
107 | compat_long_t ru_msgsnd; | |
108 | compat_long_t ru_msgrcv; | |
109 | compat_long_t ru_nsignals; | |
110 | compat_long_t ru_nvcsw; | |
111 | compat_long_t ru_nivcsw; | |
112 | }; | |
113 | ||
114 | extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *); | |
115 | ||
116 | struct compat_siginfo; | |
117 | ||
118 | extern asmlinkage long compat_sys_waitid(int, compat_pid_t, | |
119 | struct compat_siginfo __user *, int, | |
120 | struct compat_rusage __user *); | |
121 | ||
122 | struct compat_dirent { | |
123 | u32 d_ino; | |
124 | compat_off_t d_off; | |
125 | u16 d_reclen; | |
126 | char d_name[256]; | |
127 | }; | |
128 | ||
129 | typedef union compat_sigval { | |
130 | compat_int_t sival_int; | |
131 | compat_uptr_t sival_ptr; | |
132 | } compat_sigval_t; | |
133 | ||
134 | #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) | |
135 | ||
136 | typedef struct compat_sigevent { | |
137 | compat_sigval_t sigev_value; | |
138 | compat_int_t sigev_signo; | |
139 | compat_int_t sigev_notify; | |
140 | union { | |
141 | compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE]; | |
142 | compat_int_t _tid; | |
143 | ||
144 | struct { | |
145 | compat_uptr_t _function; | |
146 | compat_uptr_t _attribute; | |
147 | } _sigev_thread; | |
148 | } _sigev_un; | |
149 | } compat_sigevent_t; | |
150 | ||
34f192c6 IM |
151 | struct compat_robust_list { |
152 | compat_uptr_t next; | |
153 | }; | |
154 | ||
155 | struct compat_robust_list_head { | |
156 | struct compat_robust_list list; | |
157 | compat_long_t futex_offset; | |
158 | compat_uptr_t list_op_pending; | |
159 | }; | |
160 | ||
161 | extern void compat_exit_robust_list(struct task_struct *curr); | |
162 | ||
163 | asmlinkage long | |
164 | compat_sys_set_robust_list(struct compat_robust_list_head __user *head, | |
165 | compat_size_t len); | |
166 | asmlinkage long | |
ba46df98 | 167 | compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, |
34f192c6 | 168 | compat_size_t __user *len_ptr); |
1da177e4 LT |
169 | |
170 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); | |
171 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); | |
172 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, | |
173 | int version, void __user *uptr); | |
174 | long compat_sys_msgctl(int first, int second, void __user *uptr); | |
175 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | |
176 | void __user *uptr); | |
177 | long compat_sys_shmctl(int first, int second, void __user *uptr); | |
178 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, | |
179 | unsigned nsems, const struct compat_timespec __user *timeout); | |
180 | asmlinkage long compat_sys_keyctl(u32 option, | |
181 | u32 arg2, u32 arg3, u32 arg4, u32 arg5); | |
182 | ||
183 | asmlinkage ssize_t compat_sys_readv(unsigned long fd, | |
184 | const struct compat_iovec __user *vec, unsigned long vlen); | |
185 | asmlinkage ssize_t compat_sys_writev(unsigned long fd, | |
186 | const struct compat_iovec __user *vec, unsigned long vlen); | |
187 | ||
188 | int compat_do_execve(char * filename, compat_uptr_t __user *argv, | |
189 | compat_uptr_t __user *envp, struct pt_regs * regs); | |
190 | ||
191 | asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, | |
192 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, | |
193 | struct compat_timeval __user *tvp); | |
194 | ||
c202f298 | 195 | asmlinkage long compat_sys_wait4(compat_pid_t pid, |
7d61c459 AV |
196 | compat_uint_t __user *stat_addr, int options, |
197 | struct compat_rusage __user *ru); | |
c202f298 | 198 | |
1da177e4 LT |
199 | #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) |
200 | ||
201 | #define BITS_TO_COMPAT_LONGS(bits) \ | |
202 | (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG) | |
203 | ||
5fa3839a | 204 | long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask, |
1da177e4 LT |
205 | unsigned long bitmap_size); |
206 | long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, | |
207 | unsigned long bitmap_size); | |
208 | int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from); | |
209 | int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from); | |
210 | int get_compat_sigevent(struct sigevent *event, | |
211 | const struct compat_sigevent __user *u_event); | |
212 | ||
643a6545 AM |
213 | static inline int compat_timeval_compare(struct compat_timeval *lhs, |
214 | struct compat_timeval *rhs) | |
215 | { | |
216 | if (lhs->tv_sec < rhs->tv_sec) | |
217 | return -1; | |
218 | if (lhs->tv_sec > rhs->tv_sec) | |
219 | return 1; | |
220 | return lhs->tv_usec - rhs->tv_usec; | |
221 | } | |
222 | ||
223 | static inline int compat_timespec_compare(struct compat_timespec *lhs, | |
224 | struct compat_timespec *rhs) | |
225 | { | |
226 | if (lhs->tv_sec < rhs->tv_sec) | |
227 | return -1; | |
228 | if (lhs->tv_sec > rhs->tv_sec) | |
229 | return 1; | |
230 | return lhs->tv_nsec - rhs->tv_nsec; | |
231 | } | |
232 | ||
83f5d126 DL |
233 | extern int get_compat_itimerspec(struct itimerspec *dst, |
234 | const struct compat_itimerspec __user *src); | |
235 | extern int put_compat_itimerspec(struct compat_itimerspec __user *dst, | |
236 | const struct itimerspec *src); | |
237 | ||
3158e941 SR |
238 | asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); |
239 | ||
bebfa101 | 240 | extern int compat_printk(const char *fmt, ...); |
0235497f | 241 | extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat); |
bebfa101 | 242 | |
3fd59397 SR |
243 | asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, |
244 | compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, | |
245 | const compat_ulong_t __user *new_nodes); | |
246 | ||
032d82d9 RM |
247 | extern int compat_ptrace_request(struct task_struct *child, |
248 | compat_long_t request, | |
249 | compat_ulong_t addr, compat_ulong_t data); | |
250 | ||
c269f196 RM |
251 | #ifdef __ARCH_WANT_COMPAT_SYS_PTRACE |
252 | extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request, | |
253 | compat_ulong_t addr, compat_ulong_t data); | |
254 | asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, | |
255 | compat_long_t addr, compat_long_t data); | |
256 | #endif /* __ARCH_WANT_COMPAT_SYS_PTRACE */ | |
257 | ||
f6dfb4fd DL |
258 | /* |
259 | * epoll (fs/eventpoll.c) compat bits follow ... | |
260 | */ | |
f6dfb4fd DL |
261 | struct epoll_event; |
262 | #define compat_epoll_event epoll_event | |
f6dfb4fd DL |
263 | asmlinkage long compat_sys_epoll_pwait(int epfd, |
264 | struct compat_epoll_event __user *events, | |
265 | int maxevents, int timeout, | |
266 | const compat_sigset_t __user *sigmask, | |
267 | compat_size_t sigsetsize); | |
268 | ||
97416ce8 SR |
269 | asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, |
270 | struct compat_timespec __user *t, int flags); | |
271 | ||
140ff8b0 SR |
272 | asmlinkage long compat_sys_signalfd(int ufd, |
273 | const compat_sigset_t __user *sigmask, | |
274 | compat_size_t sigsetsize); | |
4d672e7a DL |
275 | asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, |
276 | const struct compat_itimerspec __user *utmr, | |
277 | struct compat_itimerspec __user *otmr); | |
278 | asmlinkage long compat_sys_timerfd_gettime(int ufd, | |
279 | struct compat_itimerspec __user *otmr); | |
140ff8b0 | 280 | |
1da177e4 LT |
281 | #endif /* CONFIG_COMPAT */ |
282 | #endif /* _LINUX_COMPAT_H */ |