ioctl switch statement weirdness
dhaigh at mail.com
Tue Sep 28 10:08:27 PDT 2004
I have a standard ioctl routine that takes an u_long value as the command. As I was testing out my ioctl routine on a Sun Ultra 60 running 5.2.1 I kept getting 'invalid ioctl' statments from my routine. What I discovered was that if the value of the ioctl included the IOC_IN flag, it would not be recognized. The IOC_IN flag sets the highest order bit (0x80000000) so the only thing I could think of was that the switch statement was sign extending the IOCTL value, but the case statement was not. To see if this was the case, I assigned the u_long value (an unsigned 64 bit value) to an unsigned int value (a 32 bit value) and used that in the switch statement. It worked.
So the u_long type on the ioctl parameters will not work if the high order bit is set. Is this a problem with the FreeBSD definition of the ioctl command value or gcc's problem?
Sign-up for Ads Free at Mail.com
More information about the freebsd-sparc64