summaryrefslogtreecommitdiff
path: root/patches/glibc/ports-2.12.1/490-alpha_alpha-add-fdatasync-support.patch
blob: 9d35ebdd802fa944537e6802a0bde609481995f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
2009-07-25  Aurelien Jarno  <aurelien@aurel32.net>

	* sysdeps/unix/sysv/linux/kernel-features.h: define 
	__ASSUME_FDATASYNC. 
	* sysdeps/unix/sysv/linux/fdatasync.c: New file.
	* sysdeps/unix/sysv/linux/Makefile: compile fdatasync.c with
	-fexceptions.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove fdatasync.

 sysdeps/unix/sysv/linux/Makefile          |    1 
 sysdeps/unix/sysv/linux/fdatasync.c       |   69 ++++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/kernel-features.h |    6 ++
 sysdeps/unix/sysv/linux/syscalls.list     |    1 
 4 files changed, 76 insertions(+), 1 deletion(-)

diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/Makefile glibc-2.12.1/sysdeps/unix/sysv/linux/Makefile
--- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/Makefile	2009-03-02 17:15:13.000000000 +0100
+++ glibc-2.12.1/sysdeps/unix/sysv/linux/Makefile	2009-11-13 00:51:04.000000000 +0100
@@ -20,6 +20,7 @@
 		   setfsuid setfsgid makedev epoll_pwait signalfd \
 		   eventfd eventfd_read eventfd_write
 
+CFLAGS-fdatasync.c = -fexceptions
 CFLAGS-gethostid.c = -fexceptions
 
 sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/fdatasync.c glibc-2.12.1/sysdeps/unix/sysv/linux/fdatasync.c
--- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/fdatasync.c	1970-01-01 01:00:00.000000000 +0100
+++ glibc-2.12.1/sysdeps/unix/sysv/linux/fdatasync.c	2009-11-13 00:51:04.000000000 +0100
@@ -0,0 +1,69 @@
+/* fdatasync -- synchronize at least the data part of a file with 
+   the underlying media. Linux version. 
+
+   Copyright (C) 2007 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 <unistd.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#if defined __NR_fdatasync && !defined __ASSUME_FDATASYNC
+static int __have_no_fdatasync;
+#endif
+
+static int
+do_fdatasync (int fd)
+{
+#ifdef __ASSUME_FDATASYNC
+  return INLINE_SYSCALL (fdatasync, 1, fd);
+#elif defined __NR_fdatasync
+  if (!__builtin_expect (__have_no_fdatasync, 0))
+    {
+      int result = INLINE_SYSCALL (fdatasync, 1, fd);
+      if (__builtin_expect (result, 0) != -1 || errno != ENOSYS)
+	return result;
+
+      __have_no_fdatasync = 1;
+    }
+#endif
+  return INLINE_SYSCALL (fsync, 1, fd);
+}
+
+int
+__fdatasync (int fd)
+{
+  if (SINGLE_THREAD_P)
+    return do_fdatasync (fd);
+
+  int oldtype = LIBC_CANCEL_ASYNC ();
+
+  int result = do_fdatasync (fd);
+
+  LIBC_CANCEL_RESET (oldtype);
+
+  return result;
+}
+
+weak_alias (__fdatasync, fdatasync)
+
diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/kernel-features.h glibc-2.12.1/sysdeps/unix/sysv/linux/kernel-features.h
--- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/kernel-features.h	2009-11-13 00:50:45.000000000 +0100
+++ glibc-2.12.1/sysdeps/unix/sysv/linux/kernel-features.h	2009-11-13 00:51:04.000000000 +0100
@@ -459,6 +459,12 @@
 # define __ASSUME_FUTEX_LOCK_PI	1
 #endif
 
+/* Support for fsyncdata syscall was added in 2.6.22 on alpha, but it
+   was already present in 2.0 kernels on other architectures.  */
+#if (!defined __alpha || __LINUX_KERNEL_VERSION >= 0x020616)
+# define __ASSUME_FDATASYNC	1
+#endif
+
 /* Support for utimensat syscall was added in 2.6.22, on SH
    only after 2.6.22-rc1.  */
 #if __LINUX_KERNEL_VERSION >= 0x020616 \
diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/syscalls.list glibc-2.12.1/sysdeps/unix/sysv/linux/syscalls.list
--- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/syscalls.list	2008-08-02 01:29:08.000000000 +0200
+++ glibc-2.12.1/sysdeps/unix/sysv/linux/syscalls.list	2009-11-13 00:51:04.000000000 +0100
@@ -11,7 +11,6 @@
 epoll_create1	EXTRA	epoll_create1	i:i	epoll_create1
 epoll_ctl	EXTRA	epoll_ctl	i:iiip	epoll_ctl
 epoll_wait	EXTRA	epoll_wait	Ci:ipii	epoll_wait
-fdatasync	-	fdatasync	Ci:i	fdatasync
 flock		-	flock		i:ii	__flock		flock
 fork		-	fork		i:	__libc_fork	__fork fork
 get_kernel_syms	EXTRA	get_kernel_syms	i:p	get_kernel_syms