162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_SPARC64_COMPAT_H
362306a36Sopenharmony_ci#define _ASM_SPARC64_COMPAT_H
462306a36Sopenharmony_ci/*
562306a36Sopenharmony_ci * Architecture specific compatibility types
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#include <linux/types.h>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#define compat_mode_t	compat_mode_t
1062306a36Sopenharmony_citypedef u16		compat_mode_t;
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#define __compat_uid_t	__compat_uid_t
1362306a36Sopenharmony_citypedef u16		__compat_uid_t;
1462306a36Sopenharmony_citypedef u16		__compat_gid_t;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define compat_dev_t	compat_dev_t
1762306a36Sopenharmony_citypedef u16		compat_dev_t;
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define compat_ipc_pid_t compat_ipc_pid_t
2062306a36Sopenharmony_citypedef u16		 compat_ipc_pid_t;
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define compat_ipc64_perm compat_ipc64_perm
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define COMPAT_RLIM_INFINITY 0x7fffffff
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#include <asm-generic/compat.h>
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#define COMPAT_UTS_MACHINE	"sparc\0\0"
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_citypedef s16		compat_nlink_t;
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_cistruct compat_stat {
3362306a36Sopenharmony_ci	compat_dev_t	st_dev;
3462306a36Sopenharmony_ci	compat_ino_t	st_ino;
3562306a36Sopenharmony_ci	compat_mode_t	st_mode;
3662306a36Sopenharmony_ci	compat_nlink_t	st_nlink;
3762306a36Sopenharmony_ci	__compat_uid_t	st_uid;
3862306a36Sopenharmony_ci	__compat_gid_t	st_gid;
3962306a36Sopenharmony_ci	compat_dev_t	st_rdev;
4062306a36Sopenharmony_ci	compat_off_t	st_size;
4162306a36Sopenharmony_ci	old_time32_t	st_atime;
4262306a36Sopenharmony_ci	compat_ulong_t	st_atime_nsec;
4362306a36Sopenharmony_ci	old_time32_t	st_mtime;
4462306a36Sopenharmony_ci	compat_ulong_t	st_mtime_nsec;
4562306a36Sopenharmony_ci	old_time32_t	st_ctime;
4662306a36Sopenharmony_ci	compat_ulong_t	st_ctime_nsec;
4762306a36Sopenharmony_ci	compat_off_t	st_blksize;
4862306a36Sopenharmony_ci	compat_off_t	st_blocks;
4962306a36Sopenharmony_ci	u32		__unused4[2];
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistruct compat_stat64 {
5362306a36Sopenharmony_ci	unsigned long long	st_dev;
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	unsigned long long	st_ino;
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci	unsigned int	st_mode;
5862306a36Sopenharmony_ci	unsigned int	st_nlink;
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci	unsigned int	st_uid;
6162306a36Sopenharmony_ci	unsigned int	st_gid;
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci	unsigned long long	st_rdev;
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	unsigned char	__pad3[8];
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	long long	st_size;
6862306a36Sopenharmony_ci	unsigned int	st_blksize;
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci	unsigned char	__pad4[8];
7162306a36Sopenharmony_ci	unsigned int	st_blocks;
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci	unsigned int	st_atime;
7462306a36Sopenharmony_ci	unsigned int	st_atime_nsec;
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci	unsigned int	st_mtime;
7762306a36Sopenharmony_ci	unsigned int	st_mtime_nsec;
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	unsigned int	st_ctime;
8062306a36Sopenharmony_ci	unsigned int	st_ctime_nsec;
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci	unsigned int	__unused4;
8362306a36Sopenharmony_ci	unsigned int	__unused5;
8462306a36Sopenharmony_ci};
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#define __ARCH_COMPAT_FLOCK_PAD		short __unused;
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistruct compat_ipc64_perm {
8962306a36Sopenharmony_ci	compat_key_t key;
9062306a36Sopenharmony_ci	__compat_uid32_t uid;
9162306a36Sopenharmony_ci	__compat_gid32_t gid;
9262306a36Sopenharmony_ci	__compat_uid32_t cuid;
9362306a36Sopenharmony_ci	__compat_gid32_t cgid;
9462306a36Sopenharmony_ci	unsigned short __pad1;
9562306a36Sopenharmony_ci	compat_mode_t mode;
9662306a36Sopenharmony_ci	unsigned short __pad2;
9762306a36Sopenharmony_ci	unsigned short seq;
9862306a36Sopenharmony_ci	unsigned long __unused1;	/* yes they really are 64bit pads */
9962306a36Sopenharmony_ci	unsigned long __unused2;
10062306a36Sopenharmony_ci};
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_cistruct compat_semid64_ds {
10362306a36Sopenharmony_ci	struct compat_ipc64_perm sem_perm;
10462306a36Sopenharmony_ci	unsigned int	sem_otime_high;
10562306a36Sopenharmony_ci	unsigned int	sem_otime;
10662306a36Sopenharmony_ci	unsigned int	sem_ctime_high;
10762306a36Sopenharmony_ci	unsigned int	sem_ctime;
10862306a36Sopenharmony_ci	u32		sem_nsems;
10962306a36Sopenharmony_ci	u32		__unused1;
11062306a36Sopenharmony_ci	u32		__unused2;
11162306a36Sopenharmony_ci};
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_cistruct compat_msqid64_ds {
11462306a36Sopenharmony_ci	struct compat_ipc64_perm msg_perm;
11562306a36Sopenharmony_ci	unsigned int	msg_stime_high;
11662306a36Sopenharmony_ci	unsigned int	msg_stime;
11762306a36Sopenharmony_ci	unsigned int	msg_rtime_high;
11862306a36Sopenharmony_ci	unsigned int	msg_rtime;
11962306a36Sopenharmony_ci	unsigned int	msg_ctime_high;
12062306a36Sopenharmony_ci	unsigned int	msg_ctime;
12162306a36Sopenharmony_ci	unsigned int	msg_cbytes;
12262306a36Sopenharmony_ci	unsigned int	msg_qnum;
12362306a36Sopenharmony_ci	unsigned int	msg_qbytes;
12462306a36Sopenharmony_ci	compat_pid_t	msg_lspid;
12562306a36Sopenharmony_ci	compat_pid_t	msg_lrpid;
12662306a36Sopenharmony_ci	unsigned int	__unused1;
12762306a36Sopenharmony_ci	unsigned int	__unused2;
12862306a36Sopenharmony_ci};
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_cistruct compat_shmid64_ds {
13162306a36Sopenharmony_ci	struct compat_ipc64_perm shm_perm;
13262306a36Sopenharmony_ci	unsigned int	shm_atime_high;
13362306a36Sopenharmony_ci	unsigned int	shm_atime;
13462306a36Sopenharmony_ci	unsigned int	shm_dtime_high;
13562306a36Sopenharmony_ci	unsigned int	shm_dtime;
13662306a36Sopenharmony_ci	unsigned int	shm_ctime_high;
13762306a36Sopenharmony_ci	unsigned int	shm_ctime;
13862306a36Sopenharmony_ci	compat_size_t	shm_segsz;
13962306a36Sopenharmony_ci	compat_pid_t	shm_cpid;
14062306a36Sopenharmony_ci	compat_pid_t	shm_lpid;
14162306a36Sopenharmony_ci	unsigned int	shm_nattch;
14262306a36Sopenharmony_ci	unsigned int	__unused1;
14362306a36Sopenharmony_ci	unsigned int	__unused2;
14462306a36Sopenharmony_ci};
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#ifdef CONFIG_COMPAT
14762306a36Sopenharmony_cistatic inline int is_compat_task(void)
14862306a36Sopenharmony_ci{
14962306a36Sopenharmony_ci	return test_thread_flag(TIF_32BIT);
15062306a36Sopenharmony_ci}
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_cistatic inline bool in_compat_syscall(void)
15362306a36Sopenharmony_ci{
15462306a36Sopenharmony_ci	/* Vector 0x110 is LINUX_32BIT_SYSCALL_TRAP */
15562306a36Sopenharmony_ci	return pt_regs_trap_type(current_pt_regs()) == 0x110;
15662306a36Sopenharmony_ci}
15762306a36Sopenharmony_ci#define in_compat_syscall in_compat_syscall
15862306a36Sopenharmony_ci#endif
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci#endif /* _ASM_SPARC64_COMPAT_H */
161