public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: libc-ports@sourceware.org
Subject: [PATCH 07/10] alpha: Support __NR_fstatat64.
Date: Thu, 09 Feb 2012 04:36:00 -0000	[thread overview]
Message-ID: <1328761745-24481-8-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1328761745-24481-1-git-send-email-rth@twiddle.net>

---
 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c |    9 ++++
 sysdeps/unix/sysv/linux/alpha/fxstatat.c      |   63 ++++++++++++++++--------
 2 files changed, 51 insertions(+), 21 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c

diff --git a/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c b/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
new file mode 100644
index 0000000..41e83bc
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/dl-fxstatat64.c
@@ -0,0 +1,9 @@
+/* In this implementation we do not really care whether the call fails
+   because of missing kernel support since we do not even call the
+   function in this case.  */
+/* For Alpha, in <kernel-features.h> we redefine the default definition of
+   when __ASSUME_ATFCTS is present.  The hack must wait until after that.  */
+#include <kernel-features.h>
+#undef __ASSUME_ATFCTS
+#define __ASSUME_ATFCTS 1
+#include "fxstatat.c"
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat.c b/sysdeps/unix/sysv/linux/alpha/fxstatat.c
index 6fa3aeb..a6fd06b 100644
--- a/sysdeps/unix/sysv/linux/alpha/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/alpha/fxstatat.c
@@ -30,11 +30,44 @@
 
 #undef __fxstatat64
 
+#ifdef __ASSUME_ATFCTS
+# define __have_atfcts 1
+#endif
+#ifdef __ASSUME_STAT64_SYSCALL
+# define __libc_missing_axp_stat64 0
+#endif
 
 /* Get information about the file NAME in BUF.  */
 int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
+  INTERNAL_SYSCALL_DECL (err);
+  int result, errno_out;
+
+  /* ??? The __fxstatat entry point is new enough that it must be using
+     vers == _STAT_VER_KERNEL64.  For the benefit of dl-fxstatat64.c, we
+     cannot actually check this, lest the compiler not optimize the rest
+     of the function away.  */
+
+#ifdef __NR_fstatat64
+  if (__have_atfcts >= 0)
+    {
+      result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, st, flag);
+      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	return result;
+      errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+#ifndef __ASSUME_ATFCTS
+      if (errno_out == ENOSYS)
+	__have_atfcts = -1;
+      else
+#endif
+	{
+	  __set_errno (errno_out);
+	  return -1;
+	}
+    }
+#endif /* __NR_fstatat64 */
+
   if (flag & ~AT_SYMLINK_NOFOLLOW)
     {
       __set_errno (EINVAL);
@@ -67,12 +100,8 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       file = buf;
     }
 
-  INTERNAL_SYSCALL_DECL (err);
-  int result, errno_out;
-  struct kernel_stat kst;
-
-#if __ASSUME_STAT64_SYSCALL > 0
-  if (vers == _STAT_VER_KERNEL64)
+#ifdef __NR_stat64
+  if (!__libc_missing_axp_stat64)
     {
       if (flag & AT_SYMLINK_NOFOLLOW)
 	result = INTERNAL_SYSCALL (lstat64, err, 2, file, st);
@@ -82,24 +111,16 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
 	return result;
       errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
-      goto fail;
-    }
-#elif defined __NR_stat64
-  if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
-    {
-      if (flag & AT_SYMLINK_NOFOLLOW)
-	result = INTERNAL_SYSCALL (lstat64, err, 2, file, st);
+# if __ASSUME_STAT64_SYSCALL == 0
+      if (errno_out == ENOSYS)
+	__libc_missing_axp_stat64 = 1;
       else
-	result = INTERNAL_SYSCALL (stat64, err, 2, file, st);
-
-      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
-	return result;
-      errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
-      if (errno_out != ENOSYS)
+# endif
 	goto fail;
-      __libc_missing_axp_stat64 = 1;
     }
-#endif
+#endif /* __NR_stat64 */
+
+  struct kernel_stat kst;
 
   if (flag & AT_SYMLINK_NOFOLLOW)
     result = INTERNAL_SYSCALL (lstat, err, 2, file, &kst);
-- 
1.7.7.6

  parent reply	other threads:[~2012-02-09  4:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09  4:29 [PATCH 00/10] Alpha compilation fixes Richard Henderson
2012-02-09  4:29 ` [PATCH 01/10] alpha: Remove HAVE_TLS_SUPPORT and HAVE___THREAD tests Richard Henderson
2012-02-09  4:29 ` [PATCH 04/10] alpha: Define _STAT_VER_LINUX Richard Henderson
2012-02-09 17:52   ` Richard Henderson
2012-02-13  2:43     ` Carlos O'Donell
2012-02-09  4:29 ` [PATCH 02/10] alpha: Require kernel version 2.6.0 Richard Henderson
2012-02-09  4:29 ` [PATCH 06/10] alpha: Convert to crt[in].S Richard Henderson
2012-02-09  4:29 ` [PATCH 03/10] alpha: Define TLS_DTV_UNALLOCATED Richard Henderson
2012-02-09  4:29 ` [PATCH 05/10] alpha: Eliminate set-but-not-used warnings with internal syscalls Richard Henderson
2012-02-09  4:35 ` [PATCH 10/10] alpha: Add ldsodefs.h and tst-audit.h Richard Henderson
2012-02-09  4:35 ` [PATCH 09/10] alpha: Add tls-macros.h Richard Henderson
2012-02-09  4:35 ` [PATCH 08/10] alpha: Remove HAVE_ELF tests Richard Henderson
2012-02-09  4:36 ` Richard Henderson [this message]
2012-02-09 19:04 ` [PATCH 00/10] Alpha compilation fixes Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328761745-24481-8-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=libc-ports@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).