summaryrefslogtreecommitdiffstats
path: root/main/libc0.9.32/0004-add-cancellation-to-generic-pread_write.patch
blob: 555bc5850f992a7605844603814fe3f24b5072ef (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From 25fae380b721fdb3fe27872dda57d4534d7d78c1 Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Fri, 22 Apr 2011 01:25:31 +0200
Subject: [PATCH 4/6] add cancellation to generic pread_write

Prepare the file to be used in all arch specific files

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
(cherry picked from commit 61198b43ee8a639544622d0e666b972418c9c383)
---
 libc/sysdeps/linux/common/pread_write.c | 100 ++++++++++++++++----------------
 1 file changed, 51 insertions(+), 49 deletions(-)

diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index 48fe7dd..3d04bb7 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -15,71 +15,73 @@
 
 #include <sys/syscall.h>
 #include <unistd.h>
-#include <stdint.h>
 #include <endian.h>
+#include <bits/wordsize.h>
+#include <cancel.h>
 
-extern __typeof(pread) __libc_pread;
-extern __typeof(pwrite) __libc_pwrite;
-#ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-extern __typeof(pwrite64) __libc_pwrite64;
-#endif
-
-#ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
+#ifdef __NR_pread64
 # undef __NR_pread
 # define __NR_pread __NR_pread64
 #endif
+#ifdef __NR_pwrite64
+# undef __NR_pwrite
+# define __NR_pwrite __NR_pwrite64
+#endif
 
-#include <bits/kernel_types.h>
-
-#ifdef __NR_pread
+#ifndef MY_PREAD
+# ifdef __NR_pread
+#  define __NR___syscall_pread __NR_pread
+static _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+		 size_t, count, off_t, offset_hi, off_t, offset_lo)
+#  define MY_PREAD(fd, buf, count, offset) __syscall_pread(fd, buf, count, OFF_HI_LO(offset))
+#  define MY_PREAD64(fd, buf, count, offset) __syscall_pread(fd, buf, count, OFF64_HI_LO(offset))
+#endif
 
-# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
-		size_t, count, off_t, offset_hi, off_t, offset_lo)
+#ifndef MY_PWRITE
+# ifdef __NR_pwrite
+#  define __NR___syscall_pwrite __NR_pwrite
+static _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+		 size_t, count, off_t, offset_hi, off_t, offset_lo)
+#  define MY_PWRITE(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, OFF_HI_LO(offset))
+#  define MY_PWRITE64(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, OFF64_HI_LO(offset))
+#endif
 
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
+static ssize_t __NC(pread)(int fd, void *buf, size_t count, off_t offset)
 {
-	return __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+	return MY_PREAD(fd, buf, count, offset);
 }
-weak_alias(__libc_pread,pread)
+CANCELLABLE_SYSCALL(ssize_t, pread, (int fd, void *buf, size_t count, off_t offset),
+		    (fd, buf, count, offset))
 
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
+static ssize_t __NC(pwrite)(int fd, const void *buf, size_t count, off_t offset)
 {
-	uint32_t low = offset & 0xffffffff;
-	uint32_t high = offset >> 32;
-	return __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(high, low));
+	return MY_PWRITE(fd, buf, count, offset);
 }
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__  */
+CANCELLABLE_SYSCALL(ssize_t, pwrite, (int fd, const void *buf, size_t count, off_t offset),
+		    (fd, buf, count, offset))
 
-#endif /* __NR_pread */
-
-#ifdef __NR_pwrite64             /* Newer kernels renamed but it's the same.  */
-# undef __NR_pwrite
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-#ifdef __NR_pwrite
-
-# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
-		size_t, count, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
+#ifdef __UCLIBC_HAS_LFS__
+# if __WORDSIZE == 32
+static ssize_t __NC(pread64)(int fd, void *buf, size_t count, off64_t offset)
 {
-	return __syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+	return MY_PREAD64(fd, buf, count, offset);
 }
-weak_alias(__libc_pwrite,pwrite)
+CANCELLABLE_SYSCALL(ssize_t, pread64, (int fd, void *buf, size_t count, off64_t offset),
+		    (fd, buf, count, offset))
 
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
+static ssize_t __NC(pwrite64)(int fd, const void *buf, size_t count, off64_t offset)
 {
-	uint32_t low = offset & 0xffffffff;
-	uint32_t high = offset >> 32;
-	return __syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR(high, low));
+	return MY_PWRITE64(fd, buf, count, offset);
 }
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__  */
-#endif /* __NR_pwrite */
+CANCELLABLE_SYSCALL(ssize_t, pwrite64, (int fd, const void *buf, size_t count, off64_t offset),
+		    (fd, buf, count, offset))
+# else
+#  ifdef __LINUXTHREADS_OLD__
+weak_alias(pread,pread64)
+weak_alias(pwrite,pwrite64)
+#  else
+strong_alias_untyped(pread,pread64)
+strong_alias_untyped(pwrite,pwrite64)
+#  endif
+# endif
+#endif
-- 
1.7.11.1