Module: Mesa
Branch: main
Commit: b389bccccd689a6f488501ed4884068b73b83098
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b389bccccd689a6f488501ed4884068b73b83098

Author: Yonggang Luo <luoyongg...@gmail.com>
Date:   Fri Nov  3 03:58:53 2023 +0800

util,compiler: Avoid use align as variable, replace it with other names

align is a function and when we want use it, the align variable will shadow it
So replace it with other names

Signed-off-by: Yonggang Luo <luoyongg...@gmail.com>
Reviewed-by: Alyssa Rosenzweig <aly...@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26885>

---

 src/compiler/glsl_types.h |  4 ++--
 src/util/ralloc.c         | 20 ++++++++++----------
 src/util/ralloc.h         |  4 ++--
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 07a2df75047..15740f6087d 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -1065,7 +1065,7 @@ const glsl_type *glsl_get_column_type(const glsl_type *t);
  * The size/align func is only called for scalar and vector types and the
  * returned type is otherwise laid out in the natural way as follows:
  *
- *  - Arrays and matrices have a stride of ALIGN(elem_size, elem_align).
+ *  - Arrays and matrices have a stride of align(elem_size, elem_align).
  *
  *  - Structure types have their elements in-order and as tightly packed as
  *    possible following the alignment required by the size/align func.
@@ -1079,7 +1079,7 @@ const glsl_type *glsl_get_column_type(const glsl_type *t);
  */
 const glsl_type *glsl_get_explicit_type_for_size_align(const glsl_type *type,
                                                               
glsl_type_size_align_func type_info,
-                                                              unsigned *size, 
unsigned *align);
+                                                              unsigned *size, 
unsigned *alignment);
 
 const glsl_type *glsl_type_replace_vec3_with_vec4(const glsl_type *type);
 
diff --git a/src/util/ralloc.c b/src/util/ralloc.c
index 95b80a87991..80287f1ea37 100644
--- a/src/util/ralloc.c
+++ b/src/util/ralloc.c
@@ -803,23 +803,23 @@ create_slab(gc_ctx *ctx, unsigned bucket)
 }
 
 void *
-gc_alloc_size(gc_ctx *ctx, size_t size, size_t align)
+gc_alloc_size(gc_ctx *ctx, size_t size, size_t alignment)
 {
    assert(ctx);
-   assert(util_is_power_of_two_nonzero(align));
+   assert(util_is_power_of_two_nonzero(alignment));
 
-   align = MAX2(align, alignof(gc_block_header));
+   alignment = MAX2(alignment, alignof(gc_block_header));
 
    /* Alignment will add at most align-alignof(gc_block_header) bytes of 
padding to the header, and
     * the IS_PADDING byte can only encode up to 127.
     */
-   assert((align - alignof(gc_block_header)) <= 127);
+   assert((alignment - alignof(gc_block_header)) <= 127);
 
    /* We can only align as high as the slab is. */
-   assert(align <= HEADER_ALIGN);
+   assert(alignment <= HEADER_ALIGN);
 
-   size_t header_size = align64(sizeof(gc_block_header), align);
-   size = align64(size, align);
+   size_t header_size = align64(sizeof(gc_block_header), alignment);
+   size = align64(size, alignment);
    size += header_size;
 
    gc_block_header *header = NULL;
@@ -846,14 +846,14 @@ gc_alloc_size(gc_ctx *ctx, size_t size, size_t align)
    if ((header_size - 1) != offsetof(gc_block_header, flags))
       ptr[-1] = IS_PADDING | (header_size - sizeof(gc_block_header));
 
-   assert(((uintptr_t)ptr & (align - 1)) == 0);
+   assert(((uintptr_t)ptr & (alignment - 1)) == 0);
    return ptr;
 }
 
 void *
-gc_zalloc_size(gc_ctx *ctx, size_t size, size_t align)
+gc_zalloc_size(gc_ctx *ctx, size_t size, size_t alignment)
 {
-   void *ptr = gc_alloc_size(ctx, size, align);
+   void *ptr = gc_alloc_size(ctx, size, alignment);
 
    if (likely(ptr))
       memset(ptr, 0, size);
diff --git a/src/util/ralloc.h b/src/util/ralloc.h
index 2078a88ff07..1af4da8c824 100644
--- a/src/util/ralloc.h
+++ b/src/util/ralloc.h
@@ -498,8 +498,8 @@ gc_ctx *gc_context(const void *parent);
 #define gc_zalloc_zla(ctx, type, type2, count) \
    gc_zalloc_size(ctx, sizeof(type) + sizeof(type2) * (count), 
MAX2(alignof(type), alignof(type2)))
 
-void *gc_alloc_size(gc_ctx *ctx, size_t size, size_t align) MALLOCLIKE;
-void *gc_zalloc_size(gc_ctx *ctx, size_t size, size_t align) MALLOCLIKE;
+void *gc_alloc_size(gc_ctx *ctx, size_t size, size_t alignment) MALLOCLIKE;
+void *gc_zalloc_size(gc_ctx *ctx, size_t size, size_t alignment) MALLOCLIKE;
 void gc_free(void *ptr);
 gc_ctx *gc_get_context(void *ptr);
 

Reply via email to