This is the mail archive of the libc-alpha@sources.redhat.com 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]

[PATCH] alpha compilation fix with the kernel header < 2.6.4.


This patch fixes alpha compilation fix when kernel header (< 2.6.4) is
used.  I update it from my previous patch that does not use
__ASSUME_STAT64_SYSCALL suggested by Ulrich.  I tested it with three
patterns.  Note that I unfold the original "fail:" part because
enclosing only "fail:" with #ifdef __ASSUME_STAT64_SYSCALL and
__NR_*stat64 looks unseemly.

Regards,
-- gotom

2005-02-26  GOTO Masanori  <gotom@debian.or.jp>

	* sysdeps/unix/sysv/linux/kernel-features.h: Define
	__ASSUME_STAT64_SYSCALL.
	* sysdeps/unix/sysv/linux/alpha/fxstat.c: Check
	__ASSUME_STAT64_SYSCALL.
	* sysdeps/unix/sysv/linux/alpha/lxstat.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/xstat.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/xstatconv.c: Don't define
	__libc_missing_axp_stat64 when it's not needed.
	* sysdeps/unix/sysv/linux/alpha/xstatconv.h: Likewise.

Index: sysdeps/unix/sysv/linux/kernel-features.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/kernel-features.h,v
retrieving revision 1.83
diff -u -p -r1.83 kernel-features.h
--- sysdeps/unix/sysv/linux/kernel-features.h	26 Jan 2005 20:01:10 -0000	1.83
+++ sysdeps/unix/sysv/linux/kernel-features.h	18 Feb 2005 06:21:10 -0000
@@ -413,6 +413,11 @@
 # define __ASSUME_GETDENTS32_D_TYPE	1
 #endif
 
+/* Starting with version 2.6.4, alpha stat64 syscalls are available.  */
+#if __LINUX_KERNEL_VERSION >= 0x020604 && defined __alpha__
+# define __ASSUME_STAT64_SYSCALL	1
+#endif
+
 /* Starting with version 2.5.3, the initial location returned by `brk'
    after exec is always rounded up to the next page.  */
 #if __LINUX_KERNEL_VERSION >= 132355
Index: sysdeps/unix/sysv/linux/alpha/fxstat.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/fxstat.c,v
retrieving revision 1.1
diff -u -p -r1.1 fxstat.c
--- sysdeps/unix/sysv/linux/alpha/fxstat.c	11 Mar 2004 02:58:44 -0000	1.1
+++ sysdeps/unix/sysv/linux/alpha/fxstat.c	18 Feb 2005 06:21:10 -0000
@@ -1,5 +1,5 @@
 /* fxstat using old-style Unix stat system call.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 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
@@ -35,27 +35,39 @@ int
 __fxstat (int vers, int fd, struct stat *buf)
 {
   INTERNAL_SYSCALL_DECL (err);
-  int result, errno_out;
+  int result;
   struct kernel_stat kbuf;
 
+#if __ASSUME_STAT64_SYSCALL > 0
+  if (vers == _STAT_VER_KERNEL64)
+    {
+      result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
+      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	return result;
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      return -1;
+    }
+#elif defined __NR_fstat64
   if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
     {
+      int errno_out;
       result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
       if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
 	return result;
       errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
       if (errno_out != ENOSYS)
-	goto fail;
+	{
+	  __set_errno (errno_out);
+	  return -1;
+	}
       __libc_missing_axp_stat64 = 1;
     }
+#endif
 
   result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
     return __xstat_conv (vers, &kbuf, buf);
-  errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
-  
- fail:
-  __set_errno (errno_out);
+  __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
   return -1;
 }
 hidden_def (__fxstat)
Index: sysdeps/unix/sysv/linux/alpha/lxstat.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/lxstat.c,v
retrieving revision 1.1
diff -u -p -r1.1 lxstat.c
--- sysdeps/unix/sysv/linux/alpha/lxstat.c	11 Mar 2004 02:58:44 -0000	1.1
+++ sysdeps/unix/sysv/linux/alpha/lxstat.c	18 Feb 2005 06:21:10 -0000
@@ -1,5 +1,5 @@
 /* lxstat using old-style Unix stat system call.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 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
@@ -35,27 +35,39 @@ int
 __lxstat (int vers, const char *name, struct stat *buf)
 {
   INTERNAL_SYSCALL_DECL (err);
-  int result, errno_out;
+  int result;
   struct kernel_stat kbuf;
 
+#if __ASSUME_STAT64_SYSCALL > 0
+  if (vers == _STAT_VER_KERNEL64)
+    {
+      result = INTERNAL_SYSCALL (lstat64, err, 2, name, buf);
+      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	return result;
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      return -1;
+    }
+#elif defined __NR_lstat64
   if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
     {
+      int errno_out;
       result = INTERNAL_SYSCALL (lstat64, err, 2, name, buf);
       if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
 	return result;
       errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
       if (errno_out != ENOSYS)
-	goto fail;
+	{
+	  __set_errno (errno_out);
+	  return -1;
+	}
       __libc_missing_axp_stat64 = 1;
     }
+#endif
 
   result = INTERNAL_SYSCALL (lstat, err, 2, name, &kbuf);
   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
     return __xstat_conv (vers, &kbuf, buf);
-  errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
-  
- fail:
-  __set_errno (errno_out);
+  __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
   return -1;
 }
 hidden_def (__lxstat)
Index: sysdeps/unix/sysv/linux/alpha/xstat.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/xstat.c,v
retrieving revision 1.1
diff -u -p -r1.1 xstat.c
--- sysdeps/unix/sysv/linux/alpha/xstat.c	11 Mar 2004 02:58:44 -0000	1.1
+++ sysdeps/unix/sysv/linux/alpha/xstat.c	18 Feb 2005 06:21:10 -0000
@@ -1,5 +1,5 @@
 /* xstat using old-style Unix stat system call.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 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
@@ -35,27 +35,39 @@ int
 __xstat (int vers, const char *name, struct stat *buf)
 {
   INTERNAL_SYSCALL_DECL (err);
-  int result, errno_out;
+  int result;
   struct kernel_stat kbuf;
 
+#if __ASSUME_STAT64_SYSCALL > 0
+  if (vers == _STAT_VER_KERNEL64)
+    {
+      result = INTERNAL_SYSCALL (stat64, err, 2, name, buf);
+      if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	return result;
+      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+      return -1;
+    }
+#elif defined __NR_stat64
   if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
     {
+      int errno_out;
       result = INTERNAL_SYSCALL (stat64, err, 2, name, buf);
       if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
 	return result;
       errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
       if (errno_out != ENOSYS)
-	goto fail;
+	{
+	  __set_errno (errno_out);
+	  return -1;
+	}
       __libc_missing_axp_stat64 = 1;
     }
+#endif
 
   result = INTERNAL_SYSCALL (stat, err, 2, name, &kbuf);
   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
     return __xstat_conv (vers, &kbuf, buf);
-  errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
-  
- fail:
-  __set_errno (errno_out);
+  __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
   return -1;
 }
 hidden_def (__xstat)
Index: sysdeps/unix/sysv/linux/alpha/xstatconv.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/xstatconv.c,v
retrieving revision 1.6
diff -u -p -r1.6 xstatconv.c
--- sysdeps/unix/sysv/linux/alpha/xstatconv.c	11 Mar 2004 02:58:44 -0000	1.6
+++ sysdeps/unix/sysv/linux/alpha/xstatconv.c	26 Feb 2005 13:58:07 -0000
@@ -1,5 +1,5 @@
 /* Convert between the kernel's `struct stat' format, and libc's.
-   Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2003, 2004, 2005 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
@@ -22,9 +22,14 @@
 #include <sys/stat.h>
 #include <kernel_stat.h>
 #include <xstatconv.h>
+#include <sys/syscall.h>
 
 
+#ifdef __NR_stat64
+# if __ASSUME_STAT64_SYSCALL == 0
 int __libc_missing_axp_stat64;
+# endif
+#endif
 
 int
 __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
Index: sysdeps/unix/sysv/linux/alpha/xstatconv.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/xstatconv.h,v
retrieving revision 1.1
diff -u -p -r1.1 xstatconv.h
--- sysdeps/unix/sysv/linux/alpha/xstatconv.h	11 Mar 2004 02:58:44 -0000	1.1
+++ sysdeps/unix/sysv/linux/alpha/xstatconv.h	26 Feb 2005 13:58:07 -0000
@@ -1,5 +1,5 @@
 /* Convert between the kernel's `struct stat' format, and libc's.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 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,12 @@
    02111-1307 USA.  */
 
 #include "kernel-features.h"
+#include <sys/syscall.h>
 
+#ifdef __NR_stat64
+# if __ASSUME_STAT64_SYSCALL == 0
 extern int __libc_missing_axp_stat64 attribute_hidden;
+# endif
+#endif
 extern int __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
   attribute_hidden;


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