compat.h 5.0 KB

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