patches/glibc/ports-2.10.1/490-alpha_alpha-add-fdatasync-support.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jan 17 23:06:02 2010 +0100 (2010-01-17)
changeset 1740 c57458bb354d
permissions -rw-r--r--
configure: do not require hg when configuring in an hg clone

When configuring in an hg clone, we need hg to compute the version string.
It can happen that users do not have Mercurial (eg. if they got a snapshot
rather that they did a full clone). In this case, we can still run, of
course, so simply fill the version string with a sufficiently explicit
value, that does not require hg. The date is a good candidate.
yann@1625
     1
2009-07-25  Aurelien Jarno  <aurelien@aurel32.net>
yann@1625
     2
yann@1625
     3
	* sysdeps/unix/sysv/linux/kernel-features.h: define 
yann@1625
     4
	__ASSUME_FDATASYNC. 
yann@1625
     5
	* sysdeps/unix/sysv/linux/fdatasync.c: New file.
yann@1625
     6
	* sysdeps/unix/sysv/linux/Makefile: compile fdatasync.c with
yann@1625
     7
	-fexceptions.
yann@1625
     8
	* sysdeps/unix/sysv/linux/syscalls.list: Remove fdatasync.
yann@1625
     9
yann@1625
    10
 sysdeps/unix/sysv/linux/Makefile          |    1 
yann@1625
    11
 sysdeps/unix/sysv/linux/fdatasync.c       |   69 ++++++++++++++++++++++++++++++
yann@1625
    12
 sysdeps/unix/sysv/linux/kernel-features.h |    6 ++
yann@1625
    13
 sysdeps/unix/sysv/linux/syscalls.list     |    1 
yann@1625
    14
 4 files changed, 76 insertions(+), 1 deletion(-)
yann@1625
    15
yann@1625
    16
diff -durN glibc-2.10.1.orig/sysdeps/unix/sysv/linux/Makefile glibc-2.10.1/sysdeps/unix/sysv/linux/Makefile
yann@1625
    17
--- glibc-2.10.1.orig/sysdeps/unix/sysv/linux/Makefile	2009-03-02 17:15:13.000000000 +0100
yann@1625
    18
+++ glibc-2.10.1/sysdeps/unix/sysv/linux/Makefile	2009-11-13 00:51:04.000000000 +0100
yann@1625
    19
@@ -16,6 +16,7 @@
yann@1625
    20
 		   setfsuid setfsgid makedev epoll_pwait signalfd \
yann@1625
    21
 		   eventfd eventfd_read eventfd_write
yann@1625
    22
 
yann@1625
    23
+CFLAGS-fdatasync.c = -fexceptions
yann@1625
    24
 CFLAGS-gethostid.c = -fexceptions
yann@1625
    25
 
yann@1625
    26
 sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
yann@1625
    27
diff -durN glibc-2.10.1.orig/sysdeps/unix/sysv/linux/fdatasync.c glibc-2.10.1/sysdeps/unix/sysv/linux/fdatasync.c
yann@1625
    28
--- glibc-2.10.1.orig/sysdeps/unix/sysv/linux/fdatasync.c	1970-01-01 01:00:00.000000000 +0100
yann@1625
    29
+++ glibc-2.10.1/sysdeps/unix/sysv/linux/fdatasync.c	2009-11-13 00:51:04.000000000 +0100
yann@1625
    30
@@ -0,0 +1,69 @@
yann@1625
    31
+/* fdatasync -- synchronize at least the data part of a file with 
yann@1625
    32
+   the underlying media. Linux version. 
yann@1625
    33
+
yann@1625
    34
+   Copyright (C) 2007 Free Software Foundation, Inc.
yann@1625
    35
+   This file is part of the GNU C Library.
yann@1625
    36
+
yann@1625
    37
+   The GNU C Library is free software; you can redistribute it and/or
yann@1625
    38
+   modify it under the terms of the GNU Lesser General Public
yann@1625
    39
+   License as published by the Free Software Foundation; either
yann@1625
    40
+   version 2.1 of the License, or (at your option) any later version.
yann@1625
    41
+
yann@1625
    42
+   The GNU C Library is distributed in the hope that it will be useful,
yann@1625
    43
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
yann@1625
    44
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
yann@1625
    45
+   Lesser General Public License for more details.
yann@1625
    46
+
yann@1625
    47
+   You should have received a copy of the GNU Lesser General Public
yann@1625
    48
+   License along with the GNU C Library; if not, write to the Free
yann@1625
    49
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
yann@1625
    50
+   02111-1307 USA.  */
yann@1625
    51
+
yann@1625
    52
+#include <errno.h>
yann@1625
    53
+#include <unistd.h>
yann@1625
    54
+
yann@1625
    55
+#include <sysdep-cancel.h>
yann@1625
    56
+#include <sys/syscall.h>
yann@1625
    57
+#include <bp-checks.h>
yann@1625
    58
+
yann@1625
    59
+#include <kernel-features.h>
yann@1625
    60
+
yann@1625
    61
+#if defined __NR_fdatasync && !defined __ASSUME_FDATASYNC
yann@1625
    62
+static int __have_no_fdatasync;
yann@1625
    63
+#endif
yann@1625
    64
+
yann@1625
    65
+static int
yann@1625
    66
+do_fdatasync (int fd)
yann@1625
    67
+{
yann@1625
    68
+#ifdef __ASSUME_FDATASYNC
yann@1625
    69
+  return INLINE_SYSCALL (fdatasync, 1, fd);
yann@1625
    70
+#elif defined __NR_fdatasync
yann@1625
    71
+  if (!__builtin_expect (__have_no_fdatasync, 0))
yann@1625
    72
+    {
yann@1625
    73
+      int result = INLINE_SYSCALL (fdatasync, 1, fd);
yann@1625
    74
+      if (__builtin_expect (result, 0) != -1 || errno != ENOSYS)
yann@1625
    75
+	return result;
yann@1625
    76
+
yann@1625
    77
+      __have_no_fdatasync = 1;
yann@1625
    78
+    }
yann@1625
    79
+#endif
yann@1625
    80
+  return INLINE_SYSCALL (fsync, 1, fd);
yann@1625
    81
+}
yann@1625
    82
+
yann@1625
    83
+int
yann@1625
    84
+__fdatasync (int fd)
yann@1625
    85
+{
yann@1625
    86
+  if (SINGLE_THREAD_P)
yann@1625
    87
+    return do_fdatasync (fd);
yann@1625
    88
+
yann@1625
    89
+  int oldtype = LIBC_CANCEL_ASYNC ();
yann@1625
    90
+
yann@1625
    91
+  int result = do_fdatasync (fd);
yann@1625
    92
+
yann@1625
    93
+  LIBC_CANCEL_RESET (oldtype);
yann@1625
    94
+
yann@1625
    95
+  return result;
yann@1625
    96
+}
yann@1625
    97
+
yann@1625
    98
+weak_alias (__fdatasync, fdatasync)
yann@1625
    99
+
yann@1625
   100
diff -durN glibc-2.10.1.orig/sysdeps/unix/sysv/linux/kernel-features.h glibc-2.10.1/sysdeps/unix/sysv/linux/kernel-features.h
yann@1625
   101
--- glibc-2.10.1.orig/sysdeps/unix/sysv/linux/kernel-features.h	2009-11-13 00:50:45.000000000 +0100
yann@1625
   102
+++ glibc-2.10.1/sysdeps/unix/sysv/linux/kernel-features.h	2009-11-13 00:51:04.000000000 +0100
yann@1625
   103
@@ -479,6 +479,12 @@
yann@1625
   104
 # define __ASSUME_FUTEX_LOCK_PI	1
yann@1625
   105
 #endif
yann@1625
   106
 
yann@1625
   107
+/* Support for fsyncdata syscall was added in 2.6.22 on alpha, but it
yann@1625
   108
+   was already present in 2.0 kernels on other architectures.  */
yann@1625
   109
+#if (!defined __alpha || __LINUX_KERNEL_VERSION >= 0x020616)
yann@1625
   110
+# define __ASSUME_FDATASYNC	1
yann@1625
   111
+#endif
yann@1625
   112
+
yann@1625
   113
 /* Support for utimensat syscall was added in 2.6.22, on alpha and s390
yann@1625
   114
    only after 2.6.22-rc1.  */
yann@1625
   115
 #if __LINUX_KERNEL_VERSION >= 0x020616 \
yann@1625
   116
diff -durN glibc-2.10.1.orig/sysdeps/unix/sysv/linux/syscalls.list glibc-2.10.1/sysdeps/unix/sysv/linux/syscalls.list
yann@1625
   117
--- glibc-2.10.1.orig/sysdeps/unix/sysv/linux/syscalls.list	2008-08-02 01:29:08.000000000 +0200
yann@1625
   118
+++ glibc-2.10.1/sysdeps/unix/sysv/linux/syscalls.list	2009-11-13 00:51:04.000000000 +0100
yann@1625
   119
@@ -11,7 +11,6 @@
yann@1625
   120
 epoll_create1	EXTRA	epoll_create1	i:i	epoll_create1
yann@1625
   121
 epoll_ctl	EXTRA	epoll_ctl	i:iiip	epoll_ctl
yann@1625
   122
 epoll_wait	EXTRA	epoll_wait	Ci:ipii	epoll_wait
yann@1625
   123
-fdatasync	-	fdatasync	Ci:i	fdatasync
yann@1625
   124
 flock		-	flock		i:ii	__flock		flock
yann@1625
   125
 fork		-	fork		i:	__libc_fork	__fork fork
yann@1625
   126
 get_kernel_syms	EXTRA	get_kernel_syms	i:p	get_kernel_syms