Re: [PATCH] work around duff ABIs

Matthew Wilcox
2002-10-20T12:45:07Z

On Sat, Oct 19, 2002 at 10:51:49PM -0600, Erik Andersen wrote:
> Nonono. Please see __LONG_LONG_PAIR in /usr/include/endian.h.
> Your user space code should be doing something like this:
>
> static inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
> size_t, count, off_t, offset_hi, off_t, offset_lo);
>
> 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)));
> }
>
> ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
> {
> return(__syscall_pread(fd, buf, count,
> __LONG_LONG_PAIR((off_t)(offset>>32),
> (off_t)(offset&0xffffffff))));
> }
>
> Your patch is going to break GNU libc, uClibc, and anyone else in
> userspace that is doing pread and pread64 correctly....

Well... since you just proved that you don't understand the problem,
I'd hazard a guess that uClibc is also broken, as well as glibc.

Here's how the ABI specifies that pread() shall take its arguments:

asmlinkage ssize_t sys_pread64(unsigned int fd, char *buf, size_t count,
loff_t pos)

fd arg0
buf arg1
count arg2
pos arg4 & arg5

Here's what __LONG_LONG_PAIR does:

fd arg0
buf arg1
count arg2
pos(HI) arg3
pos(LO) arg4

--
Revolutions do not require corporate support.