Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp457604imb; Fri, 1 Mar 2019 05:25:02 -0800 (PST) X-Google-Smtp-Source: APXvYqzAEloI9CahpVy+XWVqhe96olApuV2d3U+shC5rohV9GShh3i3Wjxe+z2AvylHiB1PPhoR/ X-Received: by 2002:a63:1cd:: with SMTP id 196mr4929635pgb.58.1551446702120; Fri, 01 Mar 2019 05:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551446702; cv=none; d=google.com; s=arc-20160816; b=LHcZOMD6/ZcGXeOtVm73Yqycn7wKbZVOePPe9VS+y3xWccLHt/kg6Joow6TbZRJlqc LjlxXWy3fqXxRwgC4wBblFCrSlqodBkvrFhZ/aRTVIJJ9m9NUxzNBXvpwnSDjW6OL8HJ TBaUn0H4AAFR2ic8yVdIt5XlehLuDAaL2SnjvvC4+UndN0rWNSoo5HrrQGVqrFXCreRt 0oxgWWmRcGoMstdDjaVg/PKiWEzMV2pN7y3SLeXgEz/FzyFAW0LArTpJqXOXN34LXVH2 CGKr6es+FCPqAUy4h1H+yrZFDOEku+jdQOa2EQ0Cw8j3xMEpxq0yu7JY8vNIEyktt8n5 sGhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version; bh=VWyc/WNCi93l9SwjEWnUETRcieq5emZMgbvHEBTapzM=; b=iWMVPBy35bkC4x10LqRE3qg6fW5Gk3IQq//7OCdeGW2EMAV2VZ/2ja8LfKVBED0CML oWRzSoDUsMscBgizY/8AZXNayVV1Vum5r+I0wEL8cI8YZBEy2EkHIasjEcrjRYZIVyZV 7SFLkFT6e6KOsoYC1KAxeQ5795l0+9y1cOzz3o6lSM2oIWPLfgZB4guwpvuIsd/yuTx7 lTmgVECtDiVl4wuYr9cs1/1wOMsUf1N1blFjiQCYRWhvHaACXTu9xAmdH1+1DTlnm1yv JEZdGmWFu04SaFQ5he1Gjl6pNMjWQpIdxoctTJCy0SY/4wMRxgL/tq8JwwtQBr1g2lbk P4Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si17941974pln.403.2019.03.01.05.24.47; Fri, 01 Mar 2019 05:25:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728290AbfCANIR convert rfc822-to-8bit (ORCPT + 99 others); Fri, 1 Mar 2019 08:08:17 -0500 Received: from mail.fireflyinternet.com ([109.228.58.192]:49940 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725978AbfCANIR (ORCPT ); Fri, 1 Mar 2019 08:08:17 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 15743600-1500050 for multiple; Fri, 01 Mar 2019 13:08:01 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Jani Nikula , linux-kernel@vger.kernel.org From: Chris Wilson In-Reply-To: <20190301125207.30973-1-jani.nikula@intel.com> Cc: Andrew Morton , jani.nikula@intel.com References: <20190301125207.30973-1-jani.nikula@intel.com> Message-ID: <155144567811.6459.11821776880949183246@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH] log2: make is_power_of_2() integer constant expression when possible Date: Fri, 01 Mar 2019 13:07:58 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Jani Nikula (2019-03-01 12:52:07) > While is_power_of_2() is an inline function and likely gets optimized > for compile time constant arguments, it still doesn't produce an integer > constant expression that could be used in, say, static data > initialization or case labels. > > Make is_power_of_2() an integer constant expression when possible, > otherwise using the inline function to avoid multiple evaluation of the > parameter. > > Cc: Chris Wilson > Signed-off-by: Jani Nikula It does what it says on the tin and allows for static const is_pot = is_power_of_two(32); or in the actual case of interest, BUILD_BUG_ON(is_power_of_two(x) ? test1(x) : test2(x)). The only question remains can build_bug.h include ilog2.h and use this macro instead of having its own copy? Or that may be overkill for a single commonplace macro. Reviewed-by: Chris Wilson -Chris