xemu/linux-user/mips/target_fcntl.h
Aleksandar Markovic 1272a6c488 linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK
Bring target_flock definitions to be more in sync with the way
flock is defined in kernel.

Basically, the rules from the kernel are:

1. Majority of architectures have a common flock definition.

2. Architectures with 32-bit MIPS ABIs have a sligtly different
flock definition; those architectures are the only arcitectures
that have HAVE_ARCH_STRUCT_FLOCK defined, and that preprocessor
constant is used in the common header as a flag for including or
not including common flock definition.

3. Sparc architectures also have a sligtly different flock
definition, but the difference is only the padding at the end of
the structure. The presence of that padding is determined by
preprocessor constants __ARCH_FLOCK6_PAD and __ARCH_FLOCK64_PAD.

QEMU linux-user already implements rules 1. and 3. in a very
similar way as they are implemented in kernel. However, rule 2.
is implemented in a dissimilar way (for example, the constant
TARGET_HAVE_ARCH_STRUCT_FLOCK is missing), and this patch brings
QEMU implementation much closer to the kernel implementation.
TARGET_HAVE_ARCH_STRUCT_FLOCK64 constant is also introduced to
mimic HAVE_ARCH_STRUCT_FLOCK64 from kernel, but it is not defined
anywhere, however, this is the case with HAVE_ARCH_STRUCT_FLOCK64
in kernel as well.

Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <1561718618-20218-5-git-send-email-aleksandar.markovic@rt-rk.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2019-07-02 16:56:46 +02:00

52 lines
1.5 KiB
C

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation, or (at your option) any
* later version. See the COPYING file in the top-level directory.
*/
#ifndef MIPS_TARGET_FCNTL_H
#define MIPS_TARGET_FCNTL_H
#define TARGET_O_APPEND 0x0008
#define TARGET_O_DSYNC 0x0010
#define TARGET_O_NONBLOCK 0x0080
#define TARGET_O_CREAT 0x0100 /* not fcntl */
#define TARGET_O_TRUNC 0x0200 /* not fcntl */
#define TARGET_O_EXCL 0x0400 /* not fcntl */
#define TARGET_O_NOCTTY 0x0800 /* not fcntl */
#define TARGET_FASYNC 0x1000 /* fcntl, for BSD compatibility */
#define TARGET_O_LARGEFILE 0x2000 /* allow large file opens */
#define TARGET___O_SYNC 0x4000
#define TARGET_O_DIRECT 0x8000 /* direct disk access hint */
#define TARGET_F_GETLK 14
#define TARGET_F_SETLK 6
#define TARGET_F_SETLKW 7
#define TARGET_F_SETOWN 24 /* for sockets. */
#define TARGET_F_GETOWN 23 /* for sockets. */
#if (TARGET_ABI_BITS == 32)
struct target_flock {
short l_type;
short l_whence;
abi_long l_start;
abi_long l_len;
abi_long l_sysid;
int l_pid;
abi_long pad[4];
};
#define TARGET_HAVE_ARCH_STRUCT_FLOCK
#endif
#define TARGET_F_GETLK64 33 /* using 'struct flock64' */
#define TARGET_F_SETLK64 34
#define TARGET_F_SETLKW64 35
#include "../generic/fcntl.h"
#endif