All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH] drm/i915: Use __is_constexpr()
Date: Thu, 21 Mar 2019 11:50:25 +0200	[thread overview]
Message-ID: <87o964eeu6.fsf@intel.com> (raw)
In-Reply-To: <20190320154021.5244-1-chris@chris-wilson.co.uk>

On Wed, 20 Mar 2019, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> gcc-4.8 and older dislike the use of __builtin_constant_p() within a
> constant expression context, and so we must use the magical
> __is_constexpr() instead.
>
> For example, with gcc-4.8.5:
> ../drivers/gpu/drm/i915/i915_reg.h:167:27: error: first argument to ‘__builtin_choose_expr’ not a constant
> ../include/linux/build_bug.h:16:45: error: bit-field ‘<anonymous>’ width not an integer constant
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: baa09e7d2f42 ("drm/i915: use REG_FIELD_PREP() to define register bitfield values")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>

Thanks, Uma reported this too and confirmed __is_constexpr works.

Reported-by: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_reg.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 85e8d1a1f70b..50d0b2ae89eb 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -161,10 +161,10 @@
>   */
>  #define REG_FIELD_PREP(__mask, __val)						\
>  	((u32)((((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) +	\
> -	       BUILD_BUG_ON_ZERO(!__builtin_constant_p(__mask)) +		\
> +	       BUILD_BUG_ON_ZERO(!__is_constexpr(__mask)) +		\
>  	       BUILD_BUG_ON_ZERO((__mask) == 0 || (__mask) > U32_MAX) +		\
>  	       BUILD_BUG_ON_ZERO(!IS_POWER_OF_2((__mask) + (1ULL << __bf_shf(__mask)))) + \
> -	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__builtin_constant_p(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
> +	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
>  
>  /**
>   * REG_FIELD_GET() - Extract a u32 bitfield value

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-03-21  9:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 15:40 [PATCH] drm/i915: Use __is_constexpr() Chris Wilson
2019-03-20 16:05 ` Randy Dunlap
2019-03-20 17:20 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2019-03-21  9:50 ` Jani Nikula [this message]
2019-03-21 10:00   ` [PATCH] " Chris Wilson

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=87o964eeu6.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rdunlap@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.