Weirdness in parsing cpp macros

Ville Syrjälä ville.syrjala at linux.intel.com
Wed Mar 20 13:31:27 UTC 2024


On Wed, Mar 20, 2024 at 02:24:08PM +0100, Julia Lawall wrote:
> 
> 
> On Wed, 20 Mar 2024, Ville Syrjälä wrote:
> 
> > Hi Julia et al,
> >
> > In Linux drm/i915 driver (drivers/gpu/drm/i915/display/intel_pps.[ch])
> > we have a magic macro like this:
> >
> > #define with_intel_pps_lock(dp, wf) \
> 
> Did you try declaring:
> 
> iterator name with_intel_pps_lock;
> 
> up with the metavariables?

Nope, didn't know about that one.

Seems to work fine with that. Thanks.

> 
> julia
> 
> 
> >         for ((wf) = intel_pps_lock(dp); (wf); (wf) = intel_pps_unlock((dp), (wf)))
> >
> >
> > which we can then use like so:
> > ...
> > with_intel_pps_lock(intel_dp, wakeref)
> > 	wait_panel_power_cycle(intel_dp);
> > ...
> >
> >
> > If I try to modify this code with eg.
> >
> > @@
> > @@
> > - wait_panel_power_cycle
> > + _wait_panel_power_cycle
> >
> > spatch fails to parse the macro and won't do the changes here.
> >
> >
> > While experimenting with this I discovered that
> > I can make it work by:
> > - moving the macro definition into intel_pps.c file from intel_pps.h
> > - renaming the macro to contain the substring "for" (doesn't matter
> >   where in the macro name the "for" appears)
> >
> > What on earth is going on here?
> >
> > --
> > Ville Syrjälä
> > Intel
> >


-- 
Ville Syrjälä
Intel


More information about the Intel-gfx mailing list