lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151007065747.GA7837@gmail.com>
Date:	Wed, 7 Oct 2015 08:57:47 +0200
From:	Ingo Molnar <mingo@...nel.org>
To:	Rasmus Villemoes <linux@...musvillemoes.dk>
Cc:	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Jiri Slaby <jslaby@...e.cz>, Ingo Molnar <mingo@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>, Michal Marek <mmarek@...e.cz>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] linux/kconfig.h: generalize IS_ENABLED logic


* Rasmus Villemoes <linux@...musvillemoes.dk> wrote:

> +#define _COMMA ,
> +#define _COND_PUNCTUATION_0(p)
> +#define _COND_PUNCTUATION_1(p) p
> +
> +#define CHOOSE_EXPR(cfg, expr, ...) _CHOOSE_EXPR(cfg, expr, ##__VA_ARGS__, /* empty defalt arg */)
> +#define _CHOOSE_EXPR(cfg, expr, def, ...) __CHOOSE_EXPR(__ARG_PLACEHOLDER_##cfg, expr, def)
> +#define __CHOOSE_EXPR(arg1_or_junk, expr, def) ___CHOOSE_EXPR(arg1_or_junk expr, def)
> +#define ___CHOOSE_EXPR(__ignored, expr, ...) expr
> +
> +#define COND_DECLARATION(cfg, decl) _COND_DECLARATION(cfg, decl, CHOOSE_EXPR(cfg, 1, 0))
> +#define _COND_DECLARATION(cfg, decl, sfx) __COND_DECLARATION(cfg, decl, sfx)
> +#define __COND_DECLARATION(cfg, decl, sfx) CHOOSE_EXPR(cfg, decl) _COND_PUNCTUATION_##sfx(;)
> +#define COND_INITIALIZER(cfg, init) _COND_INITIALIZER(cfg, init, CHOOSE_EXPR(cfg, 1, 0))
> +#define _COND_INITIALIZER(cfg, init, sfx) __COND_INITIALIZER(cfg, init, sfx)
> +#define __COND_INITIALIZER(cfg, init, sfx) CHOOSE_EXPR(cfg, init) _COND_PUNCTUATION_##sfx(_COMMA)

Pet peeve, mind structuring this in a typographically more readable fashion, by 
adding some common-sense vertical structure to the definitions:

#define    CHOOSE_EXPR(cfg, expr, ...)		  _CHOOSE_EXPR(cfg, expr, ##__VA_ARGS__, /* empty defalt arg */)
#define   _CHOOSE_EXPR(cfg, expr, def, ...)	 __CHOOSE_EXPR(__ARG_PLACEHOLDER_##cfg, expr, def)
#define  __CHOOSE_EXPR(arg1_or_junk, expr, def)	___CHOOSE_EXPR(arg1_or_junk expr, def)
#define ___CHOOSE_EXPR(__ignored, expr, ...)	expr

#define   COND_DECLARATION(cfg, decl)	    _COND_DECLARATION(cfg, decl, CHOOSE_EXPR(cfg, 1, 0))
#define  _COND_DECLARATION(cfg, decl, sfx) __COND_DECLARATION(cfg, decl, sfx)
#define __COND_DECLARATION(cfg, decl, sfx) CHOOSE_EXPR(cfg, decl) _COND_PUNCTUATION_##sfx(;)

#define   COND_INITIALIZER(cfg, init)	    _COND_INITIALIZER(cfg, init, CHOOSE_EXPR(cfg, 1, 0))
#define  _COND_INITIALIZER(cfg, init, sfx) __COND_INITIALIZER(cfg, init, sfx)
#define __COND_INITIALIZER(cfg, init, sfx) CHOOSE_EXPR(cfg, init) _COND_PUNCTUATION_##sfx(_COMMA)

?

It's still a mouthful, but at least readable at a glance.

Thanks,

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ