pkg-config libdivecomputer / subsurface makefile / confusion

Grischa Toedt toedt at embl.de
Tue Jul 10 16:17:40 PDT 2012


as Jef committed:

"On Mac OS X (and probably the other BSD's too), the ioctl() syscall
takes an 'unsigned long' integer as the request parameter. On 64bit
systems this is a 64bit type, while on 32bit systems it's a 32bit type.

Some of the request constants are defined as 32 bit negative numbers.
Casting it to a 64bit value will perform a sign extension operation to
preserve the negative value. Because this results in a different request
code when interpreted as an unsigned integer, the ioctl() call fails
with ENOTTY. For example TIOCMBIS is defined as 0x8004746c and becomes
0xffffffff8004746 after the sign extension.

Linux 64bit is unaffected by this problem. None of the request constants
has the sign bit set, and thus the sign extension has no effect. For
example TIOCMBIS is defined as 0x5416.

By using an unsigned integer type, the sign extension can be avoided. We
use the 'unsigned long' type in case one of the request constants
happens to be defined as a 64bit number."

Grischa

On Jul 11, 2012, at 12:34 AM, Linus Torvalds wrote:

> On Tue, Jul 10, 2012 at 3:28 PM, Grischa Toedt <toedt at embl.de> wrote:
>> A final remark, you also have to apply Pascal Manchons "Fix some ioctl calls on 64bit Mac OS X." on libdivecomputer master, to be able to import dives on Mac OS X.
> 
> Seriously? That's totally broken. The "action" argument to ioctl is an
> "int" according to the open group, how/why did osx break that?
> 
> I've seen crap from OS X before, but that patch is just garbage. Just
> out of curiosity, what are the actual values of TIOCMBIS and TIOCMBIC
> on OS X?
> 
>                   Linus



More information about the subsurface mailing list