|
Packit |
6c4009 |
/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <errno.h>
|
|
Packit |
6c4009 |
#include <fcntl.h>
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Advice the system about the expected behaviour of the application with
|
|
Packit |
6c4009 |
respect to the file associated with FD. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef __OFF_T_MATCHES_OFF64_T
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Default implementation will use __NR_fadvise64 with expected argument
|
|
Packit |
6c4009 |
positions (for instance i386 and powerpc32 that uses __ALIGNMENT_ARG).
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Second option will be used by arm which define __NR_arm_fadvise64_64
|
|
Packit |
6c4009 |
(redefined to __NR_fadvise64_64 in kernel-features.h) that behaves as
|
|
Packit |
6c4009 |
__NR_fadvise64_64 (without the aligment argument required for the ABI).
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Third option will be used by mips o32. Mips will use a 7 argument
|
|
Packit |
6c4009 |
syscall with __NR_fadvise64.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
s390 implements fadvice64_64 using a specific struct with arguments
|
|
Packit |
6c4009 |
packed inside. This is the only implementation handled in arch-specific
|
|
Packit |
6c4009 |
code. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int
|
|
Packit |
6c4009 |
posix_fadvise (int fd, off_t offset, off_t len, int advise)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
INTERNAL_SYSCALL_DECL (err);
|
|
Packit |
6c4009 |
# if defined (__NR_fadvise64) && !defined (__ASSUME_FADVISE64_AS_64_64)
|
|
Packit |
6c4009 |
int ret = INTERNAL_SYSCALL_CALL (fadvise64, err, fd,
|
|
Packit |
6c4009 |
__ALIGNMENT_ARG SYSCALL_LL (offset),
|
|
Packit |
6c4009 |
len, advise);
|
|
Packit |
6c4009 |
# else
|
|
Packit |
6c4009 |
# ifdef __ASSUME_FADVISE64_64_6ARG
|
|
Packit |
6c4009 |
int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd, advise,
|
|
Packit |
6c4009 |
SYSCALL_LL (offset), SYSCALL_LL (len));
|
|
Packit |
6c4009 |
# else
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# ifndef __NR_fadvise64_64
|
|
Packit |
6c4009 |
# define __NR_fadvise64_64 __NR_fadvise64
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd,
|
|
Packit |
6c4009 |
__ALIGNMENT_ARG SYSCALL_LL (offset),
|
|
Packit |
6c4009 |
SYSCALL_LL (len), advise);
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
|
|
Packit |
6c4009 |
return INTERNAL_SYSCALL_ERRNO (ret, err);
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
#endif /* __OFF_T_MATCHES_OFF64_T */
|