tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ioctl(2) vs sys/ioctl.h
On Sat, Dec 18, 2010 at 04:06:15PM -0800, Paul Goyette wrote:
> Is there some reason why there is a discrepancy in the definition of
> ioctl()?
>
> >From man page ioctl(2)
...
> ioctl(int d, unsigned long request, void *argp);
> Yet, from sys/ioctl.h we have
...
> int ioctl(int, unsigned long, ...);
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@localhost
Home |
Main Index |
Thread Index |
Old Index