[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen: add header guards to generated asm generic headers
On Thu, 5 Jun 2025, Jan Beulich wrote: > On 05.06.2025 01:09, Stefano Stabellini wrote: > > --- a/xen/scripts/Makefile.asm-generic > > +++ b/xen/scripts/Makefile.asm-generic > > @@ -32,7 +32,12 @@ old-headers := $(wildcard $(obj)/*.h) > > unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) > > > > quiet_cmd_wrap = WRAP $@ > > - cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ > > + cmd_wrap = \ > > + upper=$$(echo $*.h | tr a-z A-Z | tr '/.' '__'); \ > > + printf "\#ifndef ASM_GENERIC_$${upper}\n" > $@; \ > > + printf "\#define ASM_GENERIC_$${upper}\n" >> $@; \ > > + printf "\#include <asm-generic/$*.h>\n" >> $@; \ > > + printf "\#endif /* ASM_GENERIC_$${upper} */\n" >> $@ > > I'm curious: In what is now a0f56da94c3e I had to resort to "define" to > get the rule to work (including a correct .*.cmd being generated). I > can't claim I actually understood why things didn't work the "simple > macro" way, and hence it's unclear to me whether the way it's done here > will work with all make versions. This works: cmd_xlat_h = \ printf "\#ifndef COMPAT_XLAT_H\n" >$@.new; \ printf "\#define COMPAT_XLAT_H\n" >>$@.new; \ cat $(filter %.h,$^) >>$@.new; \ printf "" >>$@.new; \ printf "\#endif /* COMPAT_XLAT_H */\n" >>$@.new; \ mv -f $@.new $@ I made these changes: - tab instead of spaces - printf instead of echo - escape # and add \n > One further difference to that other commit: If make is interrupted in > the middle of any of these printf-s, an incomplete file may remain. The > cmd_xlat_h rule specifically uses "mv -f $@.new $@" to cover that corner > case. Good point I can fix it > Finally - is ASM_GENERIC_$${upper} actually correct? Isn't that the > guard that ought to be used _in_ asm-generic/$*.h? You are right
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |