vulkan/util: Consolidate typed_memcpy
Collapse typed_memcpy definitions into one header. Use do/while(0) pattern to fix MSVC compilation. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7830>
This commit is contained in:
parent
116b6d135d
commit
f86668f487
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "radv_meta.h"
|
||||
|
||||
#include "vk_util.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
|
|
|
@ -183,11 +183,6 @@ radv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask)
|
|||
(b) = __builtin_ffs(__dword) - 1, __dword; \
|
||||
__dword &= ~(1 << (b)))
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
/* Whenever we generate an error, pass it through this function. Useful for
|
||||
* debugging, where we can break on it. Only call at error site, not when
|
||||
* propagating errors. Might be useful to plug in a stack trace here.
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "util/half_float.h"
|
||||
#include "util/u_pack_color.h"
|
||||
#include "vk_format_info.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
const struct v3dv_dynamic_state default_dynamic_state = {
|
||||
.viewport = {
|
||||
|
|
|
@ -114,11 +114,6 @@ pack_emit_reloc(void *cl, const void *reloc) {}
|
|||
for (uint32_t __dword = (dword); \
|
||||
(b) = __builtin_ffs(__dword) - 1, __dword; __dword &= ~(1 << (b)))
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
struct v3dv_instance;
|
||||
|
||||
#ifdef USE_V3D_SIMULATOR
|
||||
|
|
|
@ -66,10 +66,6 @@ extern "C" {
|
|||
|
||||
#define lvp_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
int lvp_get_instance_entrypoint_index(const char *name);
|
||||
int lvp_get_device_entrypoint_index(const char *name);
|
||||
int lvp_get_physical_device_entrypoint_index(const char *name);
|
||||
|
|
|
@ -355,11 +355,6 @@ static inline uintptr_t anv_pack_ptr(void *ptr, int bits, int flags)
|
|||
(b) = __builtin_ffs(__dword) - 1, __dword; \
|
||||
__dword &= ~(1 << (b)))
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
/* Mapping from anv object to VkDebugReportObjectTypeEXT. New types need
|
||||
* to be added here in order to utilize mapping in debug/error/perf macros.
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
#ifndef VK_UTIL_H
|
||||
#define VK_UTIL_H
|
||||
|
||||
#include "util/macros.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -232,6 +235,11 @@ struct vk_pipeline_cache_header {
|
|||
#define VK_ENUM_OFFSET(__enum) \
|
||||
((__enum) >= VK_EXT_OFFSET ? ((__enum) % 1000) : (__enum))
|
||||
|
||||
#define typed_memcpy(dest, src, count) do { \
|
||||
STATIC_ASSERT(sizeof(*(src)) == sizeof(*(dest))); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,11 +27,6 @@
|
|||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
VkResult
|
||||
wsi_display_get_physical_device_display_properties(
|
||||
VkPhysicalDevice physical_device,
|
||||
|
|
|
@ -44,11 +44,6 @@
|
|||
#include <util/timespec.h>
|
||||
#include <util/u_vector.h>
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
struct wsi_wayland;
|
||||
|
||||
struct wsi_wl_display_drm {
|
||||
|
|
|
@ -46,11 +46,6 @@
|
|||
#include "wsi_common_x11.h"
|
||||
#include "wsi_common_queue.h"
|
||||
|
||||
#define typed_memcpy(dest, src, count) ({ \
|
||||
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
||||
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
||||
})
|
||||
|
||||
struct wsi_x11_connection {
|
||||
bool has_dri3;
|
||||
bool has_dri3_modifiers;
|
||||
|
|
Loading…
Reference in New Issue