bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ioctl-patch for Darwin and FreeBSD


From: Bruno Haible
Subject: Re: ioctl-patch for Darwin and FreeBSD
Date: Tue, 22 Feb 2011 22:56:35 +0100
User-agent: KMail/1.9.9

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>

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 */

-- 
In memoriam Sophie Scholl <http://en.wikipedia.org/wiki/Sophie_Scholl>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]