Re: ioctl(2) vs sys/ioctl.h

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Laight
Date: Sunday, December 19, 2010 - 12:32 pm

On Sat, Dec 18, 2010 at 04:06:15PM -0800, Paul Goyette wrote:
...
...

As mentioned by others, historically the 3rd arg to ioctl was either
a pointer or a constant.
Pre ANSI-C this didn't matter.

There is a bigger problem, the 'int' and 'void *' arguments might be
passed in different ways then '...' is specified.
For a userspace varargs function this isn't a problem - it is taken
care of by va_arg(), but for a sycall stub this isn't true since the
type of the argument isn't known early enough.

I suspect the only form that will work is soemthing like:

int ioctl(int, unsigned long, void *);
#define ioctl(fd, cmd, arg) ioctl(fd, cmd, (void *)(intptr_t)(arg))

We only get away with it on our 64 bit archs because they all pass the
first 3 arguments in registers.

	David

-- 
David Laight: david@l8s.co.uk
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ioctl(2) vs sys/ioctl.h, Paul Goyette, (Sat Dec 18, 5:06 pm)
Re: ioctl(2) vs sys/ioctl.h, Christos Zoulas, (Sat Dec 18, 5:24 pm)
Re: ioctl(2) vs sys/ioctl.h, der Mouse, (Sat Dec 18, 7:44 pm)
Re: ioctl(2) vs sys/ioctl.h, Iain Hibbert, (Sun Dec 19, 2:35 am)
Re: ioctl(2) vs sys/ioctl.h, Paul Goyette, (Sun Dec 19, 9:00 am)
Re: ioctl(2) vs sys/ioctl.h, David Laight, (Sun Dec 19, 12:32 pm)
Re: ioctl(2) vs sys/ioctl.h, Rhialto, (Sun Dec 19, 1:06 pm)
Re: ioctl(2) vs sys/ioctl.h, David Laight, (Sun Dec 19, 1:32 pm)
Re: ioctl(2) vs sys/ioctl.h, der Mouse, (Sun Dec 19, 2:52 pm)
Re: ioctl(2) vs sys/ioctl.h, Christos Zoulas, (Sun Dec 19, 2:59 pm)