Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_COMPAT_H |
| 2 | #define _ASM_COMPAT_H |
| 3 | /* |
| 4 | * Architecture specific compatibility types |
| 5 | */ |
| 6 | #include <linux/types.h> |
| 7 | #include <asm/page.h> |
Ralf Baechle | b723782 | 2006-12-11 00:43:58 +0000 | [diff] [blame] | 8 | #include <asm/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | #define COMPAT_USER_HZ 100 |
| 11 | |
| 12 | typedef u32 compat_size_t; |
| 13 | typedef s32 compat_ssize_t; |
| 14 | typedef s32 compat_time_t; |
| 15 | typedef s32 compat_clock_t; |
| 16 | typedef s32 compat_suseconds_t; |
| 17 | |
| 18 | typedef s32 compat_pid_t; |
Ralf Baechle | 4ee1303 | 2005-10-29 19:32:40 +0100 | [diff] [blame] | 19 | typedef s32 __compat_uid_t; |
| 20 | typedef s32 __compat_gid_t; |
| 21 | typedef __compat_uid_t __compat_uid32_t; |
| 22 | typedef __compat_gid_t __compat_gid32_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | typedef u32 compat_mode_t; |
| 24 | typedef u32 compat_ino_t; |
| 25 | typedef u32 compat_dev_t; |
| 26 | typedef s32 compat_off_t; |
| 27 | typedef s64 compat_loff_t; |
| 28 | typedef u32 compat_nlink_t; |
| 29 | typedef s32 compat_ipc_pid_t; |
| 30 | typedef s32 compat_daddr_t; |
| 31 | typedef s32 compat_caddr_t; |
| 32 | typedef struct { |
| 33 | s32 val[2]; |
| 34 | } compat_fsid_t; |
Stephen Rothwell | 0d77e5a | 2005-06-23 00:10:14 -0700 | [diff] [blame] | 35 | typedef s32 compat_timer_t; |
Atsushi Nemoto | 05e4396 | 2006-11-07 18:02:44 +0900 | [diff] [blame] | 36 | typedef s32 compat_key_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | typedef s32 compat_int_t; |
| 39 | typedef s32 compat_long_t; |
Arnd Bergmann | 4b77758 | 2007-07-15 23:41:11 -0700 | [diff] [blame] | 40 | typedef s64 compat_s64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | typedef u32 compat_uint_t; |
| 42 | typedef u32 compat_ulong_t; |
Arnd Bergmann | 4b77758 | 2007-07-15 23:41:11 -0700 | [diff] [blame] | 43 | typedef u64 compat_u64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | struct compat_timespec { |
| 46 | compat_time_t tv_sec; |
| 47 | s32 tv_nsec; |
| 48 | }; |
| 49 | |
| 50 | struct compat_timeval { |
| 51 | compat_time_t tv_sec; |
| 52 | s32 tv_usec; |
| 53 | }; |
| 54 | |
| 55 | struct compat_stat { |
| 56 | compat_dev_t st_dev; |
| 57 | s32 st_pad1[3]; |
| 58 | compat_ino_t st_ino; |
| 59 | compat_mode_t st_mode; |
| 60 | compat_nlink_t st_nlink; |
Ralf Baechle | 4ee1303 | 2005-10-29 19:32:40 +0100 | [diff] [blame] | 61 | __compat_uid_t st_uid; |
| 62 | __compat_gid_t st_gid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | compat_dev_t st_rdev; |
| 64 | s32 st_pad2[2]; |
| 65 | compat_off_t st_size; |
| 66 | s32 st_pad3; |
| 67 | compat_time_t st_atime; |
| 68 | s32 st_atime_nsec; |
| 69 | compat_time_t st_mtime; |
| 70 | s32 st_mtime_nsec; |
| 71 | compat_time_t st_ctime; |
| 72 | s32 st_ctime_nsec; |
| 73 | s32 st_blksize; |
| 74 | s32 st_blocks; |
| 75 | s32 st_pad4[14]; |
| 76 | }; |
| 77 | |
| 78 | struct compat_flock { |
| 79 | short l_type; |
| 80 | short l_whence; |
| 81 | compat_off_t l_start; |
| 82 | compat_off_t l_len; |
| 83 | s32 l_sysid; |
| 84 | compat_pid_t l_pid; |
| 85 | short __unused; |
| 86 | s32 pad[4]; |
| 87 | }; |
| 88 | |
| 89 | #define F_GETLK64 33 |
| 90 | #define F_SETLK64 34 |
| 91 | #define F_SETLKW64 35 |
| 92 | |
| 93 | struct compat_flock64 { |
| 94 | short l_type; |
| 95 | short l_whence; |
| 96 | compat_loff_t l_start; |
| 97 | compat_loff_t l_len; |
| 98 | compat_pid_t l_pid; |
| 99 | }; |
| 100 | |
| 101 | struct compat_statfs { |
| 102 | int f_type; |
| 103 | int f_bsize; |
| 104 | int f_frsize; |
| 105 | int f_blocks; |
| 106 | int f_bfree; |
| 107 | int f_files; |
| 108 | int f_ffree; |
| 109 | int f_bavail; |
| 110 | compat_fsid_t f_fsid; |
| 111 | int f_namelen; |
| 112 | int f_spare[6]; |
| 113 | }; |
| 114 | |
| 115 | #define COMPAT_RLIM_INFINITY 0x7fffffffUL |
| 116 | |
| 117 | typedef u32 compat_old_sigset_t; /* at least 32 bits */ |
| 118 | |
| 119 | #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */ |
| 120 | #define _COMPAT_NSIG_BPW 32 |
| 121 | |
| 122 | typedef u32 compat_sigset_word; |
| 123 | |
| 124 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 125 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL |
| 126 | |
| 127 | /* |
| 128 | * A pointer passed in from user mode. This should not |
| 129 | * be used for syscall parameters, just declare them |
| 130 | * as pointers because the syscall entry code will have |
| 131 | * appropriately comverted them already. |
| 132 | */ |
| 133 | typedef u32 compat_uptr_t; |
| 134 | |
Atsushi Nemoto | 219ac73 | 2006-02-21 16:05:11 +0900 | [diff] [blame] | 135 | static inline void __user *compat_ptr(compat_uptr_t uptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | { |
Atsushi Nemoto | 01bebc6 | 2007-07-13 23:51:38 +0900 | [diff] [blame] | 137 | /* cast to a __user pointer via "unsigned long" makes sparse happy */ |
| 138 | return (void __user *)(unsigned long)(long)uptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Ingo Molnar | 62ac285 | 2006-03-27 01:16:13 -0800 | [diff] [blame] | 141 | static inline compat_uptr_t ptr_to_compat(void __user *uptr) |
| 142 | { |
| 143 | return (u32)(unsigned long)uptr; |
| 144 | } |
| 145 | |
Atsushi Nemoto | 219ac73 | 2006-02-21 16:05:11 +0900 | [diff] [blame] | 146 | static inline void __user *compat_alloc_user_space(long len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
| 148 | struct pt_regs *regs = (struct pt_regs *) |
| 149 | ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1; |
| 150 | |
Atsushi Nemoto | 219ac73 | 2006-02-21 16:05:11 +0900 | [diff] [blame] | 151 | return (void __user *) (regs->regs[29] - len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Atsushi Nemoto | 05e4396 | 2006-11-07 18:02:44 +0900 | [diff] [blame] | 154 | struct compat_ipc64_perm { |
| 155 | compat_key_t key; |
| 156 | __compat_uid32_t uid; |
| 157 | __compat_gid32_t gid; |
| 158 | __compat_uid32_t cuid; |
| 159 | __compat_gid32_t cgid; |
| 160 | compat_mode_t mode; |
| 161 | unsigned short seq; |
| 162 | unsigned short __pad2; |
| 163 | compat_ulong_t __unused1; |
| 164 | compat_ulong_t __unused2; |
| 165 | }; |
| 166 | |
| 167 | struct compat_semid64_ds { |
| 168 | struct compat_ipc64_perm sem_perm; |
| 169 | compat_time_t sem_otime; |
| 170 | compat_time_t sem_ctime; |
| 171 | compat_ulong_t sem_nsems; |
| 172 | compat_ulong_t __unused1; |
| 173 | compat_ulong_t __unused2; |
| 174 | }; |
| 175 | |
| 176 | struct compat_msqid64_ds { |
| 177 | struct compat_ipc64_perm msg_perm; |
| 178 | #ifndef CONFIG_CPU_LITTLE_ENDIAN |
| 179 | compat_ulong_t __unused1; |
| 180 | #endif |
| 181 | compat_time_t msg_stime; |
| 182 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 183 | compat_ulong_t __unused1; |
| 184 | #endif |
| 185 | #ifndef CONFIG_CPU_LITTLE_ENDIAN |
| 186 | compat_ulong_t __unused2; |
| 187 | #endif |
| 188 | compat_time_t msg_rtime; |
| 189 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 190 | compat_ulong_t __unused2; |
| 191 | #endif |
| 192 | #ifndef CONFIG_CPU_LITTLE_ENDIAN |
| 193 | compat_ulong_t __unused3; |
| 194 | #endif |
| 195 | compat_time_t msg_ctime; |
| 196 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 197 | compat_ulong_t __unused3; |
| 198 | #endif |
| 199 | compat_ulong_t msg_cbytes; |
| 200 | compat_ulong_t msg_qnum; |
| 201 | compat_ulong_t msg_qbytes; |
| 202 | compat_pid_t msg_lspid; |
| 203 | compat_pid_t msg_lrpid; |
| 204 | compat_ulong_t __unused4; |
| 205 | compat_ulong_t __unused5; |
| 206 | }; |
| 207 | |
| 208 | struct compat_shmid64_ds { |
| 209 | struct compat_ipc64_perm shm_perm; |
| 210 | compat_size_t shm_segsz; |
| 211 | compat_time_t shm_atime; |
| 212 | compat_time_t shm_dtime; |
| 213 | compat_time_t shm_ctime; |
| 214 | compat_pid_t shm_cpid; |
| 215 | compat_pid_t shm_lpid; |
| 216 | compat_ulong_t shm_nattch; |
| 217 | compat_ulong_t __unused1; |
| 218 | compat_ulong_t __unused2; |
| 219 | }; |
| 220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | #endif /* _ASM_COMPAT_H */ |