util/treewide: Use alignas(x) instead __attribute__((aligned(x)))
authorYonggang Luo <luoyonggang@gmail.com>
Tue, 4 Jul 2023 04:26:28 +0000 (12:26 +0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 9 Aug 2023 05:15:09 +0000 (05:15 +0000)
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24571>

src/freedreno/vulkan/tu_device.h
src/freedreno/vulkan/tu_util.h
src/gallium/drivers/iris/iris_bufmgr.h
src/intel/vulkan/anv_private.h
src/intel/vulkan_hasvk/anv_private.h
src/virtio/vulkan/vn_ring.c

index 4a7422f..bf119ca 100644 (file)
@@ -58,7 +58,7 @@ struct tu_memory_heap {
     *
     * Align it to 64 bits to make atomic operations faster on 32 bit platforms.
     */
-   VkDeviceSize      used __attribute__ ((aligned (8)));
+   alignas(8) VkDeviceSize used;
 };
 
 struct tu_physical_device
index 589fe52..1af4b61 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "tu_common.h"
 
+#include "util/macros.h"
 #include "util/u_math.h"
 #include "util/format/u_format_pack.h"
 #include "util/format/u_format_zs.h"
@@ -356,7 +357,7 @@ tu6_polygon_mode(VkPolygonMode mode)
 }
 
 struct bcolor_entry {
-   uint32_t fp32[4];
+   alignas(128) uint32_t fp32[4];
    uint64_t ui16;
    uint64_t si16;
    uint64_t fp16;
@@ -370,7 +371,8 @@ struct bcolor_entry {
    uint32_t z24; /* also s8? */
    uint64_t srgb;
    uint8_t  __pad1[56];
-} __attribute__((aligned(128)));
+};
+static_assert(alignof(struct bcolor_entry) == 128, "");
 
 /* vulkan does not want clamping of integer clear values, differs from u_format
  * see spec for VkClearColorValue
index 5ba8c69..8dfd729 100644 (file)
@@ -234,7 +234,7 @@ struct iris_bo {
     * Also align it to 64 bits. This will make atomic operations faster on 32
     * bit platforms.
     */
-   uint64_t last_seqnos[NUM_IRIS_DOMAINS] __attribute__ ((aligned (8)));
+   alignas(8) uint64_t last_seqnos[NUM_IRIS_DOMAINS];
 
    /** Up to one per screen, may need realloc. */
    struct iris_bo_screen_deps *deps;
index 30a21ca..fe2e0a5 100644 (file)
@@ -564,7 +564,7 @@ union anv_free_list {
    /* Make sure it's aligned to 64 bits. This will make atomic operations
     * faster on 32 bit platforms.
     */
-   uint64_t u64 __attribute__ ((aligned (8)));
+   alignas(8) uint64_t u64;
 };
 
 #define ANV_FREE_LIST_EMPTY ((union anv_free_list) { { UINT32_MAX, 0 } })
@@ -578,7 +578,7 @@ struct anv_block_state {
       /* Make sure it's aligned to 64 bits. This will make atomic operations
        * faster on 32 bit platforms.
        */
-      uint64_t u64 __attribute__ ((aligned (8)));
+      alignas(8) uint64_t u64;
    };
 };
 
@@ -845,7 +845,7 @@ struct anv_memory_heap {
     *
     * Align it to 64 bits to make atomic operations faster on 32 bit platforms.
     */
-   VkDeviceSize      used __attribute__ ((aligned (8)));
+   alignas(8) VkDeviceSize used;
 
    bool              is_local_mem;
 };
index 51233fa..9819f66 100644 (file)
@@ -536,7 +536,7 @@ union anv_free_list {
    /* Make sure it's aligned to 64 bits. This will make atomic operations
     * faster on 32 bit platforms.
     */
-   uint64_t u64 __attribute__ ((aligned (8)));
+   alignas(8) uint64_t u64;
 };
 
 #define ANV_FREE_LIST_EMPTY ((union anv_free_list) { { UINT32_MAX, 0 } })
@@ -550,7 +550,7 @@ struct anv_block_state {
       /* Make sure it's aligned to 64 bits. This will make atomic operations
        * faster on 32 bit platforms.
        */
-      uint64_t u64 __attribute__ ((aligned (8)));
+      alignas(8) uint64_t u64;
    };
 };
 
@@ -836,7 +836,7 @@ struct anv_memory_heap {
     *
     * Align it to 64 bits to make atomic operations faster on 32 bit platforms.
     */
-   VkDeviceSize      used __attribute__ ((aligned (8)));
+   alignas(8) VkDeviceSize used;
 };
 
 struct anv_memregion {
index 715cbaa..76fca33 100644 (file)
@@ -151,11 +151,11 @@ vn_ring_get_layout(size_t buf_size,
 {
    /* this can be changed/extended quite freely */
    struct layout {
-      uint32_t head __attribute__((aligned(64)));
-      uint32_t tail __attribute__((aligned(64)));
-      uint32_t status __attribute__((aligned(64)));
+      alignas(64) uint32_t head;
+      alignas(64) uint32_t tail;
+      alignas(64) uint32_t status;
 
-      uint8_t buffer[] __attribute__((aligned(64)));
+      alignas(64) uint8_t buffer[];
    };
 
    assert(buf_size && util_is_power_of_two_or_zero(buf_size));