Hi Pierre-Clément, On Thu, 17 Mar 2022 at 05:00, Pierre-Clément Tosi <pt...@google.com> wrote: > > On Wed, Mar 16, 2022 at 01:23:44PM -0600, Simon Glass wrote: > > Hi Pierre-Clément, > > > > On Wed, 16 Mar 2022 at 09:40, Pierre-Clément Tosi <pt...@google.com> wrote: > > > > > > Import the header from version 5.16 of the kernel: > > > > > > commit df0cc57e057f18e44dac8e6c18aba47ab53202f9 > > > > > > Inline <vdso/const.h> and <uapi/linux/const.h>. This is wrapped in > > > "#ifndef __UBOOT__/#include/#else/{inline}" to better document the > > > origin of the code being added to the U-Boot header (but not present in > > > the original header) and make diff tools happier when comparing the file > > > with its reference, which should be useful when porting future changes > > > from the Linux header and/or if we decide to also import those included > > > headers into the U-Boot codebase. > > > > > > Signed-off-by: Pierre-Clément Tosi <pt...@google.com> > > > Cc: Simon Glass <s...@chromium.org> > > > Cc: Tom Rini <tr...@konsulko.com> > > > --- > > > include/linux/const.h | 22 +++++++++++++++++++++- > > > 1 file changed, 21 insertions(+), 1 deletion(-) > > > > > > diff --git a/include/linux/const.h b/include/linux/const.h > > > index 379c889232..3e3803d767 100644 > > > --- a/include/linux/const.h > > > +++ b/include/linux/const.h > > > @@ -2,8 +2,13 @@ > > > #ifndef _LINUX_CONST_H > > > #define _LINUX_CONST_H > > > > > > -/* const.h: Macros for dealing with constants. */ > > > +#ifndef __UBOOT__ > > > +#include <vdso/const.h> > > > +#else > > > > > > +#ifndef __UBOOT__ > > > +#include <uapi/linux/const.h> > > > +#else > > > /* Some constant macros are used in both assembler and > > > * C code. Therefore we cannot annotate them always with > > > * 'UL' and other type specifiers unilaterally. We > > > @@ -28,7 +33,22 @@ > > > #define _BITUL(x) (_UL(1) << (x)) > > > #define _BITULL(x) (_ULL(1) << (x)) > > > > > > +#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, > > > (typeof(x))(a) - 1) > > > +#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) > > > > How does this compare to the existing ALIGN()? It looks the same to me. > > > > __ALIGN_KERNEL() is the uAPI counterpart to the ALIGN() kernel macro (or is it > the other way around?) so they're intended to be similar in implementation; > the > key difference being the double-leading-underscore notation, which bears a > special meaning as per the C Standard, and allows __ALIGN_KERNEL() to be > considerably easier to export. In fact, the kernel currently defines > > #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) > > For the reason why this patch introduces it here, I've taken the conservative > approach of meticulously copying the original headers over, in their entirety > (as far as feasible), in order to make future upgrades as smooth as possible. > > This patch inlines those vDSO and uAPI headers instead of bringing them as the > stand-alone files they are in the kernel as it looks like no other kernel > header > of that kind has been imported but IMO, it would make more sense to do the > later. What do you think?
OK I see. Using stand-alone files makes it easier to keep things in sync in the future, but I don't have a strong opinion on it. Reviewed-by: Simon Glass <s...@chromium.org> > > > > + > > > +#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) > > > +#endif > > > + > > > #define UL(x) (_UL(x)) > > > #define ULL(x) (_ULL(x)) > > > +#endif > > > + > > > +/* > > > + * This returns a constant expression while determining if an argument is > > > + * a constant expression, most importantly without evaluating the > > > argument. > > > + * Glory to Martin Uecker <martin.uec...@med.uni-goettingen.de> > > > + */ > > > +#define __is_constexpr(x) \ > > > + (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int > > > *)8))) > > > > > > #endif /* _LINUX_CONST_H */ > > > -- > > > 2.35.1.723.g4982287a31-goog Regards, Simon