blob: 9760753e662b4f735583034b17a1e0ed5c24dc07 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
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>
16
17#define compat_jiffies_to_clock_t(x) \
18 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
19
Stephen Rothwell202e5972005-09-06 15:16:40 -070020typedef __compat_uid32_t compat_uid_t;
21typedef __compat_gid32_t compat_gid_t;
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023struct rusage;
24
25struct compat_itimerspec {
26 struct compat_timespec it_interval;
27 struct compat_timespec it_value;
28};
29
30struct compat_utimbuf {
31 compat_time_t actime;
32 compat_time_t modtime;
33};
34
35struct compat_itimerval {
36 struct compat_timeval it_interval;
37 struct compat_timeval it_value;
38};
39
40struct compat_tms {
41 compat_clock_t tms_utime;
42 compat_clock_t tms_stime;
43 compat_clock_t tms_cutime;
44 compat_clock_t tms_cstime;
45};
46
Stephen Rothwell88959ea2006-03-26 01:37:27 -080047struct compat_timex {
48 compat_uint_t modes;
49 compat_long_t offset;
50 compat_long_t freq;
51 compat_long_t maxerror;
52 compat_long_t esterror;
53 compat_int_t status;
54 compat_long_t constant;
55 compat_long_t precision;
56 compat_long_t tolerance;
57 struct compat_timeval time;
58 compat_long_t tick;
59 compat_long_t ppsfreq;
60 compat_long_t jitter;
61 compat_int_t shift;
62 compat_long_t stabil;
63 compat_long_t jitcnt;
64 compat_long_t calcnt;
65 compat_long_t errcnt;
66 compat_long_t stbcnt;
67
68 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
69 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
70 compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
71};
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
74
75typedef struct {
76 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
77} compat_sigset_t;
78
79extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
80extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
81extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
82
83struct compat_iovec {
84 compat_uptr_t iov_base;
85 compat_size_t iov_len;
86};
87
88struct compat_rlimit {
89 compat_ulong_t rlim_cur;
90 compat_ulong_t rlim_max;
91};
92
93struct compat_rusage {
94 struct compat_timeval ru_utime;
95 struct compat_timeval ru_stime;
96 compat_long_t ru_maxrss;
97 compat_long_t ru_ixrss;
98 compat_long_t ru_idrss;
99 compat_long_t ru_isrss;
100 compat_long_t ru_minflt;
101 compat_long_t ru_majflt;
102 compat_long_t ru_nswap;
103 compat_long_t ru_inblock;
104 compat_long_t ru_oublock;
105 compat_long_t ru_msgsnd;
106 compat_long_t ru_msgrcv;
107 compat_long_t ru_nsignals;
108 compat_long_t ru_nvcsw;
109 compat_long_t ru_nivcsw;
110};
111
112extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
113
114struct compat_siginfo;
115
116extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
117 struct compat_siginfo __user *, int,
118 struct compat_rusage __user *);
119
120struct compat_dirent {
121 u32 d_ino;
122 compat_off_t d_off;
123 u16 d_reclen;
124 char d_name[256];
125};
126
127typedef union compat_sigval {
128 compat_int_t sival_int;
129 compat_uptr_t sival_ptr;
130} compat_sigval_t;
131
132#define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
133
134typedef struct compat_sigevent {
135 compat_sigval_t sigev_value;
136 compat_int_t sigev_signo;
137 compat_int_t sigev_notify;
138 union {
139 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
140 compat_int_t _tid;
141
142 struct {
143 compat_uptr_t _function;
144 compat_uptr_t _attribute;
145 } _sigev_thread;
146 } _sigev_un;
147} compat_sigevent_t;
148
Ingo Molnar34f192c2006-03-27 01:16:24 -0800149struct compat_robust_list {
150 compat_uptr_t next;
151};
152
153struct compat_robust_list_head {
154 struct compat_robust_list list;
155 compat_long_t futex_offset;
156 compat_uptr_t list_op_pending;
157};
158
159extern void compat_exit_robust_list(struct task_struct *curr);
160
161asmlinkage long
162compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
163 compat_size_t len);
164asmlinkage long
165compat_sys_get_robust_list(int pid, compat_uptr_t *head_ptr,
166 compat_size_t __user *len_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168long compat_sys_semctl(int first, int second, int third, void __user *uptr);
169long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
170long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
171 int version, void __user *uptr);
172long compat_sys_msgctl(int first, int second, void __user *uptr);
173long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
174 void __user *uptr);
175long compat_sys_shmctl(int first, int second, void __user *uptr);
176long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
177 unsigned nsems, const struct compat_timespec __user *timeout);
178asmlinkage long compat_sys_keyctl(u32 option,
179 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
180
181asmlinkage ssize_t compat_sys_readv(unsigned long fd,
182 const struct compat_iovec __user *vec, unsigned long vlen);
183asmlinkage ssize_t compat_sys_writev(unsigned long fd,
184 const struct compat_iovec __user *vec, unsigned long vlen);
185
186int compat_do_execve(char * filename, compat_uptr_t __user *argv,
187 compat_uptr_t __user *envp, struct pt_regs * regs);
188
189asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
190 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
191 struct compat_timeval __user *tvp);
192
193#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
194
195#define BITS_TO_COMPAT_LONGS(bits) \
196 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
197
198long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask,
199 unsigned long bitmap_size);
200long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
201 unsigned long bitmap_size);
202int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
203int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
204int get_compat_sigevent(struct sigevent *event,
205 const struct compat_sigevent __user *u_event);
206
Andrew Morton643a6542006-02-11 17:55:52 -0800207static inline int compat_timeval_compare(struct compat_timeval *lhs,
208 struct compat_timeval *rhs)
209{
210 if (lhs->tv_sec < rhs->tv_sec)
211 return -1;
212 if (lhs->tv_sec > rhs->tv_sec)
213 return 1;
214 return lhs->tv_usec - rhs->tv_usec;
215}
216
217static inline int compat_timespec_compare(struct compat_timespec *lhs,
218 struct compat_timespec *rhs)
219{
220 if (lhs->tv_sec < rhs->tv_sec)
221 return -1;
222 if (lhs->tv_sec > rhs->tv_sec)
223 return 1;
224 return lhs->tv_nsec - rhs->tv_nsec;
225}
226
Stephen Rothwell3158e942006-03-26 01:37:29 -0800227asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
228
Andi Kleenbebfa102006-06-26 13:56:52 +0200229extern int compat_printk(const char *fmt, ...);
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231#endif /* CONFIG_COMPAT */
232#endif /* _LINUX_COMPAT_H */