On Wednesday 10 June 2009 07:17:23 Marcus Johansson wrote: > I'm using pread/pwrite in my multi-threaded application. Ran into > mysterious problems. I discovered that uClibc thinks that the kernel does > not implement pread/pwrite (__NR_pread is not defined). __NR_pread64 is > defined though. This make uClibc use a fake pread/pwrite instead, using > three lseeks (one to save the old position, one to reposition and finally, > after the read/write operation, one to restore the original position). This > sequence is apparently not thread safe which causes my problems. The place > this is implemented is libc/sysdeps/linux/common/pread_write.c. > > I'm using uClibc-0.9.29. Do you have any suggestions? Is this a bug or have > I misconfigured? I have configured uClibc with LFS.
seems to be broken for most people. please try this patch: diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c index 83d5fdf..c800ee4 100644 --- a/libc/sysdeps/linux/common/pread_write.c +++ b/libc/sysdeps/linux/common/pread_write.c @@ -27,9 +27,13 @@ extern __typeof(pwrite64) __libc_pwrite64; #include <bits/kernel_types.h> -#ifdef __NR_pread +#if defined(__NR_pread) && !defined(__NR_pread64) +# define __NR_pread64 __NR_pread +#endif + +#ifdef __NR_pread64 -# define __NR___syscall_pread __NR_pread +# define __NR___syscall_pread __NR_pread64 static __inline__ _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo) @@ -51,9 +55,13 @@ weak_alias(__libc_pread64,pread64) #endif /* __NR_pread */ -#ifdef __NR_pwrite +#if defined(__NR_pwrite) && !defined(__NR_pwrite64) +# define __NR_pwrite64 __NR_pwrite +#endif + +#ifdef __NR_pwrite64 -# define __NR___syscall_pwrite __NR_pwrite +# define __NR___syscall_pwrite __NR_pwrite64 static __inline__ _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo) @@ -74,7 +82,7 @@ weak_alias(__libc_pwrite64,pwrite64) # endif /* __UCLIBC_HAS_LFS__ */ #endif /* __NR_pwrite */ -#if ! defined __NR_pread || ! defined __NR_pwrite +#if ! defined __NR_pread64 || ! defined __NR_pwrite64 /* libc_hidden_proto(read) */ /* libc_hidden_proto(write) */ /* libc_hidden_proto(lseek) */ @@ -154,7 +162,7 @@ static ssize_t __fake_pread_write64(int fd, void *buf, return result; } # endif /* __UCLIBC_HAS_LFS__ */ -#endif /* ! defined __NR_pread || ! defined __NR_pwrite */ +#endif /* ! defined __NR_pread64 || ! defined __NR_pwrite64 */ #ifndef __NR_pread ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) -mike _______________________________________________ uClibc mailing list uClibc@uclibc.org http://lists.busybox.net/mailman/listinfo/uclibc