summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/pread_write.c
diff options
context:
space:
mode:
authorDavid McCullough <davidm@snapgear.com>2002-08-09 12:58:02 +0000
committerDavid McCullough <davidm@snapgear.com>2002-08-09 12:58:02 +0000
commit54e4a312a7ac8609604d922950d29f618d1cb04c (patch)
tree623097d3a64b440b1404d98480ef91b6467bee41 /libc/sysdeps/linux/common/pread_write.c
parentdad8611e7a0345c2cfa472489b36d5be79bcc6d2 (diff)
pread and pwrite were broken in several ways:
* pwrite was using the write system call. * SYSCALL_INLINE was only defined for pread and reused by pwrite meaning pwrite did a pread :-). * The kernel pread/pwrite interfaces always take a 64bit value. So the libc versions must do the LONG_LONG_PAIR stuff otherwise the pread/pwrite calls will not work. These guys are working now for SH at least (and I can format my DiskOnChip again ;-)
Diffstat (limited to 'libc/sysdeps/linux/common/pread_write.c')
-rw-r--r--libc/sysdeps/linux/common/pread_write.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index 61d1bee4f..801359276 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -40,45 +40,49 @@
#include <unistd.h>
#ifdef __NR_pread
-#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)
-#if defined __UCLIBC_HAVE_LFS__
-#ifndef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) __syscall_pread (args)
#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);
-#endif
+#define __NR___libc_pread __NR_pread
+
+ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR((off_t)0,offset)));
+}
+weak_alias (__libc_pread, pread)
+
+#if defined __UCLIBC_HAVE_LFS__
ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
{
- return(INLINE_SYSCALL (pread, 5, fd, buf,
- count, __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) (offset & 0xffffffff))));
+ return(__syscall_pread(fd, buf, count,
+ __LONG_LONG_PAIR((off_t)(offset>>32),(off_t)(offset&0xffffffff))));
}
weak_alias (__libc_pread64, pread64)
#endif /* __UCLIBC_HAVE_LFS__ */
+
#endif /* __NR_pread */
#ifdef __NR_pwrite
#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)
-#if defined __UCLIBC_HAVE_LFS__
-#ifndef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) __syscall_write (args)
-#define __NR___syscall_write __NR_write
-static inline _syscall5(ssize_t, __syscall_write, int, fd, const void *, buf,
+#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);
-#endif
+ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+ return(__syscall_pwrite(fd,buf,count,__LONG_LONG_PAIR((off_t)0,offset)));
+}
+weak_alias (__libc_pwrite, pwrite)
+
+#if defined __UCLIBC_HAVE_LFS__
ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
{
- return(INLINE_SYSCALL (pwrite, 5, fd, buf,
- count, __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) (offset & 0xffffffff))));
+ return(__syscall_pwrite(fd, buf, count,
+ __LONG_LONG_PAIR((off_t)(offset>>32),(off_t)(offset&0xffffffff))));
}
weak_alias (__libc_pwrite64, pwrite64)
#endif /* __UCLIBC_HAVE_LFS__ */