compat.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 ARM Ltd.
  4. */
  5. #ifndef __ASM_COMPAT_H
  6. #define __ASM_COMPAT_H
  7. #define compat_mode_t compat_mode_t
  8. typedef u16 compat_mode_t;
  9. #define __compat_uid_t __compat_uid_t
  10. typedef u16 __compat_uid_t;
  11. typedef u16 __compat_gid_t;
  12. #define compat_ipc_pid_t compat_ipc_pid_t
  13. typedef u16 compat_ipc_pid_t;
  14. #define compat_statfs compat_statfs
  15. #include <asm-generic/compat.h>
  16. #ifdef CONFIG_COMPAT
  17. /*
  18. * Architecture specific compatibility types
  19. */
  20. #include <linux/types.h>
  21. #include <linux/sched.h>
  22. #include <linux/sched/task_stack.h>
  23. #ifdef __AARCH64EB__
  24. #define COMPAT_UTS_MACHINE "armv8b\0\0"
  25. #else
  26. #define COMPAT_UTS_MACHINE "armv8l\0\0"
  27. #endif
  28. typedef u16 __compat_uid16_t;
  29. typedef u16 __compat_gid16_t;
  30. typedef s32 compat_nlink_t;
  31. struct compat_stat {
  32. #ifdef __AARCH64EB__
  33. short st_dev;
  34. short __pad1;
  35. #else
  36. compat_dev_t st_dev;
  37. #endif
  38. compat_ino_t st_ino;
  39. compat_mode_t st_mode;
  40. compat_ushort_t st_nlink;
  41. __compat_uid16_t st_uid;
  42. __compat_gid16_t st_gid;
  43. #ifdef __AARCH64EB__
  44. short st_rdev;
  45. short __pad2;
  46. #else
  47. compat_dev_t st_rdev;
  48. #endif
  49. compat_off_t st_size;
  50. compat_off_t st_blksize;
  51. compat_off_t st_blocks;
  52. old_time32_t st_atime;
  53. compat_ulong_t st_atime_nsec;
  54. old_time32_t st_mtime;
  55. compat_ulong_t st_mtime_nsec;
  56. old_time32_t st_ctime;
  57. compat_ulong_t st_ctime_nsec;
  58. compat_ulong_t __unused4[2];
  59. };
  60. struct compat_statfs {
  61. int f_type;
  62. int f_bsize;
  63. int f_blocks;
  64. int f_bfree;
  65. int f_bavail;
  66. int f_files;
  67. int f_ffree;
  68. compat_fsid_t f_fsid;
  69. int f_namelen; /* SunOS ignores this field. */
  70. int f_frsize;
  71. int f_flags;
  72. int f_spare[4];
  73. };
  74. #define COMPAT_RLIM_INFINITY 0xffffffff
  75. #define COMPAT_OFF_T_MAX 0x7fffffff
  76. #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
  77. #define COMPAT_MINSIGSTKSZ 2048
  78. static inline int is_compat_task(void)
  79. {
  80. return test_thread_flag(TIF_32BIT);
  81. }
  82. static inline int is_compat_thread(struct thread_info *thread)
  83. {
  84. return test_ti_thread_flag(thread, TIF_32BIT);
  85. }
  86. #else /* !CONFIG_COMPAT */
  87. static inline int is_compat_thread(struct thread_info *thread)
  88. {
  89. return 0;
  90. }
  91. #endif /* CONFIG_COMPAT */
  92. #endif /* __ASM_COMPAT_H */