[Mesa-dev] [PATCH v2 1/9] util/macros: Import ALIGN_POT from ralloc.c

Brian Paul brianp at vmware.com
Mon Jul 2 13:33:37 UTC 2018


On 06/29/2018 06:13 PM, Jason Ekstrand wrote:
> ---
>   src/util/macros.h | 3 +++
>   src/util/ralloc.c | 2 --
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/macros.h b/src/util/macros.h
> index 6d3df904082..95b86c7a31a 100644
> --- a/src/util/macros.h
> +++ b/src/util/macros.h
> @@ -285,6 +285,9 @@ do {                       \
>   #define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
>   #define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
>   
> +/** Align a value to a power of two */
> +#define ALIGN_POT(x, y) (((x) + (y) - 1) & ~((y) - 1))

Maybe improve the comment to say that y must be a power of two value?

Maybe rename 'y' to 'pot'?

The same macro is in src/util/slab.c and build_id.c too (at least).

-Brian

> +
>   /**
>    * Macro for declaring an explicit conversion operator.  Defaults to an
>    * implicit conversion if C++11 is not supported.
> diff --git a/src/util/ralloc.c b/src/util/ralloc.c
> index 42cfa2e391d..5d77f75ee85 100644
> --- a/src/util/ralloc.c
> +++ b/src/util/ralloc.c
> @@ -553,8 +553,6 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
>    * other buffers.
>    */
>   
> -#define ALIGN_POT(x, y) (((x) + (y) - 1) & ~((y) - 1))
> -
>   #define MIN_LINEAR_BUFSIZE 2048
>   #define SUBALLOC_ALIGNMENT sizeof(uintptr_t)
>   #define LMAGIC 0x87b9c7d3
> 



More information about the mesa-dev mailing list