Re: [PATCH] x86: ioport_{32|64}.c unification

From: Valdis . Kletnieks
Date: Sun Jan 06 2008 - 00:56:36 EST


On Sun, 06 Jan 2008 02:20:45 +0100, Miguel =?utf-8?q?Bot=C3=B3n?= said:
> #ifdef CONFIG_X86_32
> asmlinkage long sys_iopl(unsigned long regsp)
> {
> volatile struct pt_regs *regs = (struct pt_regs *)&regsp;
> unsigned int level = regs->bx;
> #else
> asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs)
> {
> #endif
> return do_iopl(level, (long *)&regs->flags);
> }

That looks like an unholy marriage between the preprocessor, a function
definition, and a Duff Device. :)

Do it like this:
#ifdef CONFIG_X86_32
asmlinkage sys_iopl( prototype_needed)
{
/* the whole thing */
}
#else
asmlinkage long sys_iopl(alternate_prototype)
{
/* the entire body */
}
#endif

You'll still need some ad-croc ifdef-ery at the call site to make it use
the correct prototype (unless you can come up with some clever way of making
the two use the same prototype, possibly by passing a dummy argument on
some architectures...

Attachment: pgp00000.pgp
Description: PGP signature