compat.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. #ifndef _ASM_SPARC64_COMPAT_H
  2. #define _ASM_SPARC64_COMPAT_H
  3. /*
  4. * Architecture specific compatibility types
  5. */
  6. #include <linux/types.h>
  7. #define COMPAT_USER_HZ 100
  8. #define COMPAT_UTS_MACHINE "sparc\0\0"
  9. typedef u32 compat_size_t;
  10. typedef s32 compat_ssize_t;
  11. typedef s32 compat_time_t;
  12. typedef s32 compat_clock_t;
  13. typedef s32 compat_pid_t;
  14. typedef u16 __compat_uid_t;
  15. typedef u16 __compat_gid_t;
  16. typedef u32 __compat_uid32_t;
  17. typedef u32 __compat_gid32_t;
  18. typedef u16 compat_mode_t;
  19. typedef u32 compat_ino_t;
  20. typedef u16 compat_dev_t;
  21. typedef s32 compat_off_t;
  22. typedef s64 compat_loff_t;
  23. typedef s16 compat_nlink_t;
  24. typedef u16 compat_ipc_pid_t;
  25. typedef s32 compat_daddr_t;
  26. typedef u32 compat_caddr_t;
  27. typedef __kernel_fsid_t compat_fsid_t;
  28. typedef s32 compat_key_t;
  29. typedef s32 compat_timer_t;
  30. typedef s32 compat_int_t;
  31. typedef s32 compat_long_t;
  32. typedef s64 compat_s64;
  33. typedef u32 compat_uint_t;
  34. typedef u32 compat_ulong_t;
  35. typedef u64 compat_u64;
  36. typedef u32 compat_uptr_t;
  37. struct compat_timespec {
  38. compat_time_t tv_sec;
  39. s32 tv_nsec;
  40. };
  41. struct compat_timeval {
  42. compat_time_t tv_sec;
  43. s32 tv_usec;
  44. };
  45. struct compat_stat {
  46. compat_dev_t st_dev;
  47. compat_ino_t st_ino;
  48. compat_mode_t st_mode;
  49. compat_nlink_t st_nlink;
  50. __compat_uid_t st_uid;
  51. __compat_gid_t st_gid;
  52. compat_dev_t st_rdev;
  53. compat_off_t st_size;
  54. compat_time_t st_atime;
  55. compat_ulong_t st_atime_nsec;
  56. compat_time_t st_mtime;
  57. compat_ulong_t st_mtime_nsec;
  58. compat_time_t st_ctime;
  59. compat_ulong_t st_ctime_nsec;
  60. compat_off_t st_blksize;
  61. compat_off_t st_blocks;
  62. u32 __unused4[2];
  63. };
  64. struct compat_stat64 {
  65. unsigned long long st_dev;
  66. unsigned long long st_ino;
  67. unsigned int st_mode;
  68. unsigned int st_nlink;
  69. unsigned int st_uid;
  70. unsigned int st_gid;
  71. unsigned long long st_rdev;
  72. unsigned char __pad3[8];
  73. long long st_size;
  74. unsigned int st_blksize;
  75. unsigned char __pad4[8];
  76. unsigned int st_blocks;
  77. unsigned int st_atime;
  78. unsigned int st_atime_nsec;
  79. unsigned int st_mtime;
  80. unsigned int st_mtime_nsec;
  81. unsigned int st_ctime;
  82. unsigned int st_ctime_nsec;
  83. unsigned int __unused4;
  84. unsigned int __unused5;
  85. };
  86. struct compat_flock {
  87. short l_type;
  88. short l_whence;
  89. compat_off_t l_start;
  90. compat_off_t l_len;
  91. compat_pid_t l_pid;
  92. short __unused;
  93. };
  94. #define F_GETLK64 12
  95. #define F_SETLK64 13
  96. #define F_SETLKW64 14
  97. struct compat_flock64 {
  98. short l_type;
  99. short l_whence;
  100. compat_loff_t l_start;
  101. compat_loff_t l_len;
  102. compat_pid_t l_pid;
  103. short __unused;
  104. };
  105. struct compat_statfs {
  106. int f_type;
  107. int f_bsize;
  108. int f_blocks;
  109. int f_bfree;
  110. int f_bavail;
  111. int f_files;
  112. int f_ffree;
  113. compat_fsid_t f_fsid;
  114. int f_namelen; /* SunOS ignores this field. */
  115. int f_frsize;
  116. int f_flags;
  117. int f_spare[4];
  118. };
  119. #define COMPAT_RLIM_INFINITY 0x7fffffff
  120. typedef u32 compat_old_sigset_t;
  121. #define _COMPAT_NSIG 64
  122. #define _COMPAT_NSIG_BPW 32
  123. typedef u32 compat_sigset_word;
  124. typedef union compat_sigval {
  125. compat_int_t sival_int;
  126. compat_uptr_t sival_ptr;
  127. } compat_sigval_t;
  128. #define SI_PAD_SIZE32 (128/sizeof(int) - 3)
  129. typedef struct compat_siginfo {
  130. int si_signo;
  131. int si_errno;
  132. int si_code;
  133. union {
  134. int _pad[SI_PAD_SIZE32];
  135. /* kill() */
  136. struct {
  137. compat_pid_t _pid; /* sender's pid */
  138. unsigned int _uid; /* sender's uid */
  139. } _kill;
  140. /* POSIX.1b timers */
  141. struct {
  142. compat_timer_t _tid; /* timer id */
  143. int _overrun; /* overrun count */
  144. compat_sigval_t _sigval; /* same as below */
  145. int _sys_private; /* not to be passed to user */
  146. } _timer;
  147. /* POSIX.1b signals */
  148. struct {
  149. compat_pid_t _pid; /* sender's pid */
  150. unsigned int _uid; /* sender's uid */
  151. compat_sigval_t _sigval;
  152. } _rt;
  153. /* SIGCHLD */
  154. struct {
  155. compat_pid_t _pid; /* which child */
  156. unsigned int _uid; /* sender's uid */
  157. int _status; /* exit code */
  158. compat_clock_t _utime;
  159. compat_clock_t _stime;
  160. } _sigchld;
  161. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
  162. struct {
  163. u32 _addr; /* faulting insn/memory ref. */
  164. int _trapno;
  165. } _sigfault;
  166. /* SIGPOLL */
  167. struct {
  168. int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  169. int _fd;
  170. } _sigpoll;
  171. } _sifields;
  172. } compat_siginfo_t;
  173. #define COMPAT_OFF_T_MAX 0x7fffffff
  174. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  175. /*
  176. * A pointer passed in from user mode. This should not
  177. * be used for syscall parameters, just declare them
  178. * as pointers because the syscall entry code will have
  179. * appropriately converted them already.
  180. */
  181. static inline void __user *compat_ptr(compat_uptr_t uptr)
  182. {
  183. return (void __user *)(unsigned long)uptr;
  184. }
  185. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  186. {
  187. return (u32)(unsigned long)uptr;
  188. }
  189. static inline void __user *arch_compat_alloc_user_space(long len)
  190. {
  191. struct pt_regs *regs = current_thread_info()->kregs;
  192. unsigned long usp = regs->u_regs[UREG_I6];
  193. if (test_thread_64bit_stack(usp))
  194. usp += STACK_BIAS;
  195. if (test_thread_flag(TIF_32BIT))
  196. usp &= 0xffffffffUL;
  197. usp -= len;
  198. usp &= ~0x7UL;
  199. return (void __user *) usp;
  200. }
  201. struct compat_ipc64_perm {
  202. compat_key_t key;
  203. __compat_uid32_t uid;
  204. __compat_gid32_t gid;
  205. __compat_uid32_t cuid;
  206. __compat_gid32_t cgid;
  207. unsigned short __pad1;
  208. compat_mode_t mode;
  209. unsigned short __pad2;
  210. unsigned short seq;
  211. unsigned long __unused1; /* yes they really are 64bit pads */
  212. unsigned long __unused2;
  213. };
  214. struct compat_semid64_ds {
  215. struct compat_ipc64_perm sem_perm;
  216. unsigned int __pad1;
  217. compat_time_t sem_otime;
  218. unsigned int __pad2;
  219. compat_time_t sem_ctime;
  220. u32 sem_nsems;
  221. u32 __unused1;
  222. u32 __unused2;
  223. };
  224. struct compat_msqid64_ds {
  225. struct compat_ipc64_perm msg_perm;
  226. unsigned int __pad1;
  227. compat_time_t msg_stime;
  228. unsigned int __pad2;
  229. compat_time_t msg_rtime;
  230. unsigned int __pad3;
  231. compat_time_t msg_ctime;
  232. unsigned int msg_cbytes;
  233. unsigned int msg_qnum;
  234. unsigned int msg_qbytes;
  235. compat_pid_t msg_lspid;
  236. compat_pid_t msg_lrpid;
  237. unsigned int __unused1;
  238. unsigned int __unused2;
  239. };
  240. struct compat_shmid64_ds {
  241. struct compat_ipc64_perm shm_perm;
  242. unsigned int __pad1;
  243. compat_time_t shm_atime;
  244. unsigned int __pad2;
  245. compat_time_t shm_dtime;
  246. unsigned int __pad3;
  247. compat_time_t shm_ctime;
  248. compat_size_t shm_segsz;
  249. compat_pid_t shm_cpid;
  250. compat_pid_t shm_lpid;
  251. unsigned int shm_nattch;
  252. unsigned int __unused1;
  253. unsigned int __unused2;
  254. };
  255. static inline int is_compat_task(void)
  256. {
  257. return test_thread_flag(TIF_32BIT);
  258. }
  259. #endif /* _ASM_SPARC64_COMPAT_H */