>From edb98f0b69c16f612f79fe24d10597af47424f13 Mon Sep 17 00:00:00 2001 From: Zeng Linggang <[email protected]> Date: Tue, 24 Dec 2013 19:21:32 +0800 Subject: [PATCH] fallocate/fallocate.h: move inline function
Moved common inline function to fallocate.h Signed-off-by: Zeng Linggang <[email protected]> --- testcases/kernel/syscalls/fallocate/fallocate.h | 47 +++++++++++++++++++++++ testcases/kernel/syscalls/fallocate/fallocate01.c | 23 +---------- testcases/kernel/syscalls/fallocate/fallocate02.c | 19 +-------- testcases/kernel/syscalls/fallocate/fallocate03.c | 19 +-------- 4 files changed, 50 insertions(+), 58 deletions(-) create mode 100644 testcases/kernel/syscalls/fallocate/fallocate.h diff --git a/testcases/kernel/syscalls/fallocate/fallocate.h b/testcases/kernel/syscalls/fallocate/fallocate.h new file mode 100644 index 0000000..e47338b --- /dev/null +++ b/testcases/kernel/syscalls/fallocate/fallocate.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) International Business Machines Corp., 2007 + * Copyright (c) 2013 Fujitsu Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef FALLOCATE_H +#define FALLOCATE_H + +#include <sys/types.h> +#include <endian.h> +#include "linux_syscall_numbers.h" + +static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) +{ +/* + * Use __WORDSIZE will fail on ABI's that have 64bit registers but 32bit + * longs like MIPS n32 and x86_64 x32 + */ +#if __WORDSIZE == 64 || defined __powerpc64__ || defined __mips64 ||\ +defined __x86_64__ || defined __sparc64__ + return ltp_syscall(__NR_fallocate, fd, mode, offset, len); + +#else + return (long)ltp_syscall(__NR_fallocate, fd, mode, + __LONG_LONG_PAIR((off_t) (offset >> 32), + (off_t) offset), + __LONG_LONG_PAIR((off_t) (len >> 32), + (off_t) len)); +#endif +} + +#endif /* FALLOCATE.H */ diff --git a/testcases/kernel/syscalls/fallocate/fallocate01.c b/testcases/kernel/syscalls/fallocate/fallocate01.c index 0240687..eec39fa 100644 --- a/testcases/kernel/syscalls/fallocate/fallocate01.c +++ b/testcases/kernel/syscalls/fallocate/fallocate01.c @@ -100,12 +100,10 @@ #include "test.h" #include "usctest.h" -#include "linux_syscall_numbers.h" +#include "fallocate.h" #define BLOCKS_WRITTEN 12 -/* Local Function */ -static inline long fallocate(); void get_blocksize(int); void populate_files(int fd); void runtest(int, int, loff_t); @@ -183,16 +181,10 @@ void get_blocksize(int fd) void populate_files(int fd) { char buf[buf_size + 1]; - char *fname; int index; int blocks; int data; - if (fd == fd_mode1) - fname = fname_mode1; - else - fname = fname_mode2; - for (blocks = 0; blocks < BLOCKS_WRITTEN; blocks++) { for (index = 0; index < buf_size; index++) buf[index] = 'A' + (index % 26); @@ -239,19 +231,6 @@ int main(int ac, char **av) tst_exit(); } -static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) -{ -#if __WORDSIZE == 32 - return (long)ltp_syscall(__NR_fallocate, fd, mode, - __LONG_LONG_PAIR((off_t) (offset >> 32), - (off_t) offset), - __LONG_LONG_PAIR((off_t) (len >> 32), - (off_t) len)); -#else - return ltp_syscall(__NR_fallocate, fd, mode, offset, len); -#endif -} - /***************************************************************************** * Calls the system call, with appropriate parameters and writes data ******************************************************************************/ diff --git a/testcases/kernel/syscalls/fallocate/fallocate02.c b/testcases/kernel/syscalls/fallocate/fallocate02.c index 37f0635..e5e482c 100644 --- a/testcases/kernel/syscalls/fallocate/fallocate02.c +++ b/testcases/kernel/syscalls/fallocate/fallocate02.c @@ -96,7 +96,7 @@ #include "test.h" #include "usctest.h" -#include "linux_syscall_numbers.h" +#include "fallocate.h" #define BLOCKS_WRITTEN 12 @@ -108,7 +108,6 @@ #define OFFSET 12 -static inline long fallocate(); void populate_file(); void create_fifo(); void create_pipe(); @@ -225,22 +224,6 @@ void populate_file() } /***************************************************************************** - * Wraper function to call fallocate system call - ******************************************************************************/ -static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) -{ -#if __WORDSIZE == 32 - return (long)ltp_syscall(__NR_fallocate, fd, mode, - __LONG_LONG_PAIR((off_t) (offset >> 32), - (off_t) offset), - __LONG_LONG_PAIR((off_t) (len >> 32), - (off_t) len)); -#else - return ltp_syscall(__NR_fallocate, fd, mode, offset, len); -#endif -} - -/***************************************************************************** * Main function that calls the system call with the appropriate parameters ******************************************************************************/ /* ac: number of command line parameters */ diff --git a/testcases/kernel/syscalls/fallocate/fallocate03.c b/testcases/kernel/syscalls/fallocate/fallocate03.c index 973b2d7..a42dcad 100644 --- a/testcases/kernel/syscalls/fallocate/fallocate03.c +++ b/testcases/kernel/syscalls/fallocate/fallocate03.c @@ -95,7 +95,7 @@ #include "test.h" #include "usctest.h" -#include "linux_syscall_numbers.h" +#include "fallocate.h" #define BLOCKS_WRITTEN 12 #define HOLE_SIZE_IN_BLOCKS 12 @@ -103,7 +103,6 @@ #define FALLOC_FL_KEEP_SIZE 1 //Need to be removed once the glibce support is provided #define TRUE 0 -static inline long fallocate(); void get_blocksize(int); void populate_file(); void file_seek(off_t); @@ -219,22 +218,6 @@ void populate_file() } /***************************************************************************** - * Wraper function to call fallocate system call - ******************************************************************************/ -static inline long fallocate(int fd, int mode, loff_t offset, loff_t len) -{ -#if __WORDSIZE == 32 - return (long)ltp_syscall(__NR_fallocate, fd, mode, - __LONG_LONG_PAIR((off_t) (offset >> 32), - (off_t) offset), - __LONG_LONG_PAIR((off_t) (len >> 32), - (off_t) len)); -#else - return ltp_syscall(__NR_fallocate, fd, mode, offset, len); -#endif -} - -/***************************************************************************** * Main function that calls the system call with the appropriate parameters ******************************************************************************/ /* ac: number of command line parameters */ -- 1.8.2.1 ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
