pread() and pwrite() system calls

David Laight David.Laight at ACULAB.COM
Tue May 29 18:28:55 EST 2012

> > A special pread/pwrite asm stub that just copies
> > r7 to r0 could be used.
> > 
> > Would it be enough to do:
> > syscall_pread_pwrite:
> > 	mov 0,7
> > 	sc
> > 	blr
> > and handle the -ve -> errno in C?
> Huh? Won't fly, r0 is used for the system call number!

I was copying that from r7!
Actually I have a much better stub by copying the one
used for mmap().
The system call itself is fine.
Using the system call almost halved the time taken
for a 4-byte read.

> On the other hand, I believed PPC had no problems passing
> up to 8 32 bit arguments in registers (r3 to r10), but
> I may be confusing with the standard ABI for function calls.
> Hmm, a quick look at kernel/entry_32.s shows that it should 
> be able to use at least r3 to r8, which should be sufficient.
> I think that it is an uClibc problem.

True, in that it isn't a kernel bug.
OTOH the kernel is likely to get blamed for non-atomic pread.
I've found the same user-space code in newlib as well.
glibc may be ok, some code I've found implies it only
uses the 'emulation' when the system call returns ENOSYS.


More information about the Linuxppc-dev mailing list