1 #ifndef _LINUX_COMPAT_H
2 #define _LINUX_COMPAT_H
4 * These are the type definitions for the architecture specific
5 * syscall compatibility layer.
10 #include <linux/stat.h>
11 #include <linux/param.h> /* for HZ */
12 #include <linux/sem.h>
14 #include <asm/compat.h>
15 #include <asm/siginfo.h>
16 #include <asm/signal.h>
18 #define compat_jiffies_to_clock_t(x) \
19 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
21 typedef __compat_uid32_t compat_uid_t;
22 typedef __compat_gid32_t compat_gid_t;
26 struct compat_itimerspec {
27 struct compat_timespec it_interval;
28 struct compat_timespec it_value;
31 struct compat_utimbuf {
33 compat_time_t modtime;
36 struct compat_itimerval {
37 struct compat_timeval it_interval;
38 struct compat_timeval it_value;
42 compat_clock_t tms_utime;
43 compat_clock_t tms_stime;
44 compat_clock_t tms_cutime;
45 compat_clock_t tms_cstime;
52 compat_long_t maxerror;
53 compat_long_t esterror;
55 compat_long_t constant;
56 compat_long_t precision;
57 compat_long_t tolerance;
58 struct compat_timeval time;
60 compat_long_t ppsfreq;
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;
72 compat_int_t :32; compat_int_t :32; compat_int_t :32;
75 #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
78 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
81 extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
82 extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
85 compat_uptr_t iov_base;
86 compat_size_t iov_len;
89 struct compat_rlimit {
90 compat_ulong_t rlim_cur;
91 compat_ulong_t rlim_max;
94 struct compat_rusage {
95 struct compat_timeval ru_utime;
96 struct compat_timeval ru_stime;
97 compat_long_t ru_maxrss;
98 compat_long_t ru_ixrss;
99 compat_long_t ru_idrss;
100 compat_long_t ru_isrss;
101 compat_long_t ru_minflt;
102 compat_long_t ru_majflt;
103 compat_long_t ru_nswap;
104 compat_long_t ru_inblock;
105 compat_long_t ru_oublock;
106 compat_long_t ru_msgsnd;
107 compat_long_t ru_msgrcv;
108 compat_long_t ru_nsignals;
109 compat_long_t ru_nvcsw;
110 compat_long_t ru_nivcsw;
113 extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
115 struct compat_siginfo;
117 extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
118 struct compat_siginfo __user *, int,
119 struct compat_rusage __user *);
121 struct compat_dirent {
128 struct compat_ustat {
129 compat_daddr_t f_tfree;
130 compat_ino_t f_tinode;
135 typedef union compat_sigval {
136 compat_int_t sival_int;
137 compat_uptr_t sival_ptr;
140 #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
142 typedef struct compat_sigevent {
143 compat_sigval_t sigev_value;
144 compat_int_t sigev_signo;
145 compat_int_t sigev_notify;
147 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
151 compat_uptr_t _function;
152 compat_uptr_t _attribute;
157 struct compat_robust_list {
161 struct compat_robust_list_head {
162 struct compat_robust_list list;
163 compat_long_t futex_offset;
164 compat_uptr_t list_op_pending;
167 extern void compat_exit_robust_list(struct task_struct *curr);
170 compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
173 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
174 compat_size_t __user *len_ptr);
176 long compat_sys_semctl(int first, int second, int third, void __user *uptr);
177 long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
178 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
179 int version, void __user *uptr);
180 long compat_sys_msgctl(int first, int second, void __user *uptr);
181 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
183 long compat_sys_shmctl(int first, int second, void __user *uptr);
184 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
185 unsigned nsems, const struct compat_timespec __user *timeout);
186 asmlinkage long compat_sys_keyctl(u32 option,
187 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
188 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
190 asmlinkage ssize_t compat_sys_readv(unsigned long fd,
191 const struct compat_iovec __user *vec, unsigned long vlen);
192 asmlinkage ssize_t compat_sys_writev(unsigned long fd,
193 const struct compat_iovec __user *vec, unsigned long vlen);
194 asmlinkage ssize_t compat_sys_preadv(unsigned long fd,
195 const struct compat_iovec __user *vec,
196 unsigned long vlen, u32 pos_low, u32 pos_high);
197 asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
198 const struct compat_iovec __user *vec,
199 unsigned long vlen, u32 pos_low, u32 pos_high);
201 int compat_do_execve(char * filename, compat_uptr_t __user *argv,
202 compat_uptr_t __user *envp, struct pt_regs * regs);
204 asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
205 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
206 struct compat_timeval __user *tvp);
208 asmlinkage long compat_sys_wait4(compat_pid_t pid,
209 compat_uint_t __user *stat_addr, int options,
210 struct compat_rusage __user *ru);
212 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
214 #define BITS_TO_COMPAT_LONGS(bits) \
215 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
217 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
218 unsigned long bitmap_size);
219 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
220 unsigned long bitmap_size);
221 int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
222 int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
223 int get_compat_sigevent(struct sigevent *event,
224 const struct compat_sigevent __user *u_event);
226 static inline int compat_timeval_compare(struct compat_timeval *lhs,
227 struct compat_timeval *rhs)
229 if (lhs->tv_sec < rhs->tv_sec)
231 if (lhs->tv_sec > rhs->tv_sec)
233 return lhs->tv_usec - rhs->tv_usec;
236 static inline int compat_timespec_compare(struct compat_timespec *lhs,
237 struct compat_timespec *rhs)
239 if (lhs->tv_sec < rhs->tv_sec)
241 if (lhs->tv_sec > rhs->tv_sec)
243 return lhs->tv_nsec - rhs->tv_nsec;
246 extern int get_compat_itimerspec(struct itimerspec *dst,
247 const struct compat_itimerspec __user *src);
248 extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
249 const struct itimerspec *src);
251 asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
252 struct timezone __user *tz);
253 asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
254 struct timezone __user *tz);
256 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
258 extern int compat_printk(const char *fmt, ...);
259 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
261 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
262 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
263 const compat_ulong_t __user *new_nodes);
265 extern int compat_ptrace_request(struct task_struct *child,
266 compat_long_t request,
267 compat_ulong_t addr, compat_ulong_t data);
269 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
270 compat_ulong_t addr, compat_ulong_t data);
271 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
272 compat_long_t addr, compat_long_t data);
275 * epoll (fs/eventpoll.c) compat bits follow ...
278 #define compat_epoll_event epoll_event
279 asmlinkage long compat_sys_epoll_pwait(int epfd,
280 struct compat_epoll_event __user *events,
281 int maxevents, int timeout,
282 const compat_sigset_t __user *sigmask,
283 compat_size_t sigsetsize);
285 asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename,
286 struct compat_timespec __user *t, int flags);
288 asmlinkage long compat_sys_signalfd(int ufd,
289 const compat_sigset_t __user *sigmask,
290 compat_size_t sigsetsize);
291 asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
292 const struct compat_itimerspec __user *utmr,
293 struct compat_itimerspec __user *otmr);
294 asmlinkage long compat_sys_timerfd_gettime(int ufd,
295 struct compat_itimerspec __user *otmr);
297 asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
299 const int __user *nodes,
302 asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename,
303 struct compat_timeval __user *t);
304 asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
305 struct compat_stat __user *statbuf,
307 asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
308 int flags, int mode);
310 #endif /* CONFIG_COMPAT */
311 #endif /* _LINUX_COMPAT_H */