[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ioctl-patch for Darwin and FreeBSD
From: |
Markus Gothe |
Subject: |
Re: ioctl-patch for Darwin and FreeBSD |
Date: |
Tue, 22 Feb 2011 23:32:43 +0100 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Bruno,
On 22 Feb, 2011, at 22:56 , Bruno Haible wrote:
> Hi Markus,
>
>> Please see attached patch for ioctl() on FreeBSD and Darwin. Their definition
>> differ from (int, int, ...) and the gnulib variant doesn't work well on
>> 64-bit Darwin with this proto.
>
> I'm sure this is a follow-up to this thread from January
> <http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00514.html>
Yes, that's the correct thread.
>
> You showed some code that uses SIOCSIFLLADDR. Maybe the problem is
> that this value does not fit in an 'int'?
>
> $ cat foo.c
> #include <sys/socket.h>
> #include <net/if.h>
> #include <sys/sockio.h>
> unsigned long x = SIOCSIFLLADDR;
> int y = SIOCSIFLLADDR;
>
> $ gcc -S -m64 foo.c
> $ cat foo.s
> .globl _x
> .data
> .align 3
> _x:
> .quad 2149607740
> .globl _y
> .align 2
> _y:
> .long -2145359556
> .subsections_via_symbols
>
>
> Does this patch fix the issue for you?
>
>
> 2011-02-22 Bruno Haible <address@hidden>
>
> ioctl: Fix for MacOS X in 64-bit mode.
> * lib/ioctl.c (rpl_ioctl): Zero-extend, not sign-extend, the request
> value.
> Reported by Markus Gothe <address@hidden>.
>
> --- lib/ioctl.c.orig Tue Feb 22 22:54:33 2011
> +++ lib/ioctl.c Tue Feb 22 22:54:16 2011
> @@ -37,7 +37,9 @@
> buf = va_arg (args, void *);
> va_end (args);
>
> - return ioctl (fd, request, buf);
> + /* Cast 'request' so that when the system's ioctl function takes a 64-bit
> + request argument, the value gets zero-extended, not sign-extended. */
> + return ioctl (fd, (unsigned int) request, buf);
> }
>
> #else /* mingw */
>
Yes, taking an unsigned int in account actually fixed it... Splendid!
> --
> In memoriam Sophie Scholl <http://en.wikipedia.org/wiki/Sophie_Scholl>
//Markus - The panama-hat hacker
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
iD8DBQFNZDmP6I0XmJx2NrwRAqDeAKDIm+DqFfOcCn3HOpgrctfveBDpCgCdGDGe
WGPx2TgYlPo1V6IGWD99c40=
=+EEM
-----END PGP SIGNATURE-----