Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_64_COMPAT_H |
| 2 | #define _ASM_X86_64_COMPAT_H |
| 3 | |
| 4 | /* |
| 5 | * Architecture specific compatibility types |
| 6 | */ |
| 7 | #include <linux/types.h> |
| 8 | #include <linux/sched.h> |
| 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_pid_t; |
Stephen Rothwell | 202e597 | 2005-09-06 15:16:40 -0700 | [diff] [blame] | 17 | typedef u16 __compat_uid_t; |
| 18 | typedef u16 __compat_gid_t; |
| 19 | typedef u32 __compat_uid32_t; |
| 20 | typedef u32 __compat_gid32_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | typedef u16 compat_mode_t; |
| 22 | typedef u32 compat_ino_t; |
| 23 | typedef u16 compat_dev_t; |
| 24 | typedef s32 compat_off_t; |
| 25 | typedef s64 compat_loff_t; |
| 26 | typedef u16 compat_nlink_t; |
| 27 | typedef u16 compat_ipc_pid_t; |
| 28 | typedef s32 compat_daddr_t; |
| 29 | typedef u32 compat_caddr_t; |
| 30 | typedef __kernel_fsid_t compat_fsid_t; |
| 31 | typedef s32 compat_timer_t; |
| 32 | typedef s32 compat_key_t; |
| 33 | |
| 34 | typedef s32 compat_int_t; |
| 35 | typedef s32 compat_long_t; |
Arnd Bergmann | 4b77758 | 2007-07-15 23:41:11 -0700 | [diff] [blame] | 36 | typedef s64 __attribute__((aligned(4))) compat_s64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | typedef u32 compat_uint_t; |
| 38 | typedef u32 compat_ulong_t; |
Arnd Bergmann | 4b77758 | 2007-07-15 23:41:11 -0700 | [diff] [blame] | 39 | typedef u64 __attribute__((aligned(4))) compat_u64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | struct compat_timespec { |
| 42 | compat_time_t tv_sec; |
| 43 | s32 tv_nsec; |
| 44 | }; |
| 45 | |
| 46 | struct compat_timeval { |
| 47 | compat_time_t tv_sec; |
| 48 | s32 tv_usec; |
| 49 | }; |
| 50 | |
| 51 | struct compat_stat { |
| 52 | compat_dev_t st_dev; |
| 53 | u16 __pad1; |
| 54 | compat_ino_t st_ino; |
| 55 | compat_mode_t st_mode; |
| 56 | compat_nlink_t st_nlink; |
Stephen Rothwell | 202e597 | 2005-09-06 15:16:40 -0700 | [diff] [blame] | 57 | __compat_uid_t st_uid; |
| 58 | __compat_gid_t st_gid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | compat_dev_t st_rdev; |
| 60 | u16 __pad2; |
| 61 | u32 st_size; |
| 62 | u32 st_blksize; |
| 63 | u32 st_blocks; |
| 64 | u32 st_atime; |
| 65 | u32 st_atime_nsec; |
| 66 | u32 st_mtime; |
| 67 | u32 st_mtime_nsec; |
| 68 | u32 st_ctime; |
| 69 | u32 st_ctime_nsec; |
| 70 | u32 __unused4; |
| 71 | u32 __unused5; |
| 72 | }; |
| 73 | |
| 74 | struct compat_flock { |
| 75 | short l_type; |
| 76 | short l_whence; |
| 77 | compat_off_t l_start; |
| 78 | compat_off_t l_len; |
| 79 | compat_pid_t l_pid; |
| 80 | }; |
| 81 | |
| 82 | #define F_GETLK64 12 /* using 'struct flock64' */ |
| 83 | #define F_SETLK64 13 |
| 84 | #define F_SETLKW64 14 |
| 85 | |
| 86 | /* |
| 87 | * IA32 uses 4 byte alignment for 64 bit quantities, |
| 88 | * so we need to pack this structure. |
| 89 | */ |
| 90 | struct compat_flock64 { |
| 91 | short l_type; |
| 92 | short l_whence; |
| 93 | compat_loff_t l_start; |
| 94 | compat_loff_t l_len; |
| 95 | compat_pid_t l_pid; |
| 96 | } __attribute__((packed)); |
| 97 | |
| 98 | struct compat_statfs { |
| 99 | int f_type; |
| 100 | int f_bsize; |
| 101 | int f_blocks; |
| 102 | int f_bfree; |
| 103 | int f_bavail; |
| 104 | int f_files; |
| 105 | int f_ffree; |
| 106 | compat_fsid_t f_fsid; |
| 107 | int f_namelen; /* SunOS ignores this field. */ |
| 108 | int f_frsize; |
| 109 | int f_spare[5]; |
| 110 | }; |
| 111 | |
| 112 | #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff |
| 113 | #define COMPAT_RLIM_INFINITY 0xffffffff |
| 114 | |
| 115 | typedef u32 compat_old_sigset_t; /* at least 32 bits */ |
| 116 | |
| 117 | #define _COMPAT_NSIG 64 |
| 118 | #define _COMPAT_NSIG_BPW 32 |
| 119 | |
| 120 | typedef u32 compat_sigset_word; |
| 121 | |
| 122 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 123 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL |
| 124 | |
| 125 | struct compat_ipc64_perm { |
| 126 | compat_key_t key; |
Stephen Rothwell | 202e597 | 2005-09-06 15:16:40 -0700 | [diff] [blame] | 127 | __compat_uid32_t uid; |
| 128 | __compat_gid32_t gid; |
| 129 | __compat_uid32_t cuid; |
| 130 | __compat_gid32_t cgid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | unsigned short mode; |
| 132 | unsigned short __pad1; |
| 133 | unsigned short seq; |
| 134 | unsigned short __pad2; |
| 135 | compat_ulong_t unused1; |
| 136 | compat_ulong_t unused2; |
| 137 | }; |
| 138 | |
| 139 | struct compat_semid64_ds { |
| 140 | struct compat_ipc64_perm sem_perm; |
| 141 | compat_time_t sem_otime; |
| 142 | compat_ulong_t __unused1; |
| 143 | compat_time_t sem_ctime; |
| 144 | compat_ulong_t __unused2; |
| 145 | compat_ulong_t sem_nsems; |
| 146 | compat_ulong_t __unused3; |
| 147 | compat_ulong_t __unused4; |
| 148 | }; |
| 149 | |
| 150 | struct compat_msqid64_ds { |
| 151 | struct compat_ipc64_perm msg_perm; |
| 152 | compat_time_t msg_stime; |
| 153 | compat_ulong_t __unused1; |
| 154 | compat_time_t msg_rtime; |
| 155 | compat_ulong_t __unused2; |
| 156 | compat_time_t msg_ctime; |
| 157 | compat_ulong_t __unused3; |
| 158 | compat_ulong_t msg_cbytes; |
| 159 | compat_ulong_t msg_qnum; |
| 160 | compat_ulong_t msg_qbytes; |
| 161 | compat_pid_t msg_lspid; |
| 162 | compat_pid_t msg_lrpid; |
| 163 | compat_ulong_t __unused4; |
| 164 | compat_ulong_t __unused5; |
| 165 | }; |
| 166 | |
| 167 | struct compat_shmid64_ds { |
| 168 | struct compat_ipc64_perm shm_perm; |
| 169 | compat_size_t shm_segsz; |
| 170 | compat_time_t shm_atime; |
| 171 | compat_ulong_t __unused1; |
| 172 | compat_time_t shm_dtime; |
| 173 | compat_ulong_t __unused2; |
| 174 | compat_time_t shm_ctime; |
| 175 | compat_ulong_t __unused3; |
| 176 | compat_pid_t shm_cpid; |
| 177 | compat_pid_t shm_lpid; |
| 178 | compat_ulong_t shm_nattch; |
| 179 | compat_ulong_t __unused4; |
| 180 | compat_ulong_t __unused5; |
| 181 | }; |
| 182 | |
| 183 | /* |
| 184 | * A pointer passed in from user mode. This should not |
| 185 | * be used for syscall parameters, just declare them |
| 186 | * as pointers because the syscall entry code will have |
| 187 | * appropriately comverted them already. |
| 188 | */ |
| 189 | typedef u32 compat_uptr_t; |
| 190 | |
| 191 | static inline void __user *compat_ptr(compat_uptr_t uptr) |
| 192 | { |
| 193 | return (void __user *)(unsigned long)uptr; |
| 194 | } |
| 195 | |
| 196 | static inline compat_uptr_t ptr_to_compat(void __user *uptr) |
| 197 | { |
| 198 | return (u32)(unsigned long)uptr; |
| 199 | } |
| 200 | |
| 201 | static __inline__ void __user *compat_alloc_user_space(long len) |
| 202 | { |
Al Viro | bb04923 | 2006-01-12 01:05:38 -0800 | [diff] [blame] | 203 | struct pt_regs *regs = task_pt_regs(current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | return (void __user *)regs->rsp - len; |
| 205 | } |
| 206 | |
Andi Kleen | bf2fcc6 | 2006-01-11 22:44:06 +0100 | [diff] [blame] | 207 | static inline int is_compat_task(void) |
| 208 | { |
| 209 | return current_thread_info()->status & TS_COMPAT; |
| 210 | } |
| 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | #endif /* _ASM_X86_64_COMPAT_H */ |