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

From: Horst von Brand (vonbrand@pincoya.inf.utfsm.cl)
Date: Fri Mar 17 2000 - 15:28:25 EST


Jakub Jelinek <jakub@redhat.com> said:

[...]

> Can you elaborate more on how could gcc someday decide to use an inline
> function with completely different name?

AFAIU, what your macro is supposed to be doing is:

   static int g(int x) { /* ... */ }

   int public_func(int) __alias__(("g"));
   extern inline int g(int x) { return x; }

Now there are two different definitions of g() in the source, this is
definitely wrong.

What I see your macro doing is totally different, BTW. Perhaps you meant
something like:

   extern inline int throw_this_away(int x) { return g(x); }

? This won't protect against some lost soul defining:

   static double g(float x);

...

What I propose is:

a) Get GCC to consider the alias as an use
b) A macro that does:

   int public_func(int) __alias__(("g"));
   static int g(int);

The prototype protects against strange definitions of g(), and is legal
anyway, even when placed before the definition of g() proper.

But perhaps I'm just being dense...

-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

- 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 : Thu Mar 23 2000 - 21:00:22 EST