3 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 /* Based in part on the files
8 * ./sysdeps/unix/sysv/linux/pwrite.c,
9 * ./sysdeps/unix/sysv/linux/pread.c,
10 * sysdeps/posix/pread.c
11 * sysdeps/posix/pwrite.c
12 * from GNU libc 2.2.5, but reworked considerably...
16 #define _LARGEFILE64_SOURCE
19 /* We absolutely do _NOT_ want interfaces silently
20 * * * renamed under us or very bad things will happen... */
21 #ifdef __USE_FILE_OFFSET64
22 # undef __USE_FILE_OFFSET64
27 #include <sys/types.h>
28 #include <sys/syscall.h>
32 #ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
34 # error "__NR_pread and __NR_pread64 both defined???"
36 # define __NR_pread __NR_pread64
42 _syscall4(ssize_t, pread, int, fd, void *, buf, size_t, count, off_t, offset);
44 #define __NR___syscall_pread __NR_pread
45 static inline _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
46 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
48 ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
50 return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
52 strong_alias(__libc_pread,pread)
54 #if defined __UCLIBC_HAS_LFS__
55 ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
57 uint32_t low = offset & 0xffffffff;
58 uint32_t high = offset >> 32;
59 return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
61 strong_alias(__libc_pread64,pread64)
62 #endif /* __UCLIBC_HAS_LFS__ */
63 #endif /* !__mips64 */
65 #endif /* __NR_pread */
67 /**********************************************************************/
69 #ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
71 # error "__NR_pwrite and __NR_pwrite64 both defined???"
73 # define __NR_pwrite __NR_pwrite64
79 _syscall4(ssize_t, pwrite, int, fd, const void *, buf, size_t, count, off_t, offset);
81 #define __NR___syscall_pwrite __NR_pwrite
82 static inline _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
83 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
85 ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
87 return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset>>31,offset)));
89 strong_alias(__libc_pwrite,pwrite)
91 #if defined __UCLIBC_HAS_LFS__
92 ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
94 uint32_t low = offset & 0xffffffff;
95 uint32_t high = offset >> 32;
96 return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
98 strong_alias(__libc_pwrite64,pwrite64)
99 #endif /* __UCLIBC_HAS_LFS__ */
100 #endif /* !__mips64 */
101 #endif /* __NR_pwrite */