summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog60
-rw-r--r--sysdeps/powerpc/powerpc32/sysdep.h13
-rw-r--r--sysdeps/powerpc/powerpc64/sysdep.h14
-rw-r--r--sysdeps/sparc/sparc32/dl-machine.h34
-rw-r--r--sysdeps/unix/alpha/sysdep.h15
-rw-r--r--sysdeps/unix/mips/sysdep.h12
-rw-r--r--sysdeps/unix/sparc/sysdep.h7
-rw-r--r--sysdeps/unix/sysdep.h3
-rw-r--r--sysdeps/unix/sysv/linux/alpha/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/i386/Makefile4
-rw-r--r--sysdeps/unix/sysv/linux/i386/posix_fadvise64.S (renamed from sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S)16
-rw-r--r--sysdeps/unix/sysv/linux/ia64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/posix_fadvise.c12
-rw-r--r--sysdeps/unix/sysv/linux/posix_fadvise64.c78
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/Versions3
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h14
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h15
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/Versions3
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h49
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h12
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/syscalls.list2
26 files changed, 336 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index ffba51e149..23d9e92884 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,63 @@
+2003-08-16  Jakub Jelinek  <jakub@redhat.com>
+
+	* sysdeps/powerpc/powerpc32/sysdep.h (PSEUDO_ERRVAL,
+	PSEUDO_RET_ERRVAL, ret_ERRVAL, PSEUDO_END_ERRVAL): Define.
+	* sysdeps/powerpc/powerpc64/sysdep.h (PSEUDO_ERRVAL,
+	PSEUDO_RET_ERRVAL, ret_ERRVAL, PSEUDO_END_ERRVAL): Define.
+	* sysdeps/unix/alpha/sysdep.h (PSEUDO_ERRVAL,
+	ret_ERRVAL, PSEUDO_END_ERRVAL): Define.
+	* sysdeps/unix/mips/sysdep.h (PSEUDO_ERRVAL,
+	ret_ERRVAL, PSEUDO_END_ERRVAL): Define.
+	* sysdeps/unix/sparc/sysdep.h (PSEUDO_ERRVAL,
+	ret_ERRVAL): Define.
+	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (PSEUDO_ERRVAL,
+	PSEUDO_END_ERRVAL, ret_ERRVAL): Define.
+	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (PSEUDO_ERRVAL,
+	PSEUDO_END_ERRVAL, ret_ERRVAL): Define.
+	* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h (PSEUDO_ERRVAL):
+	Define.
+	* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h (PSEUDO_ERRVAL,
+	PSEUDO_END_ERRVAL, ret_ERRVAL): Define.
+	* sysdeps/unix/sysdep.h (PSEUDO_END_ERRVAL): Define.
+
+	* sysdeps/unix/sysv/linux/syscalls.list (posix_fadvise64,
+	posix_fadvise64_64): Remove.
+	* sysdeps/unix/sysv/linux/alpha/syscalls.list (posix_fadvise64): Add
+	V flag.
+	* sysdeps/unix/sysv/linux/ia64/syscalls.list (posix_fadvise64):
+	Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
+	(posix_fadvise64): Likewise.
+	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+	(posix_fadvise64): Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
+	(posix_fadvise64): Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/syscalls.list (posix_fadvise64):
+	Likewise.
+	* sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S: Moved to...
+	* sysdeps/unix/sysv/linux/i386/posix_fadvise64.S: ...here.
+	(__posix_fadvise64_l64): Fix a typo in fadvise64 syscall invocation.
+	(__posix_fadvise64_l32): New function.
+	* sysdeps/unix/sysv/linux/i386/Makefile: Revert last change.
+	* sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions (libc): Export
+	posix_fadvise64@@GLIBC_2.3.3.
+	* sysdeps/unix/sysv/linux/s390/s390-32/Versions (libc): Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sparc32/Versions (libc): Likewise.
+	* sysdeps/unix/sysv/linux/posix_fadvise.c (posix_fadvise): Return
+	error value.
+	* sysdeps/unix/sysv/linux/posix_fadvise64.c: New file.
+
+	* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+	(SYSCALL_ERROR_HANDLER): Use TLS errno/__libc_errno if USE___THREAD.
+
+2003-08-15  Jakub Jelinek  <jakub@redhat.com>
+
+	* sysdeps/sparc/sparc32/dl-machine.h (WEAKADDR): Remove.
+	(elf_machine_matches_host): Remove weak extern stuff.
+	Use GL(dl_hwcap) unconditionally and GL(dl_hwcap_mask) if SHARED.
+	(elf_machine_runtime_setup, sparc_fixup_plt): Remove weak extern
+	stuff.  Use GL(dl_hwcap) unconditionally.
+
 2003-08-16  Alan Modra  <amodra@bigpond.net.au>
 
 	* sysdeps/powerpc/powerpc64/elf/start.S: Add a nop after
diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h
index 338c69ae68..43179d14f0 100644
--- a/sysdeps/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/powerpc/powerpc32/sysdep.h
@@ -144,6 +144,19 @@
 #define	PSEUDO_END_NOERRNO(name)					      \
   END (name)
 
+#define PSEUDO_ERRVAL(name, syscall_name, args)				      \
+  .section ".text";							      \
+  ENTRY (name)								      \
+    DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET_ERRVAL						      \
+    blr
+#define ret_ERRVAL PSEUDO_RET_ERRVAL
+
+#undef	PSEUDO_END_ERRVAL
+#define	PSEUDO_END_ERRVAL(name)						      \
+  END (name)
+
 /* Local labels stripped out by the linker.  */
 #undef L
 #define L(x) .L##x
diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h
index 203484c896..6fbe342a2a 100644
--- a/sysdeps/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/powerpc/powerpc64/sysdep.h
@@ -249,6 +249,20 @@ LT_LABELSUFFIX(name,_name_end): ; \
 #define	PSEUDO_END_NOERRNO(name) \
   END (name)
 
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+  .section ".text";	\
+  ENTRY (name) \
+  DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET_ERRVAL \
+    blr
+
+#define ret_ERRVAL PSEUDO_RET_ERRVAL
+
+#undef	PSEUDO_END_ERRVAL
+#define	PSEUDO_END_ERRVAL(name) \
+  END (name)
+
 /* Label in text section.  */
 /* ppc64 function descriptors which requires . notation */
 #define C_TEXT(name) .##name
diff --git a/sysdeps/sparc/sparc32/dl-machine.h b/sysdeps/sparc/sparc32/dl-machine.h
index 45bb0bf152..f43b4788ef 100644
--- a/sysdeps/sparc/sparc32/dl-machine.h
+++ b/sysdeps/sparc/sparc32/dl-machine.h
@@ -40,12 +40,6 @@
 #define OPCODE_SAVE_SP	0x9de3bfa8 /* save %sp, -(16+6)*4, %sp */
 #define OPCODE_BA	0x30800000 /* b,a ?; add PC-rel word address */
 
-/* Protect some broken versions of gcc from misinterpreting weak addresses.  */
-#define WEAKADDR(x)	({ __typeof(x) *_px = &x;			\
-			   __asm ("" : "=r" (_px) : "0" (_px));		\
-			   _px; })
-
-
 /* Use a different preload file when running in 32-bit emulation mode
    on a 64-bit host.  */
 #define LD_SO_PRELOAD ((GL(dl_hwcap) & HWCAP_SPARC_V9) \
@@ -61,16 +55,13 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
     return 1;
   else if (ehdr->e_machine == EM_SPARC32PLUS)
     {
-      unsigned long *hwcap;
-#ifndef SHARED
-      weak_extern (_dl_hwcap);
-      weak_extern (_dl_hwcap_mask);
-#endif
-
-      hwcap = WEAKADDR (GL(dl_hwcap));
       /* XXX The following is wrong!  Dave Miller rejected to implement it
 	 correctly.  If this causes problems shoot *him*!  */
-      return hwcap == NULL || (*hwcap & GL(dl_hwcap_mask) & HWCAP_SPARC_V9);
+#ifdef SHARED
+      return GL(dl_hwcap) & GL(dl_hwcap_mask) & HWCAP_SPARC_V9;
+#else
+      return GL(dl_hwcap) & HWCAP_SPARC_V9;
+#endif
     }
   else
     return 0;
@@ -170,17 +161,12 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
 	  || __builtin_expect (l->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL, 0))
 	{
 	  /* Need to reinitialize .plt to undo prelinking.  */
-	  unsigned long *hwcap;
 	  int do_flush;
 	  Elf32_Rela *rela = (Elf32_Rela *) D_PTR (l, l_info[DT_JMPREL]);
 	  Elf32_Rela *relaend
 	    = (Elf32_Rela *) ((char *) rela
 			      + l->l_info[DT_PLTRELSZ]->d_un.d_val);
-#ifndef SHARED
-	  weak_extern (_dl_hwcap);
-#endif
-	  hwcap = WEAKADDR (GL(dl_hwcap));
-	  do_flush = (!hwcap || (*hwcap & HWCAP_SPARC_FLUSH));
+	  do_flush = GL(dl_hwcap) & HWCAP_SPARC_FLUSH;
 
 	  /* prelink must ensure there are no R_SPARC_NONE relocs left
 	     in .rela.plt.  */
@@ -367,13 +353,7 @@ sparc_fixup_plt (const Elf32_Rela *reloc, Elf32_Addr *reloc_addr,
 #ifndef RTLD_BOOTSTRAP
   /* Note that we don't mask the hwcap here, as the flush is essential to
      functionality on those cpu's that implement it.  */
-  unsigned long *hwcap;
-  int do_flush;
-# ifndef SHARED
-  weak_extern (_dl_hwcap);
-# endif
-  hwcap = WEAKADDR (GL(dl_hwcap));
-  do_flush = (!hwcap || (*hwcap & HWCAP_SPARC_FLUSH));
+  int do_flush = GL(dl_hwcap) & HWCAP_SPARC_FLUSH;
 #else
   /* Unfortunately, this is necessary, so that we can ensure
      ld.so will not execute corrupt PLT entry instructions. */
diff --git a/sysdeps/unix/alpha/sysdep.h b/sysdeps/unix/alpha/sysdep.h
index b9bc1c0a2a..f12edef7a7 100644
--- a/sysdeps/unix/alpha/sysdep.h
+++ b/sysdeps/unix/alpha/sysdep.h
@@ -134,6 +134,21 @@ __LABEL(name)						\
 
 #define ret_NOERRNO ret
 
+#define PSEUDO_ERRVAL(name, syscall_name, args)	\
+	.globl name;					\
+	.align 4;					\
+	.ent name,0;					\
+__LABEL(name)						\
+	PSEUDO_PROLOGUE;				\
+	PSEUDO_PREPARE_ARGS				\
+	lda	v0, SYS_ify(syscall_name);		\
+	call_pal PAL_callsys;
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(sym)  END(sym)
+
+#define ret_ERRVAL ret
+
 #define r0	v0
 #define r1	a4
 
diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h
index 13a3752dc8..dd2795edc4 100644
--- a/sysdeps/unix/mips/sysdep.h
+++ b/sysdeps/unix/mips/sysdep.h
@@ -51,6 +51,18 @@
 
 #define ret_NOERRNO ret
 
+#define PSEUDO_ERRVAL(name, syscall_name, args)	\
+  .align 2;						\
+  ENTRY(name)						\
+  .set noreorder;					\
+  li v0, SYS_ify(syscall_name);				\
+  syscall
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(sym) .end sym; .size sym,.-sym
+
+#define ret_ERRVAL ret
+
 #define r0	v0
 #define r1	v1
 /* The mips move insn is d,s.  */
diff --git a/sysdeps/unix/sparc/sysdep.h b/sysdeps/unix/sparc/sysdep.h
index 3f6a92a904..24225d9622 100644
--- a/sysdeps/unix/sparc/sysdep.h
+++ b/sysdeps/unix/sparc/sysdep.h
@@ -58,8 +58,15 @@
   mov SYS_ify(syscall_name), %g1;		\
   ta 0
 
+#define	PSEUDO_ERRVAL(name, syscall_name, args) \
+  .global syscall_error;			\
+  ENTRY (name)					\
+  mov SYS_ify(syscall_name), %g1;		\
+  ta 0
+
 #define	ret		retl; nop
 #define	ret_NOERRNO	retl; nop
+#define	ret_ERRVAL	retl; nop
 #define	r0		%o0
 #define	r1		%o1
 #define	MOVE(x,y)	mov x, y
diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h
index 4619335d0a..11e5317dff 100644
--- a/sysdeps/unix/sysdep.h
+++ b/sysdeps/unix/sysdep.h
@@ -50,6 +50,9 @@
 #ifndef PSEUDO_END_NOERRNO
 #define PSEUDO_END_NOERRNO(sym)	PSEUDO_END(sym)
 #endif
+#ifndef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(sym)	PSEUDO_END(sym)
+#endif
 
 /* Wrappers around system calls should normally inline the system call code.
    But sometimes it is not possible or implemented and we use this code.  */
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 60235d012f..d30a9b6b55 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -21,7 +21,7 @@ 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	Vi:iiii	posix_fadvise64	posix_fadvise
 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/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index 6aa5ce30ad..1ae69407ff 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -12,7 +12,3 @@ endif
 ifeq ($(subdir),resource)
 sysdep_routines += oldgetrlimit64
 endif
-
-ifeq ($(subdir),io)
-sysdep_routines += posix_fadvise64_64
-endif
diff --git a/sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S b/sysdeps/unix/sysv/linux/i386/posix_fadvise64.S
index c1ee9b99dd..8d7219f12b 100644
--- a/sysdeps/unix/sysv/linux/i386/posix_fadvise64_64.S
+++ b/sysdeps/unix/sysv/linux/i386/posix_fadvise64.S
@@ -93,7 +93,7 @@ ENTRY (BP_SYM (__posix_fadvise64_l64))
 	movl	LENLO(%esp), %esi
 	movl	FLAGS(%esp), %edi
 
-	movl	$SYS_ify(fadvise64_64), %eax
+	movl	$SYS_ify(fadvise64), %eax
 	ENTER_KERNEL
 
 	/* Restore registers.  */
@@ -115,6 +115,18 @@ L(overflow):
 	ret
 #endif
 
-PSEUDO_END_NOERRNO (BP_SYM (__posix_fadvise64_l64))
+END (BP_SYM (__posix_fadvise64_l64))
+
+#ifdef __NR_fadvise64
+PSEUDO_ERRVAL (__posix_fadvise64_l32, posix_fadvise64, 5)
+	ret
+PSEUDO_END_ERRVAL (__posix_fadvise64_l32)
+#else
+ENTRY (BP_SYM (__posix_fadvise64_l32))
+	movl	$ENOSYS, %eax
+	ret
+END (BP_SYM (__posix_fadvise64_l32))
+#endif
 
 default_symbol_version (__posix_fadvise64_l64, posix_fadvise64, GLIBC_2.3.3)
+symbol_version (__posix_fadvise64_l32, posix_fadvise64, GLIBC_2.2)
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index c2027b670f..5d83df7a6e 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -5,7 +5,7 @@ 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	Vi:iiii	posix_fadvise64	posix_fadvise
 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/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c
index 808fc865ed..30a6d9e5be 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise.c
@@ -27,10 +27,14 @@ int
 posix_fadvise (int fd, off_t offset, off_t len, int advise)
 {
 #ifdef __NR_fadvise64
-  return INLINE_SYSCALL (fadvise64, 5, fd,
-			 __LONG_LONG_PAIR (offset >> 31, offset), len, advise);
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL (fadvise64, err, 5, fd,
+			      __LONG_LONG_PAIR (offset >> 31, offset), len,
+			      advise);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return 0;
 #else
-  __set_errno (ENOSYS);
-  return -1;
+  return ENOSYS;
 #endif
 }
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c
new file mode 100644
index 0000000000..89dfd8cdc3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 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 <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <kernel-features.h>
+
+int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise);
+int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise);
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
+{
+#ifdef __NR_fadvise64_64
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
+			      __LONG_LONG_PAIR (offset >> 32, offset),
+			      __LONG_LONG_PAIR (len >> 32, len),
+			      advise);
+  if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
+    return 0;
+# ifndef __ASSUME_FADVISE64_64_SYSCALL
+  if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
+# endif
+   return INTERNAL_SYSCALL_ERRNO (ret, err);
+#endif
+#ifndef __ASSUME_FADVISE64_64_SYSCALL
+# ifdef __NR_fadvise64
+  if (len != (off_t) len)
+    return EOVERFLOW;
+
+  INTERNAL_SYSCALL_DECL (err2);
+  int ret2 = INTERNAL_SYSCALL (fadvise64, err2, 5, fd,
+			       __LONG_LONG_PAIR (offset >> 32, offset),
+			       (off_t) len, advise);
+  if (!INTERNAL_SYSCALL_ERROR_P (ret2, err2))
+    return 0;
+  return INTERNAL_SYSCALL_ERRNO (ret2, err2);
+# else
+  return ENOSYS;
+# endif
+#endif
+}
+
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3)
+
+int
+__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise)
+{
+  return __posix_fadvise64_l64 (fd, offset, len, advise);
+}
+
+versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3);
+compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
+#else
+strong_alias (__posix_fadvise64_l64, posix_fadvise64);
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions
index d0bf4a89c0..6d0795817f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Versions
@@ -20,4 +20,7 @@ libc {
     # s*
     scandir64;
   }
+  GLIBC_2.3.3 {
+    posix_fadvise64;
+  }
 }
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
index 9dbe0ed29e..7f7c7e8e1d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
@@ -25,7 +25,7 @@ s_getrlimit	getrlimit getrlimit	i:ip	__syscall_getrlimit
 s_lstat64	lxstat64 lstat64	i:sp	__syscall_lstat64
 s_mmap2		mmap64	mmap2		b:aniiii __syscall_mmap2
 s_poll		poll	poll		i:pii	__syscall_poll
-posix_fadvise64	-	fadvise64	4	posix_fadvise64	posix_fadvise
+posix_fadvise64	-	fadvise64	Vi:iiii	posix_fadvise64	posix_fadvise
 s_ptrace	ptrace	ptrace		i:iipp	__syscall_ptrace
 s_putpmsg	putpmsg	putpmsg		i:ippii	__syscall_putpmsg
 s_reboot	reboot	reboot		i:iii	__syscall_reboot
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/Versions b/sysdeps/unix/sysv/linux/s390/s390-32/Versions
index 3c45a30778..da461a57a0 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/Versions
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/Versions
@@ -23,5 +23,8 @@ libc {
     # v*
     versionsort64;
   }
+  GLIBC_2.3.3 {
+    posix_fadvise64;
+  }
 }
 
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 95cfd21857..d759e4a664 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -69,6 +69,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);					      \
+    lcr %r2,%r2
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name)						      \
+  END (name)
+
 #ifndef PIC
 # define SYSCALL_ERROR_LABEL 0f
 # define SYSCALL_ERROR_HANDLER \
@@ -156,6 +167,9 @@
 #define ret_NOERRNO							      \
     br      14
 
+#define ret_ERRVAL							      \
+    br      14
+
 #endif /* __ASSEMBLER__ */
 
 #undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index c2bf5c3307..e114994c0d 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -10,7 +10,7 @@ getpeername	-	getpeername	i:ipp	__getpeername	getpeername
 ftruncate	-	ftruncate	2	__ftruncate	ftruncate ftruncate64 __ftruncate64
 truncate	-	truncate	2	truncate	truncate64
 getrlimit	-	getrlimit	2	__getrlimit	getrlimit getrlimit64
-posix_fadvise64	-	fadvise64	4	posix_fadvise64	posix_fadvise
+posix_fadvise64	-	fadvise64	Vi:iiii	posix_fadvise64	posix_fadvise
 setrlimit	-	setrlimit	2	__setrlimit	setrlimit setrlimit64
 vfork		-	vfork		0	__vfork		vfork
 
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 9abc06e229..2fb6e7a0cf 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -83,6 +83,18 @@
   SYSCALL_ERROR_HANDLER;						      \
   END (name)
 
+#undef PSEUDO_ERRVAL
+#define	PSEUDO_ERRVAL(name, syscall_name, args)				      \
+  .text;								      \
+  ENTRY (name)								      \
+    DO_CALL (syscall_name, args);					      \
+    lcgr %r2,%r2
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name)						      \
+  SYSCALL_ERROR_HANDLER;						      \
+  END (name)
+
 #ifndef PIC
 # define SYSCALL_ERROR_LABEL syscall_error
 # define SYSCALL_ERROR_HANDLER
@@ -158,6 +170,9 @@
 #define ret_NOERRNO							      \
     br	    14
 
+#define ret_ERRVAL							      \
+    br	    14
+
 #endif /* __ASSEMBLER__ */
 
 #undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/Versions b/sysdeps/unix/sysv/linux/sparc/sparc32/Versions
index 4529e7fe6f..e6903728f3 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/Versions
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/Versions
@@ -17,4 +17,7 @@ libc {
     # s*
     scandir64;
   }
+  GLIBC_2.3.3 {
+    posix_fadvise64;
+  }
 }
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
index bc54b107c4..6dcf0cd57f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
@@ -25,6 +25,7 @@
 #ifdef IS_IN_rtld
 # include <dl-sysdep.h>		/* Defines RTLD_PRIVATE_ERRNO.  */
 #endif
+#include <tls.h>
 
 #undef SYS_ify
 #define SYS_ify(syscall_name) __NR_##syscall_name
@@ -36,6 +37,7 @@
 /* Linux/SPARC uses a different trap number */
 #undef PSEUDO
 #undef PSEUDO_NOERRNO
+#undef PSEUDO_ERRVAL
 #undef ENTRY
 #undef END
 #undef LOC
@@ -86,6 +88,47 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
 	jmpl	%i7+8, %g0;						\
 	 restore %g0, -1, %o0;						\
 	.previous;
+#elif USE___THREAD
+# ifndef NOT_IN_libc
+#  define SYSCALL_ERROR_ERRNO __libc_errno
+# else
+#  define SYSCALL_ERROR_ERRNO errno
+# endif
+# ifdef SHARED
+#  define SYSCALL_ERROR_HANDLER						\
+	.section .gnu.linkonce.t.__sparc.get_pic.l7,"ax",@progbits;	\
+	.globl __sparc.get_pic.l7;					\
+	.hidden __sparc.get_pic.l7;					\
+	.type __sparc.get_pic.l7,@function;				\
+__sparc.get_pic.l7:							\
+	retl;								\
+	 add	%o7, %l7, %l7;						\
+	.previous;							\
+SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
+	save	%sp,-96,%sp;						\
+	sethi	%tie_hi22(SYSCALL_ERROR_ERRNO), %l1;			\
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %l7;			\
+	call	__sparc.get_pic.l7;					\
+	 add	%l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7;			\
+	add	%l1, %tie_lo10(SYSCALL_ERROR_ERRNO), %l1;		\
+	ld	[%l7 + %l1], %l1, %tie_ld(SYSCALL_ERROR_ERRNO);		\
+	st	%i0, [%g7 + %l1], %tie_add(SYSCALL_ERROR_ERRNO);	\
+	jmpl	%i7+8, %g0;						\
+	 restore %g0, -1, %o0;						\
+	.previous;
+# else
+#  define SYSCALL_ERROR_HANDLER						\
+SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
+	sethi	%tie_hi22(SYSCALL_ERROR_ERRNO), %g1;			\
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_), %g2;			\
+	add	%g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1;		\
+	add	%g2, %lo(_GLOBAL_OFFSET_TABLE_), %g2;			\
+	ld	[%g2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO);		\
+	st	%o0, [%g7 + %g1], %tie_add(SYSCALL_ERROR_ERRNO);	\
+	jmpl	%o7+8, %g0;						\
+	 mov	-1, %o0;						\
+	.previous;
+# endif
 #else
 # define SYSCALL_ERROR_HANDLER						\
 SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
@@ -115,6 +158,12 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
 	LOADSYSCALL(syscall_name);				\
 	ta 0x10
 
+#define PSEUDO_ERRVAL(name, syscall_name, args)			\
+	.text;							\
+	ENTRY(name);						\
+	LOADSYSCALL(syscall_name);				\
+	ta 0x10
+
 #else  /* __ASSEMBLER__ */
 
 #define __SYSCALL_STRING						\
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
index ac0610feda..d480d25c38 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
@@ -13,7 +13,7 @@ truncate	-	truncate	2	truncate	truncate64
 mmap		-	mmap		6	__mmap		mmap __mmap64 mmap64
 readahead	-	readahead	3	__readahead	readahead
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
-posix_fadvise64	-	fadvise64	4	posix_fadvise64	posix_fadvise
+posix_fadvise64	-	fadvise64	Vi:iiii	posix_fadvise64	posix_fadvise
 
 # Override select.S in parent directory:
 select		-	select		C:5	__select	select
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
index c16e8ff673..5340fca9d1 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
@@ -36,6 +36,7 @@
 /* Linux/SPARC uses a different trap number */
 #undef PSEUDO
 #undef PSEUDO_NOERRNO
+#undef PSEUDO_ERRVAL
 #undef ENTRY
 
 #define ENTRY(name)							\
@@ -108,6 +109,12 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
 	LOADSYSCALL(syscall_name);					\
 	ta	0x6d
 
+#define PSEUDO_ERRVAL(name, syscall_name, args)				\
+	.text;								\
+	ENTRY(name);							\
+	LOADSYSCALL(syscall_name);					\
+	ta	0x6d
+
 #undef PSEUDO_END
 #define PSEUDO_END(name)						\
 	.size name,.-name
@@ -116,6 +123,10 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
 #define PSEUDO_END_NOERRNO(name)					\
 	.size name,.-name
 
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name)						\
+	.size name,.-name
+
 #undef END
 #define END(name)							\
 	.size name,.-name
@@ -123,6 +134,7 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler)			\
 /* Careful here!  This "ret" define can interfere; use jmpl if unsure.  */
 #define ret		retl; nop
 #define ret_NOERRNO	retl; nop
+#define ret_ERRVAL	retl; nop
 #define r0              %o0
 #define r1              %o1
 #define MOVE(x,y)       mov x, y
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index cf1a121b20..188401bab7 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -44,8 +44,6 @@ 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	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 26f2b07250..9fea709edb 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -4,7 +4,7 @@ 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
+posix_fadvise64	-	fadvise64	Vi:iiii	posix_fadvise64	posix_fadvise
 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