mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
util/u_vector: prevent C++ warning on cast from void* to something else
v2: fix windows build v3: duplicate foreach macro for C/C++ v4: Extract casting macro Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Dylan Baker <dylan@pnwbakers.com> (v3) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13997>
This commit is contained in:
parent
55b396e743
commit
a3886fa471
1 changed files with 9 additions and 1 deletions
|
|
@ -98,10 +98,18 @@ u_vector_finish(struct u_vector *queue)
|
|||
free(queue->data);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define u_vector_element_cast(elem) (decltype(elem))
|
||||
#else
|
||||
#define u_vector_element_cast(elem) (void *)
|
||||
#endif
|
||||
|
||||
#define u_vector_foreach(elem, queue) \
|
||||
STATIC_ASSERT(__builtin_types_compatible_p(__typeof__(queue), struct u_vector *)); \
|
||||
for (uint32_t __u_vector_offset = (queue)->tail; \
|
||||
elem = (void *)((char *)(queue)->data + (__u_vector_offset & ((queue)->size - 1))), __u_vector_offset != (queue)->head; \
|
||||
elem = u_vector_element_cast(elem)((char *)(queue)->data + \
|
||||
(__u_vector_offset & ((queue)->size - 1))), \
|
||||
__u_vector_offset != (queue)->head; \
|
||||
__u_vector_offset += (queue)->element_size)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue