util/treewide: Use alignas(x) instead __attribute__((aligned(x)))

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>
This commit is contained in:
Yonggang Luo
2023-07-04 12:26:28 +08:00
committed by Marge Bot
parent 8c25cd307a
commit d130c96bda
6 changed files with 16 additions and 14 deletions

View 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

View 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

View 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;

View 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;
};

View 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 {

View 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));