compat.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. #ifndef _LINUX_COMPAT_H
  2. #define _LINUX_COMPAT_H
  3. /*
  4. * These are the type definitions for the architecture specific
  5. * syscall compatibility layer.
  6. */
  7. #ifdef CONFIG_COMPAT
  8. #include <linux/stat.h>
  9. #include <linux/param.h> /* for HZ */
  10. #include <linux/sem.h>
  11. #include <asm/compat.h>
  12. #include <asm/siginfo.h>
  13. #define compat_jiffies_to_clock_t(x) \
  14. (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
  15. typedef __compat_uid32_t compat_uid_t;
  16. typedef __compat_gid32_t compat_gid_t;
  17. struct rusage;
  18. struct compat_itimerspec {
  19. struct compat_timespec it_interval;
  20. struct compat_timespec it_value;
  21. };
  22. struct compat_utimbuf {
  23. compat_time_t actime;
  24. compat_time_t modtime;
  25. };
  26. struct compat_itimerval {
  27. struct compat_timeval it_interval;
  28. struct compat_timeval it_value;
  29. };
  30. struct compat_tms {
  31. compat_clock_t tms_utime;
  32. compat_clock_t tms_stime;
  33. compat_clock_t tms_cutime;
  34. compat_clock_t tms_cstime;
  35. };
  36. struct compat_timex {
  37. compat_uint_t modes;
  38. compat_long_t offset;
  39. compat_long_t freq;
  40. compat_long_t maxerror;
  41. compat_long_t esterror;
  42. compat_int_t status;
  43. compat_long_t constant;
  44. compat_long_t precision;
  45. compat_long_t tolerance;
  46. struct compat_timeval time;
  47. compat_long_t tick;
  48. compat_long_t ppsfreq;
  49. compat_long_t jitter;
  50. compat_int_t shift;
  51. compat_long_t stabil;
  52. compat_long_t jitcnt;
  53. compat_long_t calcnt;
  54. compat_long_t errcnt;
  55. compat_long_t stbcnt;
  56. compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  57. compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  58. compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
  59. };
  60. #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
  61. typedef struct {
  62. compat_sigset_word sig[_COMPAT_NSIG_WORDS];
  63. } compat_sigset_t;
  64. extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
  65. extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
  66. extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
  67. struct compat_iovec {
  68. compat_uptr_t iov_base;
  69. compat_size_t iov_len;
  70. };
  71. struct compat_rlimit {
  72. compat_ulong_t rlim_cur;
  73. compat_ulong_t rlim_max;
  74. };
  75. struct compat_rusage {
  76. struct compat_timeval ru_utime;
  77. struct compat_timeval ru_stime;
  78. compat_long_t ru_maxrss;
  79. compat_long_t ru_ixrss;
  80. compat_long_t ru_idrss;
  81. compat_long_t ru_isrss;
  82. compat_long_t ru_minflt;
  83. compat_long_t ru_majflt;
  84. compat_long_t ru_nswap;
  85. compat_long_t ru_inblock;
  86. compat_long_t ru_oublock;
  87. compat_long_t ru_msgsnd;
  88. compat_long_t ru_msgrcv;
  89. compat_long_t ru_nsignals;
  90. compat_long_t ru_nvcsw;
  91. compat_long_t ru_nivcsw;
  92. };
  93. extern int put_compat_rusage(const struct rusage *, struct compat_rusage __user *);
  94. struct compat_siginfo;
  95. extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
  96. struct compat_siginfo __user *, int,
  97. struct compat_rusage __user *);
  98. struct compat_dirent {
  99. u32 d_ino;
  100. compat_off_t d_off;
  101. u16 d_reclen;
  102. char d_name[256];
  103. };
  104. typedef union compat_sigval {
  105. compat_int_t sival_int;
  106. compat_uptr_t sival_ptr;
  107. } compat_sigval_t;
  108. #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
  109. typedef struct compat_sigevent {
  110. compat_sigval_t sigev_value;
  111. compat_int_t sigev_signo;
  112. compat_int_t sigev_notify;
  113. union {
  114. compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
  115. compat_int_t _tid;
  116. struct {
  117. compat_uptr_t _function;
  118. compat_uptr_t _attribute;
  119. } _sigev_thread;
  120. } _sigev_un;
  121. } compat_sigevent_t;
  122. struct compat_robust_list {
  123. compat_uptr_t next;
  124. };
  125. struct compat_robust_list_head {
  126. struct compat_robust_list list;
  127. compat_long_t futex_offset;
  128. compat_uptr_t list_op_pending;
  129. };
  130. extern void compat_exit_robust_list(struct task_struct *curr);
  131. asmlinkage long
  132. compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
  133. compat_size_t len);
  134. asmlinkage long
  135. compat_sys_get_robust_list(int pid, compat_uptr_t *head_ptr,
  136. compat_size_t __user *len_ptr);
  137. long compat_sys_semctl(int first, int second, int third, void __user *uptr);
  138. long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
  139. long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
  140. int version, void __user *uptr);
  141. long compat_sys_msgctl(int first, int second, void __user *uptr);
  142. long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
  143. void __user *uptr);
  144. long compat_sys_shmctl(int first, int second, void __user *uptr);
  145. long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
  146. unsigned nsems, const struct compat_timespec __user *timeout);
  147. asmlinkage long compat_sys_keyctl(u32 option,
  148. u32 arg2, u32 arg3, u32 arg4, u32 arg5);
  149. asmlinkage ssize_t compat_sys_readv(unsigned long fd,
  150. const struct compat_iovec __user *vec, unsigned long vlen);
  151. asmlinkage ssize_t compat_sys_writev(unsigned long fd,
  152. const struct compat_iovec __user *vec, unsigned long vlen);
  153. int compat_do_execve(char * filename, compat_uptr_t __user *argv,
  154. compat_uptr_t __user *envp, struct pt_regs * regs);
  155. asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
  156. compat_ulong_t __user *outp, compat_ulong_t __user *exp,
  157. struct compat_timeval __user *tvp);
  158. #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
  159. #define BITS_TO_COMPAT_LONGS(bits) \
  160. (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
  161. long compat_get_bitmap(unsigned long *mask, compat_ulong_t __user *umask,
  162. unsigned long bitmap_size);
  163. long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
  164. unsigned long bitmap_size);
  165. int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
  166. int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
  167. int get_compat_sigevent(struct sigevent *event,
  168. const struct compat_sigevent __user *u_event);
  169. static inline int compat_timeval_compare(struct compat_timeval *lhs,
  170. struct compat_timeval *rhs)
  171. {
  172. if (lhs->tv_sec < rhs->tv_sec)
  173. return -1;
  174. if (lhs->tv_sec > rhs->tv_sec)
  175. return 1;
  176. return lhs->tv_usec - rhs->tv_usec;
  177. }
  178. static inline int compat_timespec_compare(struct compat_timespec *lhs,
  179. struct compat_timespec *rhs)
  180. {
  181. if (lhs->tv_sec < rhs->tv_sec)
  182. return -1;
  183. if (lhs->tv_sec > rhs->tv_sec)
  184. return 1;
  185. return lhs->tv_nsec - rhs->tv_nsec;
  186. }
  187. asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
  188. extern int compat_printk(const char *fmt, ...);
  189. #endif /* CONFIG_COMPAT */
  190. #endif /* _LINUX_COMPAT_H */