From bfef9264665ff93866882402a71c116cd0757de1 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 16 Aug 2003 06:21:46 +0000 Subject: [PATCH] Update. 2003-08-15 Ulrich Drepper * io/Versions [GLIBC_2.3.3]: Add posix_fadvise64. * io/fcntl.h (posix_fadvise64): Change type of third parameter to off_t. * sysdeps/unix/sysv/linux/posix_fadvise.c: Adjust definition. * sysdeps/unix/make-syscalls.sh: Recognize V prefix to the parameter description indicating the error value is returned, not -1. * sysdeps/unix/sysv/linux/Makefile [subdir=io] (subdir_routines): Add posix_fadvise64_64. * sysdeps/unix/sysv/linux/kernel-features.h: Add definition of __ASSUME_FADVISE64_64_SYSCALL. * sysdeps/unix/sysv/linux/syscalls.list: Don't define madvise and posix_madvise in one file. Have posix_madvise defined with error value returned. Define posix_fadvise64_64 entry. Add version info to posix_fadvise64 entry. * sysdeps/unix/sysv/linux/alpha/syscalls.list: Define posix_fadvise64_64 entry. Add version info to posix_fadvise64 entry. * sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/i386/posix_fadvise.S: New file. * sysdeps/unix/sysv/linux/i386/sysdep.h: Define PSEUDO_ERRVAL, PSEUDO_END_ERRVAL, and ret_ERRVAL. * sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise. * posix/Makefile (routines): Add posix_madvise. * sysdeps/generic/madvise.c: Don't define posix_madvise. * sysdeps/generic/posix_madvise.c: New file. * sysdeps/unix/sysv/aix/posix_madvise.c: New file. --- ChangeLog | 32 +++++ io/Versions | 3 + io/fcntl.h | 6 +- posix/Makefile | 3 +- sysdeps/generic/madvise.c | 3 +- sysdeps/generic/posix_madvise.c | 32 +++++ sysdeps/unix/make-syscalls.sh | 1 + sysdeps/unix/sysv/aix/posix_madvise.c | 8 ++ sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/alpha/syscalls.list | 3 +- .../unix/sysv/linux/i386/posix_fadvise64_64.S | 118 ++++++++++++++++++ sysdeps/unix/sysv/linux/i386/sysdep.h | 14 +++ sysdeps/unix/sysv/linux/ia64/syscalls.list | 3 +- sysdeps/unix/sysv/linux/ia64/sysdep.h | 11 ++ sysdeps/unix/sysv/linux/kernel-features.h | 6 + sysdeps/unix/sysv/linux/posix_fadvise.c | 2 +- sysdeps/unix/sysv/linux/syscalls.list | 6 +- sysdeps/unix/sysv/linux/x86_64/syscalls.list | 2 + sysdeps/unix/sysv/linux/x86_64/sysdep.h | 11 ++ 19 files changed, 254 insertions(+), 12 deletions(-) create mode 100644 sysdeps/generic/posix_madvise.c create mode 100644 sysdeps/unix/sysv/aix/posix_madvise.c create mode 100644 sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S diff --git a/ChangeLog b/ChangeLog index 416eceb106..8450b63c2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2003-08-15 Ulrich Drepper + + * io/Versions [GLIBC_2.3.3]: Add posix_fadvise64. + * io/fcntl.h (posix_fadvise64): Change type of third parameter to + off_t. + * sysdeps/unix/sysv/linux/posix_fadvise.c: Adjust definition. + * sysdeps/unix/make-syscalls.sh: Recognize V prefix to the parameter + description indicating the error value is returned, not -1. + * sysdeps/unix/sysv/linux/Makefile [subdir=io] (subdir_routines): Add + posix_fadvise64_64. + * sysdeps/unix/sysv/linux/kernel-features.h: Add definition of + __ASSUME_FADVISE64_64_SYSCALL. + * sysdeps/unix/sysv/linux/syscalls.list: Don't define madvise and + posix_madvise in one file. Have posix_madvise defined with error + value returned. + Define posix_fadvise64_64 entry. Add version info to posix_fadvise64 + entry. + * sysdeps/unix/sysv/linux/alpha/syscalls.list: Define + posix_fadvise64_64 entry. Add version info to posix_fadvise64 entry. + * sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise. + * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise. + * sysdeps/unix/sysv/linux/i386/posix_fadvise.S: New file. + * sysdeps/unix/sysv/linux/i386/sysdep.h: Define PSEUDO_ERRVAL, + PSEUDO_END_ERRVAL, and ret_ERRVAL. + * sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise. + * sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise. + + * posix/Makefile (routines): Add posix_madvise. + * sysdeps/generic/madvise.c: Don't define posix_madvise. + * sysdeps/generic/posix_madvise.c: New file. + * sysdeps/unix/sysv/aix/posix_madvise.c: New file. + 2003-08-15 Jakub Jelinek * assert/assert.h (assert_perror): Use __builtin_expect for gcc >= diff --git a/io/Versions b/io/Versions index 88f3a9ac04..9e035aecc7 100644 --- a/io/Versions +++ b/io/Versions @@ -93,6 +93,9 @@ libc { # l* lchmod; } + GLIBC_2.3.3 { + posix_fadvise64; + } GLIBC_PRIVATE { # functions which have an additional interface since they are # cancelable. diff --git a/io/fcntl.h b/io/fcntl.h index 5dbde77bf4..77f002b66b 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -134,19 +134,19 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len) __THROW; /* Advice the system about the expected behaviour of the application with respect to the file associated with FD. */ # ifndef __USE_FILE_OFFSET64 -extern int posix_fadvise (int __fd, __off_t __offset, size_t __len, +extern int posix_fadvise (int __fd, __off_t __offset, off_t __len, int __advise) __THROW; # else # ifdef __REDIRECT extern int __REDIRECT (posix_fadvise, (int __fd, __off64_t __offset, - size_t __len, int __advise) __THROW, + off64_t __len, int __advise) __THROW, posix_fadvise64); # else # define posix_fadvise posix_fadvise64 # endif # endif # ifdef __USE_LARGEFILE64 -extern int posix_fadvise64 (int __fd, __off64_t __offset, size_t __len, +extern int posix_fadvise64 (int __fd, __off64_t __offset, off64_t __len, int __advise) __THROW; # endif diff --git a/posix/Makefile b/posix/Makefile index d3e77129ee..d8516c2ec3 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -63,7 +63,8 @@ routines := \ spawnattr_getflags spawnattr_setflags \ spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni \ spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \ - spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam + spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam \ + posix_madvise include ../Makeconfig diff --git a/sysdeps/generic/madvise.c b/sysdeps/generic/madvise.c index 05ea8a9d89..dbef959dd8 100644 --- a/sysdeps/generic/madvise.c +++ b/sysdeps/generic/madvise.c @@ -24,11 +24,10 @@ for the region starting at ADDR and extending LEN bytes. */ int -posix_madvise (__ptr_t addr, size_t len, int advice) +madvise (__ptr_t addr, size_t len, int advice) { __set_errno (ENOSYS); return -1; } -weak_alias (posix_madvise, madvise) stub_warning (madvise) #include diff --git a/sysdeps/generic/posix_madvise.c b/sysdeps/generic/posix_madvise.c new file mode 100644 index 0000000000..6f8d60f55f --- /dev/null +++ b/sysdeps/generic/posix_madvise.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1994, 1995, 1996, 1997, 2000 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +/* Advise the system about particular usage patterns the program follows + for the region starting at ADDR and extending LEN bytes. */ + +int +posix_madvise (__ptr_t addr, size_t len, int advice) +{ + return ENOSYS; +} +stub_warning (posix_madvise) +#include diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index 4fea51adef..0ec8b28fd2 100644 --- a/sysdeps/unix/make-syscalls.sh +++ b/sysdeps/unix/make-syscalls.sh @@ -88,6 +88,7 @@ while read file srcfile caller syscall args strong weak; do case $args in C*) cancellable=-cancel; args=`echo $args | sed 's/C:\?//'`;; E*) noerrno=_NOERRNO; args=`echo $args | sed 's/E:\?//'`;; + V*) noerrno=_ERRVAL; args=`echo $args | sed 's/V:\?//'`;; esac # Derive the number of arguments from the argument signature diff --git a/sysdeps/unix/sysv/aix/posix_madvise.c b/sysdeps/unix/sysv/aix/posix_madvise.c new file mode 100644 index 0000000000..7ab4bed8e0 --- /dev/null +++ b/sysdeps/unix/sysv/aix/posix_madvise.c @@ -0,0 +1,8 @@ +#include +#include + +int +posix_madvise (void *addr, size_t len, int advise) +{ + return madvise (addr, len, advise) ? errno : 0; +} diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index f292931fb9..2d98aa58ac 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -135,7 +135,7 @@ CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1 endif ifeq ($(subdir),io) -sysdep_routines += xstatconv +sysdep_routines += xstatconv posix_fadvise64_64 endif ifeq ($(subdir),elf) diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list index 60235d012f..78feb7a57a 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscalls.list +++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list @@ -21,7 +21,8 @@ getpriority - getpriority i:ii __getpriority getpriority mmap - mmap b:aniiii __mmap mmap __mmap64 mmap64 llseek EXTRA lseek C:3 __libc_lseek __lseek lseek __libc_lseek64 __llseek llseek __lseek64 lseek64 lseek llseek - -posix_fadvise64 - fadvise64 4 posix_fadvise64 posix_fadvise +posix_fadvise64 - fadvise64 4 posix_fadvise64 posix_fadvise@GLIBC_2.2 +posix_fadvise64_64 - fadvise64 4 posix_fadvise64 posix_fadvise@GLIBC_2.3.3 pread - pread64 C:4 __libc_pread __libc_pread64 __pread pread __pread64 pread64 pwrite - pwrite64 C:4 __libc_pwrite __libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64 fstatfs - fstatfs i:ip __fstatfs fstatfs __fstatfs64 fstatfs64 diff --git a/sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S b/sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S new file mode 100644 index 0000000000..e132c3b9a2 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S @@ -0,0 +1,118 @@ +/* Copyright (C) 1995,96,97,98,99,2000,2002,2003 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +#include "kernel-features.h" + +#define EINVAL 22 +#define ENOSYS 38 +#define EOVERFLOW 75 + +#define SVRSP 16 /* saved register space */ +#define PARMS LINKAGE+SVRSP /* space for 4 saved regs */ +#define FD PARMS +#define OFFLO FD+4 +#define OFFHI OFFLO+4 +#define LENLO OFFHI+4 +#define LENHI LENLO+4 +#define FLAGS LENHI+4 + + .text +ENTRY (BP_SYM (__posix_fadvise64_l64)) + +#ifdef __NR_fadvise64_64 + + /* Save registers. */ + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + + movl FD(%esp), %ebx + movl OFFLO(%esp), %ecx + movl OFFHI(%esp), %edx + movl LENLO(%esp), %esi + movl LENHI(%esp), %edi + movl FLAGS(%esp), %ebp + + movl $SYS_ify(fadvise64_64), %eax + ENTER_KERNEL + + /* Restore registers. */ + popl %edi + popl %esi + popl %ebx + popl %ebp + +#ifndef __ASSUME_FADVISE64_64_SYSCALL + cmpl $-ENOSYS, %eax + je 1f +#endif + + /* The function returns zero, or the error number. So all we + have to do is negate the value passed back from the kernel. */ + /* If 0 > %eax > -4096 there was an error. */ + negl %eax + + /* Successful; return the syscall's value. */ + ret +#endif + +#if defined __NR_fadvise64 \ + && (!defined __ASSUME_FADVISE64_64_SYSCALL || !defined __NR_fadvise64_64) +1: /* Save registers. */ + pushl %ebx + pushl %esi + pushl %edi + + /* Overflow check. */ + cmpl $0, LENHI(%esp) + jne L(overflow) + + movl FD(%esp), %ebx + movl OFFLO(%esp), %ecx + movl OFFHI(%esp), %edx + movl LENLO(%esp), %esi + movl FLAGS(%esp), %edi + + movl $SYS_ify(fadvise64_64), %eax + ENTER_KERNEL + + /* Restore registers. */ + popl %edi + popl %esi + popl %ebx + + /* If 0 > %eax > -4096 there was an error. */ + negl %eax + + /* Successful; return the syscall's value. */ + ret + +L(overflow): + movl $EOVERFLOW, %eax + ret +#elif + movl $ENOSYS, %eax + ret +#endif + +PSEUDO_END_NOERRNO (BP_SYM (__posix_fadvise64_l64)) diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 95124797e9..79ad72abff 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -90,6 +90,20 @@ #define ret_NOERRNO ret +/* The function has to return the error code. */ +#undef PSEUDO_ERRVAL +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + .text; \ + ENTRY (name) \ + DO_CALL (syscall_name, args); \ + negl %eax + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) \ + END (name) + +#define ret_ERRVAL ret + #ifndef PIC # define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */ #else diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list index c2027b670f..a368226b91 100644 --- a/sysdeps/unix/sysv/linux/ia64/syscalls.list +++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list @@ -5,7 +5,8 @@ umount2 - umount 2 __umount2 umount2 # Whee! 64-bit systems naturally implement llseek. llseek EXTRA lseek C:3 __libc_lseek __lseek lseek __libc_lseek64 __llseek llseek __lseek64 lseek64 lseek llseek - -posix_fadvise64 - fadvise64 4 posix_fadvise64 posix_fadvise +posix_fadvise64 - fadvise64 4 posix_fadvise64 posix_fadvise@GLIBC_2.2 +posix_fadvise64_64 - fadvise64 4 posix_fadvise64 posix_fadvise@GLIBC_2.3.3 pread - pread C:4 __libc_pread __libc_pread64 __pread pread __pread64 pread64 pwrite - pwrite C:4 __libc_pwrite __libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64 fstatfs - fstatfs i:ip __fstatfs fstatfs fstatfs64 __fstatfs64 diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h index 0f729a3c3e..2fc32efd47 100644 --- a/sysdeps/unix/sysv/linux/ia64/sysdep.h +++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h @@ -110,6 +110,17 @@ #undef PSEUDO_END_NOERRNO #define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name); +#undef PSEUDO_ERRVAL +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + ENTRY(name) \ + DO_CALL (SYS_ify(syscall_name)); \ + cmp.eq p6,p0=-1,r10; \ +(p6) mov r10=r8; + + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name); + #undef END #define END(name) \ .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \ diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 26043af047..457ce665d2 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -367,3 +367,9 @@ #if __LINUX_KERNEL_VERSION >= 132609 # define __ASSUME_CLONE_STOPPED 1 #endif + +/* The fixed version of the posix_fadvise64 syscall appeared in + 2.6.0-test3. At least for x86. */ +#if __LINUX_KERNEL_VERSION >= 132609 && defined __i386__ +# define __ASSUME_FADVISE64_64_SYSCALL 1 +#endif diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c index fb1e59b2d3..808fc865ed 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise.c @@ -24,7 +24,7 @@ respect to the file associated with FD. */ int -posix_fadvise (int fd, __off_t offset, size_t len, int advise) +posix_fadvise (int fd, off_t offset, off_t len, int advise) { #ifdef __NR_fadvise64 return INLINE_SYSCALL (fadvise64, 5, fd, diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index ef77deb389..cf1a121b20 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -28,7 +28,8 @@ ioperm - ioperm i:iii ioperm iopl - iopl i:i iopl klogctl EXTRA syslog i:isi klogctl lchown - lchown i:sii __lchown lchown -madvise - madvise i:pii posix_madvise madvise +posix_madvise - madvise Vi:pii posix_madvise +madvise - madvise i:pii madvise mincore - mincore i:anV mincore mlock - mlock i:bn mlock mlockall - mlockall i:i mlockall @@ -43,7 +44,8 @@ pause - pause Ci: __libc_pause pause personality init-first personality i:i __personality personality pipe - pipe i:f __pipe pipe pivot_root EXTRA pivot_root i:ss pivot_root -posix_fadvise64 - fadvise64 i:iiiii posix_fadvise64 +posix_fadvise64 - fadvise64 Vi:iiiii __posix_fadvise64_l32 posix_fadvise64@GLIBC_2.2 +posix_fadvise64_64 - fadvise64_64 Vi:iiiiii __posix_fadvise64_l64 posix_fadvise64@GLIBC_2.3.3 prctl EXTRA prctl i:iiiii __prctl prctl putpmsg - putpmsg i:ippii putpmsg query_module EXTRA query_module i:sipip query_module diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list index 7d050c7815..063f9ba5df 100644 --- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list @@ -4,6 +4,8 @@ arch_prctl EXTRA arch_prctl i:ii __arch_prctl arch_prctl mmap - mmap b:aniiii __mmap mmap __mmap64 mmap64 modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt llseek EXTRA lseek Ci:iii __libc_lseek64 __llseek llseek __lseek64 lseek64 +posix_fadvise64 - fadvise64 i:iiii posix_fadvise64 posix_fadvise@GLIBC_2.2.5 +posix_fadvise64_64 - fadvise64_64 i:iiii posix_fadvise64 posix_fadvise@GLIBC_2.3.3 pread - pread Ci:ibni __libc_pread __libc_pread64 __pread pread __pread64 pread64 pwrite - pwrite Ci:ibni __libc_pwrite __libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64 fstatfs - fstatfs i:ip __fstatfs fstatfs __fstatfs64 fstatfs64 diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 430ec86a5d..d92869a32c 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -98,6 +98,17 @@ #define PSEUDO_END_NOERRNO(name) \ END (name) +#undef PSEUDO_ERRVAL +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + .text; \ + ENTRY (name) \ + DO_CALL (syscall_name, args); \ + negl %rax + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) \ + END (name) + #define ret_NOERRNO ret #ifndef PIC -- 2.43.5