Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make ioctl.h compatible with userland

The attached patch seems to already exist in a number of branches -- it
keeps popping up on Google for me, and is certainly already in Debian --
but is strangely absent from mainstream.

The problem appears to be that the patched file ends up as part of the
target toolchain, but unfortunately the gcc constant folding doesn't
appear to eliminate the __invalid_size_argument_for_IOC value early
enough. Certainly compiling C++ programs which use _IO... macros as
constants fails without this patch.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Michael Abbott and committed by
Linus Torvalds
5f8c3c8e 66659313

+4
+4
include/asm-generic/ioctl.h
··· 68 68 ((nr) << _IOC_NRSHIFT) | \ 69 69 ((size) << _IOC_SIZESHIFT)) 70 70 71 + #ifdef __KERNEL__ 71 72 /* provoke compile error for invalid uses of size argument */ 72 73 extern unsigned int __invalid_size_argument_for_IOC; 73 74 #define _IOC_TYPECHECK(t) \ 74 75 ((sizeof(t) == sizeof(t[1]) && \ 75 76 sizeof(t) < (1 << _IOC_SIZEBITS)) ? \ 76 77 sizeof(t) : __invalid_size_argument_for_IOC) 78 + #else 79 + #define _IOC_TYPECHECK(t) (sizeof(t)) 80 + #endif 77 81 78 82 /* used to create numbers */ 79 83 #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)