1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) International Business Machines Corp., 2008 4 */ 5 6 #ifndef LAPI_SYNC_FILE_RANGE_H__ 7 #define LAPI_SYNC_FILE_RANGE_H__ 8 9 #include <sys/types.h> 10 #include "config.h" 11 #include "lapi/syscalls.h" 12 #include "lapi/abisize.h" 13 14 #if !defined(HAVE_SYNC_FILE_RANGE) 15 16 #ifdef TST_TEST_H__ 17 # define TST_SYSCALL tst_syscall 18 #else 19 # define TST_SYSCALL ltp_syscall 20 #endif 21 22 /***************************************************************************** 23 * Wraper function to call sync_file_range system call 24 ******************************************************************************/ sync_file_range(int fd,off64_t offset,off64_t nbytes,unsigned int flags)25 static inline long sync_file_range(int fd, off64_t offset, off64_t nbytes, 26 unsigned int flags) 27 { 28 #if (defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)) 29 # ifdef TST_ABI32 30 # if __BYTE_ORDER == __BIG_ENDIAN 31 return TST_SYSCALL(__NR_sync_file_range2, fd, flags, 32 (int)(offset >> 32), (int)offset, (int)(nbytes >> 32), 33 (int)nbytes); 34 # elif __BYTE_ORDER == __LITTLE_ENDIAN 35 return TST_SYSCALL(__NR_sync_file_range2, fd, flags, (int)offset, 36 (int)(offset >> 32), nbytes, (int)(nbytes >> 32)); 37 # endif 38 # else 39 return TST_SYSCALL(__NR_sync_file_range2, fd, flags, offset, nbytes); 40 # endif 41 #elif (defined(__s390__) || defined(__s390x__)) && defined(TST_ABI32) 42 return TST_SYSCALL(__NR_sync_file_range, fd, (int)(offset >> 32), 43 (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); 44 #elif defined(__mips__) && defined(TST_ABI32) 45 # if __BYTE_ORDER == __BIG_ENDIAN 46 return TST_SYSCALL(__NR_sync_file_range, fd, 0, (int)(offset >> 32), 47 (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); 48 # elif __BYTE_ORDER == __LITTLE_ENDIAN 49 return TST_SYSCALL(__NR_sync_file_range, fd, 0, (int)offset, 50 (int)(offset >> 32), (int)nbytes, (int)(nbytes >> 32), flags); 51 # endif 52 #else 53 return TST_SYSCALL(__NR_sync_file_range, fd, offset, nbytes, flags); 54 #endif 55 } 56 #endif 57 58 #endif /* LAPI_SYNC_FILE_RANGE_H__ */ 59