hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

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

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 <shlib-compat.h>
Packit 6c4009
Packit 6c4009
int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise);
Packit 6c4009
libc_hidden_proto (__posix_fadvise64_l64)
Packit 6c4009
Packit 6c4009
/* Both arm and powerpc implements fadvise64_64 with last 'advise' argument
Packit 6c4009
   just after 'fd' to avoid the requirement of implementing 7-arg syscalls.
Packit 6c4009
   ARM also defines __NR_fadvise64_64 as __NR_arm_fadvise64_64.
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
#ifndef __NR_fadvise64_64
Packit 6c4009
# define __NR_fadvise64_64 __NR_fadvise64
Packit 6c4009
#endif
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
int
Packit 6c4009
__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
Packit 6c4009
{
Packit 6c4009
  INTERNAL_SYSCALL_DECL (err);
Packit 6c4009
#ifdef __ASSUME_FADVISE64_64_6ARG
Packit 6c4009
  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd, advise,
Packit 6c4009
				   SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
Packit 6c4009
#else
Packit 6c4009
  int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, err, fd,
Packit 6c4009
				   __ALIGNMENT_ARG SYSCALL_LL64 (offset),
Packit 6c4009
				   SYSCALL_LL64 (len), advise);
Packit 6c4009
#endif
Packit 6c4009
  if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
Packit 6c4009
    return 0;
Packit 6c4009
  return INTERNAL_SYSCALL_ERRNO (ret, err);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
/* The type of the len argument was changed from size_t to off_t in
Packit 6c4009
   POSIX.1-2003 TC1.  */
Packit 6c4009
#ifndef __OFF_T_MATCHES_OFF64_T
Packit 6c4009
# if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3)
Packit 6c4009
int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise);
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
attribute_compat_text_section
Packit 6c4009
__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise)
Packit 6c4009
{
Packit 6c4009
  return __posix_fadvise64_l64 (fd, offset, len, advise);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3);
Packit 6c4009
compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
Packit 6c4009
# else
Packit 6c4009
weak_alias (__posix_fadvise64_l64, posix_fadvise64);
Packit 6c4009
# endif
Packit 6c4009
#else
Packit 6c4009
weak_alias (__posix_fadvise64_l64, posix_fadvise64);
Packit 6c4009
strong_alias (__posix_fadvise64_l64, posix_fadvise);
Packit 6c4009
#endif
Packit 6c4009
libc_hidden_def (__posix_fadvise64_l64)