1 /* vi: set sw=4 ts=4: */
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.
8 * Based in part on the files
9 * ./sysdeps/unix/sysv/linux/pwrite.c,
10 * ./sysdeps/unix/sysv/linux/pread.c,
11 * sysdeps/posix/pread.c
12 * sysdeps/posix/pwrite.c
13 * from GNU libc 2.2.5, but reworked considerably...
16 #include <sys/syscall.h>
21 #ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
23 # error "__NR_pread and __NR_pread64 both defined???"
25 # define __NR_pread __NR_pread64
29 extern __typeof(pread) __libc_pread;
30 # define __NR___syscall_pread __NR_pread
31 static inline _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
32 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
34 ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
36 return(__syscall_pread(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset)));
38 weak_alias(__libc_pread,pread)
40 # ifdef __UCLIBC_HAS_LFS__
41 extern __typeof(pread64) __libc_pread64;
42 ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
44 uint32_t low = offset & 0xffffffff;
45 uint32_t high = offset >> 32;
46 return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
48 weak_alias(__libc_pread64,pread64)
49 # endif /* __UCLIBC_HAS_LFS__ */
50 #endif /* __NR_pread */
52 /**********************************************************************/
54 #ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
56 # error "__NR_pwrite and __NR_pwrite64 both defined???"
58 # define __NR_pwrite __NR_pwrite64
62 extern __typeof(pwrite) __libc_pwrite;
63 # define __NR___syscall_pwrite __NR_pwrite
64 static inline _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
65 size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
67 ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
69 return(__syscall_pwrite(fd,buf,count,0,__LONG_LONG_PAIR(offset >> 31,offset)));
71 weak_alias(__libc_pwrite,pwrite)
73 # ifdef __UCLIBC_HAS_LFS__
74 extern __typeof(pwrite64) __libc_pwrite64;
75 ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
77 uint32_t low = offset & 0xffffffff;
78 uint32_t high = offset >> 32;
79 return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
81 weak_alias(__libc_pwrite64,pwrite64)
82 # endif /* __UCLIBC_HAS_LFS__ */
83 #endif /* __NR_pwrite */