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>
13 #include <linux/socket.h>
16 #include <asm/compat.h>
17 #include <asm/siginfo.h>
18 #include <asm/signal.h>
20 #define compat_jiffies_to_clock_t(x) \
21 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
23 typedef __compat_uid32_t compat_uid_t;
24 typedef __compat_gid32_t compat_gid_t;
28 struct compat_itimerspec {
29 struct compat_timespec it_interval;
30 struct compat_timespec it_value;
33 struct compat_utimbuf {
35 compat_time_t modtime;
38 struct compat_itimerval {
39 struct compat_timeval it_interval;
40 struct compat_timeval it_value;
44 compat_clock_t tms_utime;
45 compat_clock_t tms_stime;
46 compat_clock_t tms_cutime;
47 compat_clock_t tms_cstime;
54 compat_long_t maxerror;
55 compat_long_t esterror;
57 compat_long_t constant;
58 compat_long_t precision;
59 compat_long_t tolerance;
60 struct compat_timeval time;
62 compat_long_t ppsfreq;
72 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
73 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
74 compat_int_t :32; compat_int_t :32; compat_int_t :32;
77 #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
80 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
83 extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
84 extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
87 compat_uptr_t iov_base;
88 compat_size_t iov_len;
91 struct compat_rlimit {
92 compat_ulong_t rlim_cur;
93 compat_ulong_t rlim_max;
96 struct compat_rusage {
97 struct compat_timeval ru_utime;
98 struct compat_timeval ru_stime;
99 compat_long_t ru_maxrss;
100 compat_long_t ru_ixrss;
101 compat_long_t ru_idrss;
102 compat_long_t ru_isrss;
103 compat_long_t ru_minflt;
104 compat_long_t ru_majflt;
105 compat_long_t ru_nswap;
106 compat_long_t ru_inblock;
107 compat_long_t ru_oublock;
108 compat_long_t ru_msgsnd;
109 compat_long_t ru_msgrcv;
110 compat_long_t ru_nsignals;
111 compat_long_t ru_nvcsw;
112 compat_long_t ru_nivcsw;
115 extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
117 struct compat_siginfo;
119 extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
120 struct compat_siginfo __user *, int,
121 struct compat_rusage __user *);
123 struct compat_dirent {
130 struct compat_ustat {
131 compat_daddr_t f_tfree;
132 compat_ino_t f_tinode;
137 typedef union compat_sigval {
138 compat_int_t sival_int;
139 compat_uptr_t sival_ptr;
142 #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
144 typedef struct compat_sigevent {
145 compat_sigval_t sigev_value;
146 compat_int_t sigev_signo;
147 compat_int_t sigev_notify;
149 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
153 compat_uptr_t _function;
154 compat_uptr_t _attribute;
159 struct compat_ifmap {
160 compat_ulong_t mem_start;
161 compat_ulong_t mem_end;
162 unsigned short base_addr;
168 struct compat_if_settings
170 unsigned int type; /* Type of physical device or protocol */
171 unsigned int size; /* Size of the data allocated by the caller */
172 compat_uptr_t ifs_ifsu; /* union of pointers */
175 struct compat_ifreq {
177 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
180 struct sockaddr ifru_addr;
181 struct sockaddr ifru_dstaddr;
182 struct sockaddr ifru_broadaddr;
183 struct sockaddr ifru_netmask;
184 struct sockaddr ifru_hwaddr;
186 compat_int_t ifru_ivalue;
187 compat_int_t ifru_mtu;
188 struct compat_ifmap ifru_map;
189 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
190 char ifru_newname[IFNAMSIZ];
191 compat_caddr_t ifru_data;
192 struct compat_if_settings ifru_settings;
196 struct compat_ifconf {
197 compat_int_t ifc_len; /* size of buffer */
198 compat_caddr_t ifcbuf;
201 struct compat_robust_list {
205 struct compat_robust_list_head {
206 struct compat_robust_list list;
207 compat_long_t futex_offset;
208 compat_uptr_t list_op_pending;
211 extern void compat_exit_robust_list(struct task_struct *curr);
214 compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
217 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
218 compat_size_t __user *len_ptr);
220 long compat_sys_semctl(int first, int second, int third, void __user *uptr);
221 long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
222 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
223 int version, void __user *uptr);
224 long compat_sys_msgctl(int first, int second, void __user *uptr);
225 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
227 long compat_sys_shmctl(int first, int second, void __user *uptr);
228 long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
229 unsigned nsems, const struct compat_timespec __user *timeout);
230 asmlinkage long compat_sys_keyctl(u32 option,
231 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
232 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
234 asmlinkage ssize_t compat_sys_readv(unsigned long fd,
235 const struct compat_iovec __user *vec, unsigned long vlen);
236 asmlinkage ssize_t compat_sys_writev(unsigned long fd,
237 const struct compat_iovec __user *vec, unsigned long vlen);
238 asmlinkage ssize_t compat_sys_preadv(unsigned long fd,
239 const struct compat_iovec __user *vec,
240 unsigned long vlen, u32 pos_low, u32 pos_high);
241 asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
242 const struct compat_iovec __user *vec,
243 unsigned long vlen, u32 pos_low, u32 pos_high);
245 int compat_do_execve(char * filename, compat_uptr_t __user *argv,
246 compat_uptr_t __user *envp, struct pt_regs * regs);
248 asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
249 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
250 struct compat_timeval __user *tvp);
252 asmlinkage long compat_sys_wait4(compat_pid_t pid,
253 compat_uint_t __user *stat_addr, int options,
254 struct compat_rusage __user *ru);
256 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
258 #define BITS_TO_COMPAT_LONGS(bits) \
259 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
261 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
262 unsigned long bitmap_size);
263 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
264 unsigned long bitmap_size);
265 int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
266 int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
267 int get_compat_sigevent(struct sigevent *event,
268 const struct compat_sigevent __user *u_event);
269 long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
270 struct compat_siginfo __user *uinfo);
272 static inline int compat_timeval_compare(struct compat_timeval *lhs,
273 struct compat_timeval *rhs)
275 if (lhs->tv_sec < rhs->tv_sec)
277 if (lhs->tv_sec > rhs->tv_sec)
279 return lhs->tv_usec - rhs->tv_usec;
282 static inline int compat_timespec_compare(struct compat_timespec *lhs,
283 struct compat_timespec *rhs)
285 if (lhs->tv_sec < rhs->tv_sec)
287 if (lhs->tv_sec > rhs->tv_sec)
289 return lhs->tv_nsec - rhs->tv_nsec;
292 extern int get_compat_itimerspec(struct itimerspec *dst,
293 const struct compat_itimerspec __user *src);
294 extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
295 const struct itimerspec *src);
297 asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
298 struct timezone __user *tz);
299 asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
300 struct timezone __user *tz);
302 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
304 extern int compat_printk(const char *fmt, ...);
305 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
307 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
308 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
309 const compat_ulong_t __user *new_nodes);
311 extern int compat_ptrace_request(struct task_struct *child,
312 compat_long_t request,
313 compat_ulong_t addr, compat_ulong_t data);
315 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
316 compat_ulong_t addr, compat_ulong_t data);
317 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
318 compat_long_t addr, compat_long_t data);
321 * epoll (fs/eventpoll.c) compat bits follow ...
324 #define compat_epoll_event epoll_event
325 asmlinkage long compat_sys_epoll_pwait(int epfd,
326 struct compat_epoll_event __user *events,
327 int maxevents, int timeout,
328 const compat_sigset_t __user *sigmask,
329 compat_size_t sigsetsize);
331 asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename,
332 struct compat_timespec __user *t, int flags);
334 asmlinkage long compat_sys_signalfd(int ufd,
335 const compat_sigset_t __user *sigmask,
336 compat_size_t sigsetsize);
337 asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
338 const struct compat_itimerspec __user *utmr,
339 struct compat_itimerspec __user *otmr);
340 asmlinkage long compat_sys_timerfd_gettime(int ufd,
341 struct compat_itimerspec __user *otmr);
343 asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
345 const int __user *nodes,
348 asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename,
349 struct compat_timeval __user *t);
350 asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
351 struct compat_stat __user *statbuf,
353 asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
354 int flags, int mode);
356 #endif /* CONFIG_COMPAT */
357 #endif /* _LINUX_COMPAT_H */