From cc07d890ae71837512731a0bf31006db8d717f8a Mon Sep 17 00:00:00 2001 From: Lina Zhao Date: Tue, 19 Oct 2010 10:44:39 +0800 Subject: [PATCH] sync_file_rang01.c changed for arm --- .../syscalls/sync_file_range/sync_file_range01.c | 36 ++++++++++++++------ 1 files changed, 25 insertions(+), 11 deletions(-) diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c index 53619b5..a66ce85 100644 --- a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c @@ -96,12 +96,13 @@ #include "usctest.h" #include "linux_syscall_numbers.h" -#if defined(__powerpc__) || defined(__powerpc64__) +#if defined(__powerpc__) || defined(__powerpc64__)|| defined(__arm__) #ifndef __NR_sync_file_range2 #define __NR_sync_file_range2 -1 //DUMMY VALUE int arch_support = 0; //Architecure is not supported #else int arch_support = 1; //Architecture is supported +char call_num = 1; //Use __NR_sync_file_range2 as syscall #endif #else #ifndef __NR_sync_file_range @@ -109,6 +110,7 @@ int arch_support = 1; //Architecture is supported int arch_support = 0; #else int arch_support = 1; +char call_num = 0; #endif #endif @@ -139,7 +141,7 @@ struct test_data_t { int error; } test_data[] = { { &bfd, 0, 1, SYNC_FILE_RANGE_WRITE, EBADF}, { &sfd, 0, 1, SYNC_FILE_RANGE_WAIT_AFTER, ESPIPE}, { &filed, -1, 1, SYNC_FILE_RANGE_WAIT_BEFORE, EINVAL}, { &filed, 0, -1, SYNC_FILE_RANGE_WRITE, EINVAL}, { @@ -238,22 +240,33 @@ static inline long syncfilerange(int fd, off64_t offset, off64_t nbytes, unsigned int flags) { -#if (defined(__powerpc64__) || defined(__powerpc__)) && (__WORDSIZE==32) + if (call_num){ +#if (__WORDSIZE==64) - return syscall(__NR_sync_file_range2, fd, flags, (int)(offset >> 32), - (int)offset, (int)(nbytes >> 32), (int)nbytes); + return syscall(__NR_sync_file_range2, fd, flags, offset, nbytes); -#elif (defined(__powerpc64__) || defined(__powerpc__)) && (__WORDSIZE==64) +#elif (__WORDSIZE==32) - return syscall(__NR_sync_file_range2, fd, flags, offset, nbytes); -#else + if (check_endian()) //little_endian + return syscall(__NR_sync_file_range2, fd, flags,(int)offset, + (int)(offset >> 32),(int)nbytes,(int)(nbytes >> 32)); + else //big_endian + return syscall(__NR_sync_file_range2, fd, flags, (int)(offset >> 32), + (int)offset, (int)(nbytes >> 32), (int)nbytes); +#endif + else return syscall(__NR_sync_file_range, fd, offset, nbytes, flags); -#endif - return 0; } +static int check_endian( void ) +{ + int x = 1; + return ((char)(x) == x); +} + + /******************************************************************************/ /* */ /* Function: main */ @@ -294,7 +307,8 @@ int main(int ac, /* number of command line parameters */ } #else /* For other archs, need kernel version > 2.6.16 */ - + if (arch_support)printf("arch supported!\n"); + if (tst_kvercmp(2, 6, 17) < 0)printf("kernel cmp fail\n"); if (!arch_support || (tst_kvercmp(2, 6, 17) < 0)) { tst_resm(TCONF, "System doesn't support execution of the test"); tst_exit(); -- 1.6.3.1