Clean up MIPS ftruncate64/truncate64.

This commit is contained in:
Joseph Myers 2012-05-19 19:10:13 +00:00
parent 21ed706977
commit dc2a97c6ed
9 changed files with 100 additions and 152 deletions

View File

@ -1,3 +1,28 @@
2012-05-19 Joseph Myers <joseph@codesourcery.com>
* 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 <joseph@codesourcery.com>
* sysdeps/unix/sysv/linux/mips/bits/stat.h (struct stat)

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sys/types.h>
#include <errno.h>
#include <endian.h>
#include <unistd.h>
#include <sysdep.h>
#include <sys/syscall.h>
#include <kernel-features.h>
#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 <misc/ftruncate64.c>
#endif

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sys/types.h>
#include <errno.h>
#include <endian.h>
#include <unistd.h>
#include <sysdep.h>
#include <sys/syscall.h>
/* 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)

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sys/types.h>
#include <endian.h>
#include <errno.h>
#include <unistd.h>
#include <sysdep.h>
#include <sys/syscall.h>
#include <bp-checks.h>
/* 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;
}

View File

@ -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

View File

@ -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

View File

@ -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
<http://www.gnu.org/licenses/>. */
#include <sys/types.h>
#include <endian.h>
#include <errno.h>
#include <unistd.h>
#include <sysdep.h>
#include <sys/syscall.h>
#include <bp-checks.h>
#include <kernel-features.h>
#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 <misc/truncate64.c>
#endif