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