[PATCH] static int __init foobar_init(void) {} fix

From: Jakub Jelinek (jakub@redhat.com)
Date: Mon Mar 13 2000 - 09:38:41 EST


On Mon, Mar 13, 2000 at 11:19:21AM +0000, David Woodhouse wrote:
>
> viro@math.psu.edu said:
> > Could gcc folks comment on that? IMO counting alias as valid use is a
> > reasonable idea...
>
> Can we get away with just adding __attribute(unused) to the __init and __exit
> macros?

For __init it is not a good idea IMHO, because gcc will no longer warn about
code which, though marked __init, is static and really never used (as
opposed to having an alias to it.
On the other side, we can cheat:

--- linux/include/linux/init.h.jj Sat Jan 29 21:21:06 2000
+++ linux/include/linux/init.h Mon Mar 13 15:11:55 2000
@@ -98,8 +98,14 @@ extern struct kernel_param __setup_start
 
 /* Not sure what version aliases were introduced in, but certainly in 2.91.66. */
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 91)
-#define module_init(x) int init_module(void) __attribute__((alias(#x)));
-#define module_exit(x) void cleanup_module(void) __attribute__((alias(#x)));
+#define module_init(x) \
+int init_module(void) __attribute__((alias(#x))); \
+extern inline void *__init_module_inline(void) \
+{ return (void *)x; }
+#define module_exit(x) \
+void cleanup_module(void) __attribute__((alias(#x))); \
+extern inline void *__cleanup_module_inline(void) \
+{ return (void *)x; }
 #else
 #define module_init(x) int init_module(void) { return x(); }
 #define module_exit(x) void cleanup_module(void) { x(); }

As the helper routine which uses it is extern inline, it won't be compiled
in (nobody uses it) but is sufficient to shut up at least egcs 1.1.2 and a
month old CVS trunk gcc.
In the future it would be good to fix gcc so that it accounts alias as a
normal use, but this patch should not do any harm even once it is fixed.
Linus, can you please apply it?

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.47 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:25 EST