Blame sysdeps/unix/sysv/linux/posix_fadvise64.c

Packit Service 82fcde
/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include <errno.h>
Packit Service 82fcde
#include <fcntl.h>
Packit Service 82fcde
#include <shlib-compat.h>
Packit Service 82fcde
Packit Service 82fcde
int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise);
Packit Service 82fcde
libc_hidden_proto (__posix_fadvise64_l64)
Packit Service 82fcde
Packit Service 82fcde
/* Both arm and powerpc implements fadvise64_64 with last 'advise' argument
Packit Service 82fcde
   just after 'fd' to avoid the requirement of implementing 7-arg syscalls.
Packit Service 82fcde
   ARM also defines __NR_fadvise64_64 as __NR_arm_fadvise64_64.
Packit Service 82fcde
Packit Service 82fcde
   s390 implements fadvice64_64 using a specific struct with arguments
Packit Service 82fcde
   packed inside.  This is the only implementation handled in arch-specific
Packit Service 82fcde
   code.  */
Packit Service 82fcde
Packit Service 82fcde
#ifndef __NR_fadvise64_64
Packit Service 82fcde
# define __NR_fadvise64_64 __NR_fadvise64
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
/* Advice the system about the expected behaviour of the application with
Packit Service 82fcde
   respect to the file associated with FD.  */
Packit Service 82fcde
Packit Service 82fcde
int
Packit Service 82fcde
__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
Packit Service 82fcde
{
Packit Service 82fcde
  INTERNAL_SYSCALL_DECL (err);
Packit Service 82fcde
#ifdef __ASSUME_FADVISE64_64_6ARG
Packit Service 82fcde
  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd, advise,
Packit Service 82fcde
				   SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
Packit Service 82fcde
#else
Packit Service 82fcde
  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd,
Packit Service 82fcde
				   __ALIGNMENT_ARG SYSCALL_LL64 (offset),
Packit Service 82fcde
				   SYSCALL_LL64 (len), advise);
Packit Service 82fcde
#endif
Packit Service 82fcde
  if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
Packit Service 82fcde
    return 0;
Packit Service 82fcde
  return INTERNAL_SYSCALL_ERRNO (ret, err);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
/* The type of the len argument was changed from size_t to off_t in
Packit Service 82fcde
   POSIX.1-2003 TC1.  */
Packit Service 82fcde
#ifndef __OFF_T_MATCHES_OFF64_T
Packit Service 82fcde
# if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3)
Packit Service 82fcde
int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise);
Packit Service 82fcde
Packit Service 82fcde
int
Packit Service 82fcde
attribute_compat_text_section
Packit Service 82fcde
__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise)
Packit Service 82fcde
{
Packit Service 82fcde
  return __posix_fadvise64_l64 (fd, offset, len, advise);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3);
Packit Service 82fcde
compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
Packit Service 82fcde
# else
Packit Service 82fcde
weak_alias (__posix_fadvise64_l64, posix_fadvise64);
Packit Service 82fcde
# endif
Packit Service 82fcde
#else
Packit Service 82fcde
weak_alias (__posix_fadvise64_l64, posix_fadvise64);
Packit Service 82fcde
strong_alias (__posix_fadvise64_l64, posix_fadvise);
Packit Service 82fcde
#endif
Packit Service 82fcde
libc_hidden_def (__posix_fadvise64_l64)