From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] kernel.h: Skip single-eval logic on literals in min()/max() Date: Thu, 08 Mar 2018 21:59:11 +0000 Message-ID: <1520546351.23648.32.camel@hellion.org.uk> References: <20180308214045.GA6787@beast> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Cc: Josh Poimboeuf , Rasmus Villemoes , "Gustavo A. R. Silva" , "Tobin C. Harding" , rostedt@goodmis.org, corbet@lwn.net, Chris Mason , Josef Bacik , David Sterba , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Masahiro Yamada , Borislav Petkov , Randy Dunlap , Ian Abbott , Sergey Senozhatsky , Petr Mladek , Andy Shevchenko , Pantelis Antoniou , linux-btrf To: Kees Cook , Andrew Morton Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: In-Reply-To: <20180308214045.GA6787@beast> List-Id: netdev.vger.kernel.org On Thu, 2018-03-08 at 13:40 -0800, Kees Cook wrote: > > +#define __min(t1, t2, x, y) \ > + __builtin_choose_expr(__builtin_constant_p(x) && \ > + __builtin_constant_p(y) && \ > + __builtin_types_compatible_p(t1, t2), \ > + (t1)(x) < (t2)(y) ? (t1)(x) : (t2)(y), \ > + __single_eval_min(t1, t2, \ > + __UNIQUE_ID(max1_), \ > + __UNIQUE_ID(max2_), \ min1_ etc? Ian.