1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
2f08c3bdfSopenharmony_ci/*
3f08c3bdfSopenharmony_ci * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
4f08c3bdfSopenharmony_ci * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
5f08c3bdfSopenharmony_ci */
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ci#ifndef LAPI_PREADV2_H__
8f08c3bdfSopenharmony_ci#define LAPI_PREADV2_H__
9f08c3bdfSopenharmony_ci
10f08c3bdfSopenharmony_ci#include "config.h"
11f08c3bdfSopenharmony_ci#include "lapi/syscalls.h"
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_ci#ifndef RWF_NOWAIT
14f08c3bdfSopenharmony_ci# define RWF_NOWAIT 0x00000008
15f08c3bdfSopenharmony_ci#endif
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci#if !defined(HAVE_PREADV2)
18f08c3bdfSopenharmony_ci
19f08c3bdfSopenharmony_ci/* LO_HI_LONG taken from glibc */
20f08c3bdfSopenharmony_ci# define LO_HI_LONG(val) (long) (val), (long) (((uint64_t) (val)) >> 32)
21f08c3bdfSopenharmony_ci
22f08c3bdfSopenharmony_cistatic inline ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt,
23f08c3bdfSopenharmony_ci                              off_t offset, int flags)
24f08c3bdfSopenharmony_ci{
25f08c3bdfSopenharmony_ci	return tst_syscall(__NR_preadv2, fd, iov, iovcnt,
26f08c3bdfSopenharmony_ci			   LO_HI_LONG(offset), flags);
27f08c3bdfSopenharmony_ci}
28f08c3bdfSopenharmony_ci#endif
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_ci#endif /* LAPI_PREADV2_H__ */
31