Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
| 7 | #include <linux/config.h> |
| 8 | |
| 9 | #ifdef CONFIG_COMPAT |
| 10 | |
| 11 | #include <linux/stat.h> |
| 12 | #include <linux/param.h> /* for HZ */ |
| 13 | #include <linux/sem.h> |
| 14 | |
| 15 | #include <asm/compat.h> |
| 16 | #include <asm/siginfo.h> |
| 17 | |
| 18 | #define compat_jiffies_to_clock_t(x) \ |
| 19 | (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) |
| 20 | |
Stephen Rothwell | 202e597 | 2005-09-06 15:16:40 -0700 | [diff] [blame] | 21 | typedef __compat_uid32_t compat_uid_t; |
| 22 | typedef __compat_gid32_t compat_gid_t; |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 48 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) |
| 49 | |
| 50 | typedef struct { |
| 51 | compat_sigset_word sig[_COMPAT_NSIG_WORDS]; |
| 52 | } compat_sigset_t; |
| 53 | |
| 54 | extern int cp_compat_stat(struct kstat *, struct compat_stat __user *); |
| 55 | extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); |
| 56 | extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); |
| 57 | |
| 58 | struct compat_iovec { |
| 59 | compat_uptr_t iov_base; |
| 60 | compat_size_t iov_len; |
| 61 | }; |
| 62 | |
| 63 | struct compat_rlimit { |
| 64 | compat_ulong_t rlim_cur; |
| 65 | compat_ulong_t rlim_max; |
| 66 | }; |
| 67 | |
| 68 | struct compat_rusage { |
| 69 | struct compat_timeval ru_utime; |
| 70 | struct compat_timeval ru_stime; |
| 71 | compat_long_t ru_maxrss; |
| 72 | compat_long_t ru_ixrss; |
| 73 | compat_long_t ru_idrss; |
| 74 | compat_long_t ru_isrss; |
| 75 | compat_long_t ru_minflt; |
| 76 | compat_long_t ru_majflt; |
| 77 | compat_long_t ru_nswap; |
| 78 | compat_long_t ru_inblock; |
| 79 | compat_long_t ru_oublock; |
| 80 | compat_long_t ru_msgsnd; |
| 81 | compat_long_t ru_msgrcv; |
| 82 | compat_long_t ru_nsignals; |
| 83 | compat_long_t ru_nvcsw; |
| 84 | compat_long_t ru_nivcsw; |
| 85 | }; |
| 86 | |
| 87 | extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *); |
| 88 | |
| 89 | struct compat_siginfo; |
| 90 | |
| 91 | extern asmlinkage long compat_sys_waitid(int, compat_pid_t, |
| 92 | struct compat_siginfo __user *, int, |
| 93 | struct compat_rusage __user *); |
| 94 | |
| 95 | struct compat_dirent { |
| 96 | u32 d_ino; |
| 97 | compat_off_t d_off; |
| 98 | u16 d_reclen; |
| 99 | char d_name[256]; |
| 100 | }; |
| 101 | |
| 102 | typedef union compat_sigval { |
| 103 | compat_int_t sival_int; |
| 104 | compat_uptr_t sival_ptr; |
| 105 | } compat_sigval_t; |
| 106 | |
| 107 | #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) |
| 108 | |
| 109 | typedef struct compat_sigevent { |
| 110 | compat_sigval_t sigev_value; |
| 111 | compat_int_t sigev_signo; |
| 112 | compat_int_t sigev_notify; |
| 113 | union { |
| 114 | compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE]; |
| 115 | compat_int_t _tid; |
| 116 | |
| 117 | struct { |
| 118 | compat_uptr_t _function; |
| 119 | compat_uptr_t _attribute; |
| 120 | } _sigev_thread; |
| 121 | } _sigev_un; |
| 122 | } compat_sigevent_t; |
| 123 | |
| 124 | |
| 125 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); |
| 126 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); |
| 127 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, |
| 128 | int version, void __user *uptr); |
| 129 | long compat_sys_msgctl(int first, int second, void __user *uptr); |
| 130 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, |
| 131 | void __user *uptr); |
| 132 | long compat_sys_shmctl(int first, int second, void __user *uptr); |
| 133 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, |
| 134 | unsigned nsems, const struct compat_timespec __user *timeout); |
| 135 | asmlinkage long compat_sys_keyctl(u32 option, |
| 136 | u32 arg2, u32 arg3, u32 arg4, u32 arg5); |
| 137 | |
| 138 | asmlinkage ssize_t compat_sys_readv(unsigned long fd, |
| 139 | const struct compat_iovec __user *vec, unsigned long vlen); |
| 140 | asmlinkage ssize_t compat_sys_writev(unsigned long fd, |
| 141 | const struct compat_iovec __user *vec, unsigned long vlen); |
| 142 | |
| 143 | int compat_do_execve(char * filename, compat_uptr_t __user *argv, |
| 144 | compat_uptr_t __user *envp, struct pt_regs * regs); |
| 145 | |
| 146 | asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, |
| 147 | compat_ulong_t __user *outp, compat_ulong_t __user *exp, |
| 148 | struct compat_timeval __user *tvp); |
| 149 | |
| 150 | #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) |
| 151 | |
| 152 | #define BITS_TO_COMPAT_LONGS(bits) \ |
| 153 | (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG) |
| 154 | |
| 155 | long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask, |
| 156 | unsigned long bitmap_size); |
| 157 | long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, |
| 158 | unsigned long bitmap_size); |
| 159 | int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from); |
| 160 | int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from); |
| 161 | int get_compat_sigevent(struct sigevent *event, |
| 162 | const struct compat_sigevent __user *u_event); |
| 163 | |
| 164 | #endif /* CONFIG_COMPAT */ |
| 165 | #endif /* _LINUX_COMPAT_H */ |