[PATCH i-g-t 1/3] lib/drmtest: Add IS_ALIGNED macro

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Mar 5 04:15:51 UTC 2024


On Fri, Mar 01, 2024 at 04:15:39PM +0100, Piórkowski, Piotr wrote:
> From: Piotr Piórkowski <piotr.piorkowski at intel.com>
> 
> Let's add a new macro that will be used to verify whether one value is
> aligned to the other.
> 
> Signed-off-by: Piotr Piórkowski <piotr.piorkowski at intel.com>
> ---
>  lib/drmtest.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/drmtest.h b/lib/drmtest.h
> index 6bc819734..588d7da17 100644
> --- a/lib/drmtest.h
> +++ b/lib/drmtest.h
> @@ -99,6 +99,15 @@ void __set_forced_driver(const char *name);
>   */
>  #define ALIGN_DOWN(x, a)	ALIGN((x) - ((a) - 1), (a))
>  
> +/**
> + * IS_ALIGNED:
> + * @v: value to check
> + * @a: alignment unit in bytes
> + *
> + * Macro to check if value @v is aligned to @a
> + */
> +#define IS_ALIGNED(v, a)	(((v) & ((typeof(v))(a) - 1)) == 0)
> +
>  int __drm_open_device(const char *name, unsigned int chipset);
>  void drm_load_module(unsigned int chipset);
>  int drm_open_driver(int chipset);
> -- 
> 2.34.1
>

There's no current user but code looks good to me, so:

Acked-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew


More information about the igt-dev mailing list