compat.h 4.7 KB

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