From dc2a97c6eda5fd6ed87b15f7eda3c923260cdee1 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sat, 19 May 2012 19:10:13 +0000 Subject: [PATCH] Clean up MIPS ftruncate64/truncate64. --- ChangeLog.mips | 25 ++++++++ sysdeps/unix/sysv/linux/mips/ftruncate64.c | 75 ---------------------- sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c | 36 +++++++++++ sysdeps/unix/sysv/linux/mips/mips32/truncate64.c | 36 +++++++++++ .../sysv/linux/mips/mips64/{n32 => }/ftruncate64.c | 0 .../unix/sysv/linux/mips/mips64/n32/syscalls.list | 2 - sysdeps/unix/sysv/linux/mips/mips64/syscalls.list | 3 + .../sysv/linux/mips/mips64/{n32 => }/truncate64.c | 0 sysdeps/unix/sysv/linux/mips/truncate64.c | 75 ---------------------- 9 files changed, 100 insertions(+), 152 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/mips/ftruncate64.c create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c create mode 100644 sysdeps/unix/sysv/linux/mips/mips32/truncate64.c rename sysdeps/unix/sysv/linux/mips/mips64/{n32 => }/ftruncate64.c (100%) rename sysdeps/unix/sysv/linux/mips/mips64/{n32 => }/truncate64.c (100%) delete mode 100644 sysdeps/unix/sysv/linux/mips/truncate64.c diff --git a/ChangeLog.mips b/ChangeLog.mips index db16b4b..b5fdbda 100644 --- a/ChangeLog.mips +++ b/ChangeLog.mips @@ -1,3 +1,28 @@ +2012-05-19 Joseph Myers + + * sysdeps/unix/sysv/linux/mips/ftruncate64.c: Move to ... + * sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c: ... here. + (kernel-features.h): Don't include. + [__NR_ftruncate64]: Make code unconditional. + [!__NR_ftruncate64]: Remove conditional code. + [!__ASSUME_TRUNCATE64_SYSCALL]: Likewise. + * sysdeps/unix/sysv/linux/mips/truncate64.c: Move to ... + * sysdeps/unix/sysv/linux/mips/mips32/truncate64.c: ... here. + (kernel-features.h): Don't include. + [__NR_truncate64]: Make code unconditional. + [!__NR_truncate64]: Remove conditional code. + [!__ASSUME_TRUNCATE64_SYSCALL]: Likewise. + * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (ftruncate): + Add syscall. + (truncate): Likewise. + * sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list + (ftruncate): Remove syscall. + (truncate): Likewise. + * sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c: Move to ... + * sysdeps/unix/sysv/linux/mips/mips64/ftruncate64.c: ... here. + * sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c: Move to ... + * sysdeps/unix/sysv/linux/mips/mips64/truncate64.c: ... here. + 2012-05-16 Joseph Myers * sysdeps/unix/sysv/linux/mips/bits/stat.h (struct stat) diff --git a/sysdeps/unix/sysv/linux/mips/ftruncate64.c b/sysdeps/unix/sysv/linux/mips/ftruncate64.c deleted file mode 100644 index 982650c..0000000 --- a/sysdeps/unix/sysv/linux/mips/ftruncate64.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2005,2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include -#include - -#include -#include - -#include - -#ifdef __NR_ftruncate64 -#ifndef __ASSUME_TRUNCATE64_SYSCALL -/* The variable is shared between all wrappers around *truncate64 calls. */ -extern int __have_no_truncate64; -#endif - -/* Truncate the file FD refers to to LENGTH bytes. */ -int -__ftruncate64 (int fd, off64_t length) -{ -#ifndef __ASSUME_TRUNCATE64_SYSCALL - if (! __have_no_truncate64) -#endif - { - unsigned int low = length & 0xffffffff; - unsigned int high = length >> 32; -#ifndef __ASSUME_TRUNCATE64_SYSCALL - int saved_errno = errno; -#endif - int result = INLINE_SYSCALL (ftruncate64, 4, fd, 0, - __LONG_LONG_PAIR (high, low)); -#ifndef __ASSUME_TRUNCATE64_SYSCALL - if (result != -1 || errno != ENOSYS) -#endif - return result; - -#ifndef __ASSUME_TRUNCATE64_SYSCALL - __set_errno (saved_errno); - __have_no_truncate64 = 1; -#endif - } - -#ifndef __ASSUME_TRUNCATE64_SYSCALL - if ((off_t) length != length) - { - __set_errno (EINVAL); - return -1; - } - return __ftruncate (fd, (off_t) length); -#endif -} -weak_alias (__ftruncate64, ftruncate64) - -#else -/* Use the generic implementation. */ -# include -#endif diff --git a/sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c b/sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c new file mode 100644 index 0000000..9838182 --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1997-2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include +#include +#include +#include + +#include +#include + +/* Truncate the file FD refers to to LENGTH bytes. */ +int +__ftruncate64 (int fd, off64_t length) +{ + unsigned int low = length & 0xffffffff; + unsigned int high = length >> 32; + int result = INLINE_SYSCALL (ftruncate64, 4, fd, 0, + __LONG_LONG_PAIR (high, low)); + return result; +} +weak_alias (__ftruncate64, ftruncate64) diff --git a/sysdeps/unix/sysv/linux/mips/mips32/truncate64.c b/sysdeps/unix/sysv/linux/mips/mips32/truncate64.c new file mode 100644 index 0000000..3fad93f --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/mips32/truncate64.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1997-2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include +#include +#include +#include + +#include +#include +#include + +/* Truncate the file FD refers to to LENGTH bytes. */ +int +truncate64 (const char *path, off64_t length) +{ + unsigned int low = length & 0xffffffff; + unsigned int high = length >> 32; + int result = INLINE_SYSCALL (truncate64, 4, CHECK_STRING (path), 0, + __LONG_LONG_PAIR (high, low)); + return result; +} diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c b/sysdeps/unix/sysv/linux/mips/mips64/ftruncate64.c similarity index 100% rename from sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c rename to sysdeps/unix/sysv/linux/mips/mips64/ftruncate64.c diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list index 0d37a9b..7ad5523 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list @@ -2,8 +2,6 @@ readahead - readahead i:iii __readahead readahead sync_file_range - sync_file_range Ci:iiii sync_file_range -ftruncate - ftruncate i:ii __ftruncate ftruncate ftruncate64 __ftruncate64 -truncate - truncate i:si truncate truncate64 prlimit64 EXTRA prlimit64 i:iipp prlimit64 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list index cac273c..867323a 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list +++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list @@ -2,6 +2,9 @@ lseek - lseek Ci:iii __libc_lseek __lseek lseek __llseek llseek __libc_lseek64 __lseek64 lseek64 +ftruncate - ftruncate i:ii __ftruncate ftruncate ftruncate64 __ftruncate64 +truncate - truncate i:si truncate truncate64 + # Semaphore and shm system calls. msgctl, shmctl, and semctl have C # wrappers (to set __IPC_64). msgget - msgget i:ii __msgget msgget diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c b/sysdeps/unix/sysv/linux/mips/mips64/truncate64.c similarity index 100% rename from sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c rename to sysdeps/unix/sysv/linux/mips/mips64/truncate64.c diff --git a/sysdeps/unix/sysv/linux/mips/truncate64.c b/sysdeps/unix/sysv/linux/mips/truncate64.c deleted file mode 100644 index 7c11b63..0000000 --- a/sysdeps/unix/sysv/linux/mips/truncate64.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 1997,1998,1999,2000,2002,2003,2005,2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#ifdef __NR_truncate64 -#ifndef __ASSUME_TRUNCATE64_SYSCALL -/* The variable is shared between all wrappers around *truncate64 calls. */ -int __have_no_truncate64; -#endif - -/* Truncate the file FD refers to to LENGTH bytes. */ -int -truncate64 (const char *path, off64_t length) -{ -#ifndef __ASSUME_TRUNCATE64_SYSCALL - if (! __have_no_truncate64) -#endif - { - unsigned int low = length & 0xffffffff; - unsigned int high = length >> 32; -#ifndef __ASSUME_TRUNCATE64_SYSCALL - int saved_errno = errno; -#endif - int result = INLINE_SYSCALL (truncate64, 4, CHECK_STRING (path), 0, - __LONG_LONG_PAIR (high, low)); -#ifndef __ASSUME_TRUNCATE64_SYSCALL - if (result != -1 || errno != ENOSYS) -#endif - return result; - -#ifndef __ASSUME_TRUNCATE64_SYSCALL - __set_errno (saved_errno); - __have_no_truncate64 = 1; -#endif - } - -#ifndef __ASSUME_TRUNCATE64_SYSCALL - if ((off_t) length != length) - { - __set_errno (EINVAL); - return -1; - } - return truncate (path, (off_t) length); -#endif -} - -#else -/* Use the generic implementation. */ -# include -#endif -- 2.7.4