Re: [PATCH] warning: `__attribute_used__' redefined

From: Daniel Jacobowitz
Date: Tue Feb 10 2004 - 12:18:47 EST


On Tue, Feb 10, 2004 at 08:31:24AM -0800, Linus Torvalds wrote:
>
>
> On Tue, 10 Feb 2004, Andrew Morton wrote:
> >
> > ah, thanks.
> >
> > Like this?
>
> That will just break. The reason for the "compiler.h" include is the
> "__user" part of fpstate, so now you'll get a parse error later if
> non-kernel code includes this.
>
> So the rule should still be: don't include kernel headers from user
> programs. But if it's needed for some reason, that #ifdef needs to be
> somewhere else (inside "compiler.h" or something).

This is what Debian has been using. I believe the other folks with a
glibc-kernel-headers package based on 2.6 do something similar. I
don't know how you'll feel about adding this sort of crap to the
kernel, though. Someone else needs to find time to start linuxabi
moving again...

--- include/linux/compiler.h 2003-10-15 11:13:09.000000000 -0400
+++ include/linux/compiler.h.t 2003-11-01 18:04:19.000000000 -0500
@@ -9,6 +9,15 @@
# define __kernel
#endif

+#if !defined(__KERNEL__)
+/* Debian: Most of these are inappropriate for userspace. */
+/* We don't define likely, unlikely, or barrier; they're namespace-intrusive
+ and should not be needed outside of __KERNEL__. For __attribute_pure__
+ and __attribute_used__ we use glibc's definitions. */
+# include <sys/cdefs.h>
+# define __deprecated
+#else
+
#if __GNUC__ > 3
# include <linux/compiler-gcc+.h> /* catch-all for GCC 4, 5, etc. */
#elif __GNUC__ == 3
@@ -86,4 +95,6 @@
(typeof(ptr)) (__ptr + (off)); })
#endif

+#endif /* __KERNEL__ */
+
#endif /* __LINUX_COMPILER_H */

--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/