diff options
author | Sumit Garg <sumit.garg@linaro.org> | 2019-02-21 14:30:15 +0530 |
---|---|---|
committer | Cyril Hrubis <chrubis@suse.cz> | 2019-02-25 16:11:56 +0100 |
commit | c0dc8876fb1486ee85f6dd43e36ec5b3d9d9a4ed (patch) | |
tree | 6a3607366122e4fcd7249ce46c02117a18dd88f7 /include | |
parent | 058afc78a9d545bfb4d5869f44ae7e08fce61c6b (diff) |
syscalls/sync_file_range: Use C library wrapper if present
Add config check for C library wrapper for sync_file_range() syscall.
Also, check for sync_file_range() presence via dummy call rather than
kernel version check. And move fallback api to:
include/lapi/sync_file_range.h
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
Diffstat (limited to 'include')
-rw-r--r-- | include/lapi/sync_file_range.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/include/lapi/sync_file_range.h b/include/lapi/sync_file_range.h new file mode 100644 index 000000000..e2d35fcfd --- /dev/null +++ b/include/lapi/sync_file_range.h @@ -0,0 +1,57 @@ +// 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" + +#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__)) +# if (__WORDSIZE == 32) +# 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__)) && __WORDSIZE == 32 + return TST_SYSCALL(__NR_sync_file_range, fd, (int)(offset >> 32), + (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); +#elif defined(__mips__) && __WORDSIZE == 32 +# 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 */ |