2005-03-20 13:45:40

by Magnus Damm

[permalink] [raw]
Subject: af_unix.c, KBUILD_MODNAME and unix

Hello All,

af_unix.c is currenty built with KBUILD_MODNAME=unix. This seems to
work rather well today, but if someone actually tries to use
KBUILD_MODNAME then they will end up with a preprocessor surprise:
KBUILD_MODNAME -> unix -> 1, because "unix" is defined to 1.

With other words, if someone adds module_param(foo,...) code to
af_unix.c and compiles the code as built in then they will have to use
"1.foo" to set the variable instead of "unix.foo" as expected.

Solution? #undef unix?

I came across this when trying to autogenerate parameter documentation...

/ magnus


2005-03-20 13:52:15

by Russell King

[permalink] [raw]
Subject: Re: af_unix.c, KBUILD_MODNAME and unix

On Sun, Mar 20, 2005 at 02:45:36PM +0100, Magnus Damm wrote:
> Hello All,
>
> af_unix.c is currenty built with KBUILD_MODNAME=unix. This seems to
> work rather well today, but if someone actually tries to use
> KBUILD_MODNAME then they will end up with a preprocessor surprise:
> KBUILD_MODNAME -> unix -> 1, because "unix" is defined to 1.
>
> With other words, if someone adds module_param(foo,...) code to
> af_unix.c and compiles the code as built in then they will have to use
> "1.foo" to set the variable instead of "unix.foo" as expected.
>
> Solution? #undef unix?

or maybe -Uunix ?

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-03-20 14:02:08

by Jan Engelhardt

[permalink] [raw]
Subject: Re: af_unix.c, KBUILD_MODNAME and unix

>> Hello All,
>>
>> af_unix.c is currenty built with KBUILD_MODNAME=unix. This seems to
>> Solution? #undef unix?
>
>or maybe -Uunix ?

Why is not KBUILD_MODNAME=af_unix ?



Jan Engelhardt
--

2005-03-20 15:52:56

by Magnus Damm

[permalink] [raw]
Subject: Re: af_unix.c, KBUILD_MODNAME and unix

> >> af_unix.c is currenty built with KBUILD_MODNAME=unix. This seems to
> >> Solution? #undef unix?
> >
> >or maybe -Uunix ?
>
> Why is not KBUILD_MODNAME=af_unix ?

The exact solution does not matter that much to me, and I'm afraid I
do not know how changing KBUILD_MODNAME affects the rest of the
codebase. So basically - someone else should decide... but who?

/ magnus

2005-03-20 20:17:00

by Bodo Eggert

[permalink] [raw]
Subject: Re: af_unix.c, KBUILD_MODNAME and unix

Magnus Damm <[email protected]> wrote:

> Solution? #undef unix?

#define unix unix?

provided nobody uses unix numerically.

2005-03-20 21:52:10

by Jan Engelhardt

[permalink] [raw]
Subject: Re: af_unix.c, KBUILD_MODNAME and unix

>> Why is not KBUILD_MODNAME=af_unix ?
>
>The exact solution does not matter that much to me, and I'm afraid I
>do not know how changing KBUILD_MODNAME affects the rest of the
>codebase. So basically - someone else should decide... but who?

KBUILD_MODNAME is "not used", which means you can use it for anything that
like. You can undef it, redefine, thwap it all over and whatnot.
It's a generosity from /usr/bin/make generally providing the module with its
own name.




Jan Engelhardt
--