compat.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. struct compat_timespec {
  37. compat_time_t tv_sec;
  38. s32 tv_nsec;
  39. };
  40. struct compat_timeval {
  41. compat_time_t tv_sec;
  42. s32 tv_usec;
  43. };
  44. struct compat_stat {
  45. compat_dev_t st_dev;
  46. compat_ino_t st_ino;
  47. compat_mode_t st_mode;
  48. compat_nlink_t st_nlink;
  49. __compat_uid_t st_uid;
  50. __compat_gid_t st_gid;
  51. compat_dev_t st_rdev;
  52. compat_off_t st_size;
  53. compat_time_t st_atime;
  54. compat_ulong_t st_atime_nsec;
  55. compat_time_t st_mtime;
  56. compat_ulong_t st_mtime_nsec;
  57. compat_time_t st_ctime;
  58. compat_ulong_t st_ctime_nsec;
  59. compat_off_t st_blksize;
  60. compat_off_t st_blocks;
  61. u32 __unused4[2];
  62. };
  63. struct compat_stat64 {
  64. unsigned long long st_dev;
  65. unsigned long long st_ino;
  66. unsigned int st_mode;
  67. unsigned int st_nlink;
  68. unsigned int st_uid;
  69. unsigned int st_gid;
  70. unsigned long long st_rdev;
  71. unsigned char __pad3[8];
  72. long long st_size;
  73. unsigned int st_blksize;
  74. unsigned char __pad4[8];
  75. unsigned int st_blocks;
  76. unsigned int st_atime;
  77. unsigned int st_atime_nsec;
  78. unsigned int st_mtime;
  79. unsigned int st_mtime_nsec;
  80. unsigned int st_ctime;
  81. unsigned int st_ctime_nsec;
  82. unsigned int __unused4;
  83. unsigned int __unused5;
  84. };
  85. struct compat_flock {
  86. short l_type;
  87. short l_whence;
  88. compat_off_t l_start;
  89. compat_off_t l_len;
  90. compat_pid_t l_pid;
  91. short __unused;
  92. };
  93. #define F_GETLK64 12
  94. #define F_SETLK64 13
  95. #define F_SETLKW64 14
  96. struct compat_flock64 {
  97. short l_type;
  98. short l_whence;
  99. compat_loff_t l_start;
  100. compat_loff_t l_len;
  101. compat_pid_t l_pid;
  102. short __unused;
  103. };
  104. struct compat_statfs {
  105. int f_type;
  106. int f_bsize;
  107. int f_blocks;
  108. int f_bfree;
  109. int f_bavail;
  110. int f_files;
  111. int f_ffree;
  112. compat_fsid_t f_fsid;
  113. int f_namelen; /* SunOS ignores this field. */
  114. int f_frsize;
  115. int f_spare[5];
  116. };
  117. #define COMPAT_RLIM_INFINITY 0x7fffffff
  118. typedef u32 compat_old_sigset_t;
  119. #define _COMPAT_NSIG 64
  120. #define _COMPAT_NSIG_BPW 32
  121. typedef u32 compat_sigset_word;
  122. #define COMPAT_OFF_T_MAX 0x7fffffff
  123. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  124. /*
  125. * A pointer passed in from user mode. This should not
  126. * be used for syscall parameters, just declare them
  127. * as pointers because the syscall entry code will have
  128. * appropriately converted them already.
  129. */
  130. typedef u32 compat_uptr_t;
  131. static inline void __user *compat_ptr(compat_uptr_t uptr)
  132. {
  133. return (void __user *)(unsigned long)uptr;
  134. }
  135. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  136. {
  137. return (u32)(unsigned long)uptr;
  138. }
  139. static inline void __user *arch_compat_alloc_user_space(long len)
  140. {
  141. struct pt_regs *regs = current_thread_info()->kregs;
  142. unsigned long usp = regs->u_regs[UREG_I6];
  143. if (!(test_thread_flag(TIF_32BIT)))
  144. usp += STACK_BIAS;
  145. else
  146. usp &= 0xffffffffUL;
  147. usp -= len;
  148. usp &= ~0x7UL;
  149. return (void __user *) usp;
  150. }
  151. struct compat_ipc64_perm {
  152. compat_key_t key;
  153. __compat_uid32_t uid;
  154. __compat_gid32_t gid;
  155. __compat_uid32_t cuid;
  156. __compat_gid32_t cgid;
  157. unsigned short __pad1;
  158. compat_mode_t mode;
  159. unsigned short __pad2;
  160. unsigned short seq;
  161. unsigned long __unused1; /* yes they really are 64bit pads */
  162. unsigned long __unused2;
  163. };
  164. struct compat_semid64_ds {
  165. struct compat_ipc64_perm sem_perm;
  166. unsigned int __pad1;
  167. compat_time_t sem_otime;
  168. unsigned int __pad2;
  169. compat_time_t sem_ctime;
  170. u32 sem_nsems;
  171. u32 __unused1;
  172. u32 __unused2;
  173. };
  174. struct compat_msqid64_ds {
  175. struct compat_ipc64_perm msg_perm;
  176. unsigned int __pad1;
  177. compat_time_t msg_stime;
  178. unsigned int __pad2;
  179. compat_time_t msg_rtime;
  180. unsigned int __pad3;
  181. compat_time_t msg_ctime;
  182. unsigned int msg_cbytes;
  183. unsigned int msg_qnum;
  184. unsigned int msg_qbytes;
  185. compat_pid_t msg_lspid;
  186. compat_pid_t msg_lrpid;
  187. unsigned int __unused1;
  188. unsigned int __unused2;
  189. };
  190. struct compat_shmid64_ds {
  191. struct compat_ipc64_perm shm_perm;
  192. unsigned int __pad1;
  193. compat_time_t shm_atime;
  194. unsigned int __pad2;
  195. compat_time_t shm_dtime;
  196. unsigned int __pad3;
  197. compat_time_t shm_ctime;
  198. compat_size_t shm_segsz;
  199. compat_pid_t shm_cpid;
  200. compat_pid_t shm_lpid;
  201. unsigned int shm_nattch;
  202. unsigned int __unused1;
  203. unsigned int __unused2;
  204. };
  205. static inline int is_compat_task(void)
  206. {
  207. return test_thread_flag(TIF_32BIT);
  208. }
  209. #endif /* _ASM_SPARC64_COMPAT_H */