This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Remove __ASSUME_FADVISE64_64_SYSCALL


The macro __ASSUME_FADVISE64_64_SYSCALL is defined (for all supported
kernel versions) for i386, sparc and powerpc32 in libc, and for m68k
and tile in ports.

This macro is used in the following files:
sysdeps/unix/sysv/linux/i386/posix_fadvise64.S
sysdeps/unix/sysv/linux/posix_fadvise64.c
sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c
sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c.  None of those
files is used indirectly by #include anywhere.
sysdeps/unix/sysv/linux/posix_fadvise64.c is overridden by
sysdeps/unix/sysv/linux/wordsize-64/posix_fadvise64.c on architectures
using sysdeps/unix/sysv/linux/wordsize-64/, and ARM and MIPS (for all
MIPS ABIs) also have their own versions of posix_fadvise64.c.  Thus
the architectures that do not define __ASSUME_FADVISE64_64_SYSCALL,
but use code that tests that macro, are s390-32 and sh in libc, and
am33 and hppa in ports.

2.6.16 has the fadvise64_64 syscall for s390-32, sh and hppa, and
2.6.25 has it for am33, so it is indeed safe to remove this macro and
associated conditionals (including ones on whether __NR_fadvise64_64
is defined), which this patch does.  Tested x86.

(The changes to sysdeps/unix/sysv/linux/i386/posix_fadvise64.S are,
strictly, not just removing code that would not have been built anyway
given the minimum supported kernels; the fallback compatibility code
had its own #else case with an ENOSYS return, and posix_fadvise64 for
i386 would previously have been built as the function implementation
in terms of the fadvise64_64 syscall, immediately followed by the
unreachable code

        movl    $ENOSYS, %eax
        ret

and this patch removes those two unreachable instructions as well as
the code that actually would not have been built at all.)

2012-08-20  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_FADVISE64_64_SYSCALL): Remove.
	* sysdeps/unix/sysv/linux/i386/posix_fadvise64.S: Do not include
	<kernel-features.h>.
	[__NR_fadvise64_64]: Make code unconditional.
	[!__ASSUME_FADVISE64_64_SYSCALL]: Remove conditional code.
	[__NR_fadvise64 && (!__ASSUME_FADVISE64_64_SYSCALL ||
	!__NR_fadvise64_64)]: Likewise.
	[!(__NR_fadvise64 && (!__ASSUME_FADVISE64_64_SYSCALL ||
	!__NR_fadvise64_64))]: Likewise.
	[__NR_fadvise64]: Make code unconditional.
	[!__NR_fadvise64]: Remove conditional code.
	* sysdeps/unix/sysv/linux/posix_fadvise64.c: Do not include
	<kernel-features.h>.
	(__posix_fadvise64_l64) [__NR_fadvise64_64]: Make code
	unconditional.
	(_posix_fadvise64_l64) [!__ASSUME_FADVISE64_64_SYSCALL]: Remove
	conditional code.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c: Do
	not include <kernel-features.h>.
	(__posix_fadvise64_l64) [__NR_fadvise64_64]: Make code
	unconditional.
	(_posix_fadvise64_l64) [!__ASSUME_FADVISE64_64_SYSCALL]: Remove
	conditional code.
	* sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c: Do not
	include <kernel-features.h>.
	(__posix_fadvise64_l64) [__NR_fadvise64_64]: Make code
	unconditional.
	(_posix_fadvise64_l64) [!__ASSUME_FADVISE64_64_SYSCALL]: Remove
	conditional code.

ports/ChangeLog.m68k:
2012-08-20  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_FADVISE64_64_SYSCALL): Remove.

ports/ChangeLog.tile:
2012-08-20  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	(__ASSUME_FADVISE64_64_SYSCALL): Remove.

diff --git a/ports/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/ports/sysdeps/unix/sysv/linux/m68k/kernel-features.h
index 701600e..3df653c 100644
--- a/ports/sysdeps/unix/sysv/linux/m68k/kernel-features.h
+++ b/ports/sysdeps/unix/sysv/linux/m68k/kernel-features.h
@@ -22,7 +22,6 @@
 
 /* Many syscalls were added in 2.6.10 for m68k.  */
 #define __ASSUME_UTIMES	1
-#define __ASSUME_FADVISE64_64_SYSCALL	1
 
 #include_next <kernel-features.h>
 
diff --git a/ports/sysdeps/unix/sysv/linux/tile/kernel-features.h b/ports/sysdeps/unix/sysv/linux/tile/kernel-features.h
index 0463448..cebfac4 100644
--- a/ports/sysdeps/unix/sysv/linux/tile/kernel-features.h
+++ b/ports/sysdeps/unix/sysv/linux/tile/kernel-features.h
@@ -20,7 +20,6 @@
 /* TILE glibc support starts with 2.6.36, guaranteeing many kernel features. */
 #define __ASSUME_STAT64_SYSCALL		1
 #define __ASSUME_UTIMES			1
-#define __ASSUME_FADVISE64_64_SYSCALL	1
 #define __ASSUME_O_CLOEXEC		1
 #define __ASSUME_SOCK_CLOEXEC		1
 #define __ASSUME_IN_NONBLOCK		1
diff --git a/sysdeps/unix/sysv/linux/i386/posix_fadvise64.S b/sysdeps/unix/sysv/linux/i386/posix_fadvise64.S
index 79fc071..00e6a41 100644
--- a/sysdeps/unix/sysv/linux/i386/posix_fadvise64.S
+++ b/sysdeps/unix/sysv/linux/i386/posix_fadvise64.S
@@ -1,5 +1,4 @@
-/* Copyright (C) 1995-2000,2002,2003,2004,2005,2006
-	Free Software Foundation, Inc.
+/* Copyright (C) 1995-2012 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
@@ -20,8 +19,6 @@
 #include <bp-sym.h>
 #include <bp-asm.h>
 
-#include <kernel-features.h>
-
 #define EINVAL	22
 #define ENOSYS	38
 #define EOVERFLOW 75
@@ -38,8 +35,6 @@
 	.text
 ENTRY (BP_SYM (__posix_fadvise64_l64))
 
-#ifdef __NR_fadvise64_64
-
 	/* Save registers.  */
 	pushl	%ebp
 	cfi_adjust_cfa_offset (4)
@@ -78,11 +73,6 @@ ENTRY (BP_SYM (__posix_fadvise64_l64))
 	cfi_adjust_cfa_offset (-4)
 	cfi_restore (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.  */
@@ -90,72 +80,15 @@ ENTRY (BP_SYM (__posix_fadvise64_l64))
 
 	/* 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
-	cfi_adjust_cfa_offset (4)
-	pushl	%esi
-	cfi_adjust_cfa_offset (4)
-	pushl	%edi
-	cfi_adjust_cfa_offset (4)
-
-	/* Overflow check.  */
-	cmpl	$0, LENHI(%esp)
-	movl	$-EOVERFLOW, %eax
-	jne	L(overflow)
-
-	movl	FD(%esp), %ebx
-	cfi_rel_offset (ebx, 8)
-	movl	OFFLO(%esp), %ecx
-	movl	OFFHI(%esp), %edx
-	movl	LENLO(%esp), %esi
-	cfi_rel_offset (esi, 4)
-	movl	FLAGS(%esp), %edi
-	cfi_rel_offset (edi, 0)
-
-	movl	$SYS_ify(fadvise64), %eax
-	ENTER_KERNEL
-
-	/* Restore registers.  */
-L(overflow):
-	popl	%edi
-	cfi_adjust_cfa_offset (-4)
-	cfi_restore (edi)
-	popl	%esi
-	cfi_adjust_cfa_offset (-4)
-	cfi_restore (esi)
-	popl	%ebx
-	cfi_adjust_cfa_offset (-4)
-	cfi_restore (ebx)
-
-	/* If 0 > %eax > -4096 there was an error.  */
-	negl	%eax
-
-	/* Successful; return the syscall's value.  */
-	ret
-#else
-	movl	$ENOSYS, %eax
-	ret
-#endif
 
 END (BP_SYM (__posix_fadvise64_l64))
 
-#ifdef __NR_fadvise64
 	.section	.text.compat, "ax"
 ENTRY (__posix_fadvise64_l32)
 	DO_CALL (fadvise64, 5)
 	negl %eax
 	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/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 2e45915..281faad 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -98,14 +98,6 @@
 # define __ASSUME_UTIMES	1
 #endif
 
-/* The fixed version of the posix_fadvise64 syscall appeared in
-   2.6.0-test3.  At least for x86 and sparc.  Powerpc support appeared
-   in 2.6.2, but for 32-bit userspace only.  */
-#if (defined __i386__ || defined __sparc__			\
-     || (defined __powerpc__ && !defined __powerpc64__))
-# define __ASSUME_FADVISE64_64_SYSCALL	1
-#endif
-
 /* On sparc64 stat64/lstat64/fstat64 syscalls were introduced in 2.6.12.  */
 #if defined __sparc__ && defined __arch64__
 # define __ASSUME_STAT64_SYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c
index 5d51cf2..3eea6de 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2012 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
@@ -18,7 +18,6 @@
 #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);
@@ -29,7 +28,6 @@ int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise);
 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 ((long) (offset >> 32),
@@ -39,28 +37,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
 			      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 ((long) (offset >> 32),
-						 (long) 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
+  return INTERNAL_SYSCALL_ERRNO (ret, err);
 }
 
 #include <shlib-compat.h>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c
index 2ffaec6..5b11e28 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/posix_fadvise64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2012 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
@@ -18,7 +18,6 @@
 #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);
@@ -29,34 +28,13 @@ int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise);
 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, advise,
 			      __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
 			      __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
   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, 6, fd, 0,
-			       __LONG_LONG_PAIR ((long)(offset >> 32), (long)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
+  return INTERNAL_SYSCALL_ERRNO (ret, err);
 }
 
 #include <shlib-compat.h>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
index 05b81ec..480b92f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2012 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
@@ -18,7 +18,6 @@
 #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);
@@ -37,7 +36,6 @@ struct fadvise64_64_layout
 int
 __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
 {
-#ifdef __NR_fadvise64_64
   struct fadvise64_64_layout parameters;
   INTERNAL_SYSCALL_DECL (err);
   
@@ -48,28 +46,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
   int ret = INTERNAL_SYSCALL (fadvise64_64, err, 1, &parameters);
   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 ((long) (offset >> 32),
-						 (long) 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
+  return INTERNAL_SYSCALL_ERRNO (ret, err);
 }
 
 #include <shlib-compat.h>

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]