162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
262306a36Sopenharmony_ci#ifndef __ASM_GENERIC_SEMBUF_H
362306a36Sopenharmony_ci#define __ASM_GENERIC_SEMBUF_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <asm/bitsperlong.h>
662306a36Sopenharmony_ci#include <asm/ipcbuf.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci/*
962306a36Sopenharmony_ci * The semid64_ds structure for most architectures (though it came from x86_32
1062306a36Sopenharmony_ci * originally). Note extra padding because this structure is passed back and
1162306a36Sopenharmony_ci * forth between kernel and user space.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * semid64_ds was originally meant to be architecture specific, but
1462306a36Sopenharmony_ci * everyone just ended up making identical copies without specific
1562306a36Sopenharmony_ci * optimizations, so we may just as well all use the same one.
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci * 64 bit architectures use a 64-bit long time field here, while
1862306a36Sopenharmony_ci * 32 bit architectures have a pair of unsigned long values.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * On big-endian systems, the padding is in the wrong place for
2162306a36Sopenharmony_ci * historic reasons, so user space has to reconstruct a time_t
2262306a36Sopenharmony_ci * value using
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * user_semid_ds.sem_otime = kernel_semid64_ds.sem_otime +
2562306a36Sopenharmony_ci *		((long long)kernel_semid64_ds.sem_otime_high << 32)
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * Pad space is left for 2 miscellaneous 32-bit values
2862306a36Sopenharmony_ci */
2962306a36Sopenharmony_cistruct semid64_ds {
3062306a36Sopenharmony_ci	struct ipc64_perm sem_perm;	/* permissions .. see ipc.h */
3162306a36Sopenharmony_ci#if __BITS_PER_LONG == 64
3262306a36Sopenharmony_ci	long		sem_otime;	/* last semop time */
3362306a36Sopenharmony_ci	long		sem_ctime;	/* last change time */
3462306a36Sopenharmony_ci#else
3562306a36Sopenharmony_ci	unsigned long	sem_otime;	/* last semop time */
3662306a36Sopenharmony_ci	unsigned long	sem_otime_high;
3762306a36Sopenharmony_ci	unsigned long	sem_ctime;	/* last change time */
3862306a36Sopenharmony_ci	unsigned long	sem_ctime_high;
3962306a36Sopenharmony_ci#endif
4062306a36Sopenharmony_ci	unsigned long	sem_nsems;	/* no. of semaphores in array */
4162306a36Sopenharmony_ci	unsigned long	__unused3;
4262306a36Sopenharmony_ci	unsigned long	__unused4;
4362306a36Sopenharmony_ci};
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#endif /* __ASM_GENERIC_SEMBUF_H */
46