[PATCH 4/9] linux/const.h: Upgrade & Merge vDSO and uAPI

Simon Glass sjg at chromium.org
Wed Mar 16 20:23:44 CET 2022


Hi Pierre-Clément,

On Wed, 16 Mar 2022 at 09:40, Pierre-Clément Tosi <ptosi at 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 <ptosi at google.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at 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.

> +
> +#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.Uecker at 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


More information about the U-Boot mailing list