mips64 patches

Rich Felker dalias at aerifal.cx
Thu Jul 6 16:55:02 UTC 2006


On Thu, Jul 06, 2006 at 02:45:25PM +0900, Atsushi Nemoto wrote:
> On Thu, 06 Jul 2006 01:00:53 +0900 (JST), Atsushi Nemoto <anemo at mba.ocn.ne.jp> wrote:
> > The remained patch is for ioctl, but now I can not remember the reason
> > of this change...  I'll try to figure out this is really required or
> > not.
> 
> This is really needed.  The ioctl number must be sign-extended 32bit
> value for mips64 kernel.  Without this change, libc passes
> 0x0000000080000000 for ioctl request 0x80000000, but kernel expects
> 0xffffffff80000000 for the ioctl.
> 
> Since I do not know about other 64bit system, I think adding mips
> specific ioctl.c would be better than touching the common one.  This
> mips specific ioctl.c can be used for all MIPS ABI.
> 
> Patch attached.

> diff -urNp uClibc-20060611/libc/sysdeps/linux/mips/ioctl.c uClibc/libc/sysdeps/linux/mips/ioctl.c
> --- uClibc-20060611/libc/sysdeps/linux/mips/ioctl.c	1970-01-01 09:00:00.000000000 +0900
> +++ uClibc/libc/sysdeps/linux/mips/ioctl.c	2006-07-06 14:13:51.000000000 +0900
> @@ -0,0 +1,32 @@
> +/* vi: set sw=4 ts=4: */
> +/*
> + * ioctl() for uClibc
> + *
> + * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
> + *
> + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
> + */
> +
> +#include "syscalls.h"
> +#include <stdarg.h>
> +#include <sys/ioctl.h>
> +
> +libc_hidden_proto(ioctl)
> +
> +/* 'request' must be sign-extended 32bit value on n64 */
> +#define __NR___syscall_ioctl __NR_ioctl
> +static inline
> +_syscall3(int, __syscall_ioctl, int, fd, int, request, void *, arg);
> +
> +int ioctl(int fd, unsigned long int request, ...)
> +{
> +    void *arg;
> +    va_list list;
> +
> +    va_start(list, request);
> +    arg = va_arg(list, void *);
> +
> +    va_end(list);
> +    return __syscall_ioctl(fd, request, arg);
> +}
> +libc_hidden_def(ioctl)

This prototype for ioctl is wrong. request is supposed to be int in
the userspace api as well as the syscall. See SUSv3.

Rich




More information about the uClibc mailing list