mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Jon Smirl <jonsmirl@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: __initcall macros and C token pasting
Date: Sat, 25 Sep 2004 19:32:34 +0100	[thread overview]
Message-ID: <20040925183234.GU23987@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <9e47339104092510574c908525@mail.gmail.com>

On Sat, Sep 25, 2004 at 01:57:37PM -0400, Jon Smirl wrote:
> #define DRM(x) r128_##x
> module_init( DRM(init) );
> 
> #define __define_initcall(level,fn) \
>         static initcall_t __initcall_##fn __attribute_used__ \
>         __attribute__((__section__(".initcall" level ".init"))) = fn
> 
> This gives the error:
> {standard input}: Assembler messages:
> {standard input}:104: Error: junk at end of line, first unrecognized
> character is `('
> 
> I believe this is because the C macro is not being expanded in the
> assembler context of the section with the fn assignment.

BS.  In non-modular case (quoted above) DRM(init) will be expanded _long_
before you get to __define_initcall() expansion.

In the modular case, OTOH, it will _not_.  There you get
module_init(DRM(init))  =>
static inline initcall_t __inittest(void) { return initfn; } int init_module(void) __attribute__((alias("DRM(init)")));
since # suppresses expansion of argument.  Which leaves you with
.globl init_module
	.set init_module, DRM(init)
in assembler output.  Which is not going to make as(1) happy.

> Any ideas on how to fix this?

To fix what, exactly?  Your beliefs?  DRM abuse of cpp?  For the former I'd
suggest learning C (or learning to use -S to see what exactly as(1) gets to
deal with).  For the latter...

#define DRM_abuses_cpp_too_fscking_much(x) module_init(x)
DRM_abuses_cpp_too_fscking_much(DRM(init))

will force the expansion before it gets to module_init(), which will result in
acceptable alias.

  reply	other threads:[~2004-09-25 18:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-25 17:57 Jon Smirl
2004-09-25 18:32 ` viro [this message]
2004-09-25 18:40   ` Jon Smirl
2004-09-25 19:17   ` Jon Smirl
2004-09-26 17:21     ` Olivier Galibert
2004-09-26 17:24       ` Tonnerre
2004-09-26 17:42         ` Christoph Hellwig
2004-09-26 19:56         ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040925183234.GU23987@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=jonsmirl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®