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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
|
From 5c7b0eadf777ba9539e723882138273d631ddc05 Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Fri, 22 Apr 2011 02:22:07 +0200
Subject: [PATCH 5/6] pread_write.c: make all archs use common code
c6x does not need own version at all
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 836d74b92d70b71792d3d6136db7cdf0c3775ee3)
---
libc/sysdeps/linux/c6x/Makefile.arch | 3 +-
libc/sysdeps/linux/c6x/pread_write.c | 103 ---------------------------
libc/sysdeps/linux/common/pread_write.c | 2 +
libc/sysdeps/linux/mips/pread_write.c | 116 +++++++++----------------------
libc/sysdeps/linux/powerpc/pread_write.c | 70 +++++--------------
libc/sysdeps/linux/sh/pread_write.c | 109 ++++-------------------------
libc/sysdeps/linux/xtensa/pread_write.c | 79 +++++----------------
7 files changed, 88 insertions(+), 394 deletions(-)
delete mode 100644 libc/sysdeps/linux/c6x/pread_write.c
diff --git a/libc/sysdeps/linux/c6x/Makefile.arch b/libc/sysdeps/linux/c6x/Makefile.arch
index 6bb44f2..5f8aaec 100644
--- a/libc/sysdeps/linux/c6x/Makefile.arch
+++ b/libc/sysdeps/linux/c6x/Makefile.arch
@@ -5,6 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c pread_write.c syscall.c prctl.c
+CSRC := brk.c syscall.c prctl.c
+#CSRC :=
SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S _vfork.S
diff --git a/libc/sysdeps/linux/c6x/pread_write.c b/libc/sysdeps/linux/c6x/pread_write.c
deleted file mode 100644
index f985b43..0000000
--- a/libc/sysdeps/linux/c6x/pread_write.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* vi: set sw=4 ts=4:
- *
- * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
- * Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program 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 Library General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * * * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
-
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <stdint.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_pread
-# error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#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);
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__syscall_pread(fd,buf,count,offset,offset >> 31));
-}
-weak_alias (__libc_pread, pread)
-
-#if defined __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
- return(__syscall_pread(fd, buf, count, low, high));
-}
-weak_alias (__libc_pread64, pread64)
-#endif /* __UCLIBC_HAS_LFS__ */
-
-
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
-# ifdef __NR_pwrite
-# error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-#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)
-{
- return(__syscall_pwrite(fd,buf,count,offset,offset >> 31));
-}
-weak_alias (__libc_pwrite, pwrite)
-
-#if defined __UCLIBC_HAS_LFS__
-ssize_t __libc_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, low, high));
-}
-weak_alias (__libc_pwrite64, pwrite64)
-#endif /* __UCLIBC_HAS_LFS__ */
-
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index 3d04bb7..dd5d36c 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -35,6 +35,7 @@ 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
#endif
#ifndef MY_PWRITE
@@ -44,6 +45,7 @@ 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
#endif
static ssize_t __NC(pread)(int fd, void *buf, size_t count, off_t offset)
diff --git a/libc/sysdeps/linux/mips/pread_write.c b/libc/sysdeps/linux/mips/pread_write.c
index ea6b15f..b777dc4 100644
--- a/libc/sysdeps/linux/mips/pread_write.c
+++ b/libc/sysdeps/linux/mips/pread_write.c
@@ -4,76 +4,39 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/*
- * Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- */
#include <sys/syscall.h>
#include <unistd.h>
-#include <stdint.h>
#include <endian.h>
#include <sgidefs.h>
-#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pread64
# ifdef __NR_pread
# error "__NR_pread and __NR_pread64 both defined???"
# endif
# define __NR_pread __NR_pread64
#endif
-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
-
-#include <bits/kernel_types.h>
-
-
#ifdef __NR_pread
-
-# if _MIPS_SIM == _MIPS_SIM_ABI64
-# define __NR___libc_pread __NR_pread
-_syscall4(ssize_t, __libc_pread, int, fd, void *, buf, size_t, count, off_t, offset)
-weak_alias (__libc_pread, pread)
-# ifdef __UCLIBC_HAS_LFS__
-# define __NR___libc_pread64 __NR_pread
-_syscall4(ssize_t, __libc_pread64, int, fd, void *, buf, size_t, count, off64_t, offset)
-weak_alias (__libc_pread64, pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
+# if _MIPS_SIM == _MIPS_SIM_ABI64 /* glibc uses it for N32 as well */
+# define __NR___syscall_pread __NR_pread
+static _syscall4(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset)
+# define MY_PREAD(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, offset)
+# define MY_PREAD64(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, offset)
# else /* O32 || N32 */
# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
- return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-# endif /* O32 || N32 */
-
-#endif /* __NR_pread */
-
-/**********************************************************************/
+static _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PREAD(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PREAD64(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF64_HI_LO(offset))
+# endif
+#endif
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pwrite64
# ifdef __NR_pwrite
# error "__NR_pwrite and __NR_pwrite64 both defined???"
# endif
@@ -81,35 +44,22 @@ weak_alias(__libc_pread64,pread64)
#endif
#ifdef __NR_pwrite
-
-# if _MIPS_SIM == _MIPS_SIM_ABI64
-# define __NR___libc_pwrite __NR_pwrite
-_syscall4(ssize_t, __libc_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset)
-weak_alias (__libc_pwrite, pwrite)
-# ifdef __UCLIBC_HAS_LFS__
-# define __NR___libc_pwrite64 __NR_pwrite
-_syscall4(ssize_t, __libc_pwrite64, int, fd, const void *, buf, size_t, count, off64_t, offset)
-weak_alias (__libc_pwrite64, pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
+# if _MIPS_SIM == _MIPS_SIM_ABI64 /* glibc uses it for N32 as well */
+# define __NR___syscall_pwrite __NR_pwrite
+static _syscall4(ssize_t, __syscall_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset)
+# define MY_PWRITE(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, offset)
+# define MY_PWRITE64(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, offset)
# else /* O32 || N32 */
# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
-}
-weak_alias(__libc_pwrite,pwrite)
+static _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PWRITE(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PWRITE64(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF64_HI_LO(offset))
+# endif
+#endif
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_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, 0, __LONG_LONG_PAIR (high, low)));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-# endif /* O32 || N32 */
-#endif /* __NR_pwrite */
+#include "../common/pread_write.c"
diff --git a/libc/sysdeps/linux/powerpc/pread_write.c b/libc/sysdeps/linux/powerpc/pread_write.c
index 92a184c..5cb3386 100644
--- a/libc/sysdeps/linux/powerpc/pread_write.c
+++ b/libc/sysdeps/linux/powerpc/pread_write.c
@@ -1,26 +1,15 @@
-/* vi: set sw=4 ts=4:
- *
+/* vi: set sw=4 ts=4: */
+/*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- */
#include <sys/syscall.h>
#include <unistd.h>
#include <endian.h>
-#ifndef __UCLIBC_HAS_LFS__
-# define off64_t off_t
-#endif
-
-#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pread64
# ifdef __NR_pread
# error "__NR_pread and __NR_pread64 both defined???"
# endif
@@ -28,28 +17,16 @@
#endif
#ifdef __NR_pread
-extern __typeof(pread) __libc_pread;
# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd,
- void *, buf, size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pread */
+static _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PREAD(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PREAD64(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF64_HI_LO(offset))
+#endif
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pwrite64
# ifdef __NR_pwrite
# error "__NR_pwrite and __NR_pwrite64 both defined???"
# endif
@@ -57,23 +34,14 @@ weak_alias(__libc_pread64,pread64)
#endif
#ifdef __NR_pwrite
-extern __typeof(pwrite) __libc_pwrite;
# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd,
- const void *, buf, size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
-}
-weak_alias(__libc_pwrite,pwrite)
+static _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PWRITE(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PWRITE64(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF64_HI_LO(offset))
+#endif
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pwrite64) __libc_pwrite64;
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
+#include "../common/pread_write.c"
diff --git a/libc/sysdeps/linux/sh/pread_write.c b/libc/sysdeps/linux/sh/pread_write.c
index 86feb9c..f4453a6 100644
--- a/libc/sysdeps/linux/sh/pread_write.c
+++ b/libc/sysdeps/linux/sh/pread_write.c
@@ -4,28 +4,12 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/*
- * Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- */
#include <sys/syscall.h>
#include <unistd.h>
-#include <stdint.h>
#include <endian.h>
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <sysdep-cancel.h>
-#else
-#define SINGLE_THREAD_P 1
-#endif
-
-
-#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pread64
# ifdef __NR_pread
# error "__NR_pread and __NR_pread64 both defined???"
# endif
@@ -33,49 +17,16 @@
#endif
#ifdef __NR_pread
-extern __typeof(pread) __libc_pread;
# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- if (SINGLE_THREAD_P)
- return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset)));
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- ssize_t result = __syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset));
- LIBC_CANCEL_RESET (oldtype);
- return result;
-#endif
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
-
- if (SINGLE_THREAD_P)
- return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low));
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- ssize_t result = __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low));
- LIBC_CANCEL_RESET (oldtype);
- return result;
+static _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PREAD(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PREAD64(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF64_HI_LO(offset))
#endif
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pread */
-
-/**********************************************************************/
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pwrite64
# ifdef __NR_pwrite
# error "__NR_pwrite and __NR_pwrite64 both defined???"
# endif
@@ -83,43 +34,13 @@ weak_alias(__libc_pread64,pread64)
#endif
#ifdef __NR_pwrite
-extern __typeof(pwrite) __libc_pwrite;
# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- if (SINGLE_THREAD_P)
- return __syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset));
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- ssize_t result = __syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset));
- LIBC_CANCEL_RESET (oldtype);
- return result;
+static _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PWRITE(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PWRITE64(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF64_HI_LO(offset))
#endif
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pwrite64) __libc_pwrite64;
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
-
- if (SINGLE_THREAD_P)
- return __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low));
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
- int oldtype = LIBC_CANCEL_ASYNC ();
- ssize_t result = __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low));
- LIBC_CANCEL_RESET (oldtype);
- return result;
-#endif
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
+#include "../common/pread_write.c"
diff --git a/libc/sysdeps/linux/xtensa/pread_write.c b/libc/sysdeps/linux/xtensa/pread_write.c
index e8b39e9..f4453a6 100644
--- a/libc/sysdeps/linux/xtensa/pread_write.c
+++ b/libc/sysdeps/linux/xtensa/pread_write.c
@@ -4,30 +4,12 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/*
- * Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- */
#include <sys/syscall.h>
#include <unistd.h>
-#include <stdint.h>
#include <endian.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
-
-#include <bits/kernel_types.h>
-
-#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pread64
# ifdef __NR_pread
# error "__NR_pread and __NR_pread64 both defined???"
# endif
@@ -35,31 +17,16 @@ extern __typeof(pwrite64) __libc_pwrite64;
#endif
#ifdef __NR_pread
-
# define __NR___syscall_pread __NR_pread
-/* On Xtensa, 64-bit values are aligned in even/odd register pairs. */
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, pad, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
- return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-
-#endif /* __NR_pread */
+static _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PREAD(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PREAD64(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, 0, OFF64_HI_LO(offset))
+#endif
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+#ifdef __NR_pwrite64
# ifdef __NR_pwrite
# error "__NR_pwrite and __NR_pwrite64 both defined???"
# endif
@@ -67,25 +34,13 @@ weak_alias(__libc_pread64,pread64)
#endif
#ifdef __NR_pwrite
-
# define __NR___syscall_pwrite __NR_pwrite
-/* On Xtensa, 64-bit values are aligned in even/odd register pairs. */
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, pad, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pwrite,pwrite)
+static _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PWRITE(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PWRITE64(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, 0, OFF64_HI_LO(offset))
+#endif
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_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, 0, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
+#include "../common/pread_write.c"
--
1.7.11.1
|