Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 2024

kernel-2.6.18-238.el5.src.rpm

From: Jiri Pirko <jpirko@redhat.com>
Date: Thu, 22 Jan 2009 10:20:29 +0100
Subject: [misc] make ioctl.h compatible with userland
Message-id: 20090122092028.GC3421@psychotron.englab.brq.redhat.com
O-Subject: [RHEL5.4 patch] BZ473947 Make ioctl.h compatible with userland
Bugzilla: 473947
RH-Acked-by: Mikulas Patocka <mpatocka@redhat.com>

BZ473947
https://bugzilla.redhat.com/show_bug.cgi?id=473947

Description:
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.

This is not the problem for gcc, but other compilers, e.g. Intel compiler, may
have problem with this.

Upstream:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5f8c3c8edff426fd87098f057688463107fcd9ce

Brew:
https://brewweb.devel.redhat.com/taskinfo?taskID=1651116

Test:
Booted on x86_64. Tested by the reporter on i686 (I do not have Intel compiler
to test this).

Jirka

diff --git a/include/asm-generic/ioctl.h b/include/asm-generic/ioctl.h
index cd02729..4a4bf0a 100644
--- a/include/asm-generic/ioctl.h
+++ b/include/asm-generic/ioctl.h
@@ -47,12 +47,16 @@
 	 ((nr)   << _IOC_NRSHIFT) | \
 	 ((size) << _IOC_SIZESHIFT))
 
+#ifdef __KERNEL__
 /* provoke compile error for invalid uses of size argument */
 extern unsigned int __invalid_size_argument_for_IOC;
 #define _IOC_TYPECHECK(t) \
 	((sizeof(t) == sizeof(t[1]) && \
 	  sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
 	  sizeof(t) : __invalid_size_argument_for_IOC)
+#else
+#define _IOC_TYPECHECK(t) (sizeof(t))
+#endif
 
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)