summaryrefslogtreecommitdiffstats
path: root/kernel/tests/include/lapi/sync_file_range.h
blob: 86bfe5d6ece10166f0146361fe0b2196ed40b102 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) International Business Machines  Corp., 2008
 */

#ifndef SYNC_FILE_RANGE_H
#define SYNC_FILE_RANGE_H

#include <sys/types.h>
#include "config.h"
#include "lapi/syscalls.h"
#include "lapi/abisize.h"

#if !defined(HAVE_SYNC_FILE_RANGE)

#ifdef TST_TEST_H__
# define TST_SYSCALL tst_syscall
#else
# define TST_SYSCALL ltp_syscall
#endif

/*****************************************************************************
 * Wraper function to call sync_file_range system call
 ******************************************************************************/
static inline long sync_file_range(int fd, off64_t offset, off64_t nbytes,
				   unsigned int flags)
{
#if (defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__))
# ifdef TST_ABI32
#  if __BYTE_ORDER == __BIG_ENDIAN
	return TST_SYSCALL(__NR_sync_file_range2, fd, flags,
		(int)(offset >> 32), (int)offset, (int)(nbytes >> 32),
		(int)nbytes);
#  elif __BYTE_ORDER == __LITTLE_ENDIAN
	return TST_SYSCALL(__NR_sync_file_range2, fd, flags, (int)offset,
		       (int)(offset >> 32), nbytes, (int)(nbytes >> 32));
#  endif
# else
	return TST_SYSCALL(__NR_sync_file_range2, fd, flags, offset, nbytes);
# endif
#elif (defined(__s390__) || defined(__s390x__)) && defined(TST_ABI32)
	return TST_SYSCALL(__NR_sync_file_range, fd, (int)(offset >> 32),
		(int)offset, (int)(nbytes >> 32), (int)nbytes, flags);
#elif defined(__mips__) && defined(TST_ABI32)
# if __BYTE_ORDER == __BIG_ENDIAN
	return TST_SYSCALL(__NR_sync_file_range, fd, 0, (int)(offset >> 32),
		(int)offset, (int)(nbytes >> 32), (int)nbytes, flags);
# elif __BYTE_ORDER == __LITTLE_ENDIAN
	return TST_SYSCALL(__NR_sync_file_range, fd, 0, (int)offset,
		(int)(offset >> 32), (int)nbytes, (int)(nbytes >> 32), flags);
# endif
#else
	return TST_SYSCALL(__NR_sync_file_range, fd, offset, nbytes, flags);
#endif
}
#endif

#endif /* SYNC_FILE_RANGE_H */