From 941a1059541197dfb356b45f1e003745533c4b0e Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 7 Oct 2015 09:27:31 -0700 Subject: [PATCH] anv/private: Add a typed_memcpy macro This is amazingly helpful when copying arrays of things around. --- src/vulkan/anv_private.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index e9735706a67..ac9422f6b90 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -115,6 +115,11 @@ anv_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))); \ +}) + /* Define no kernel as 1, since that's an illegal offset for a kernel */ #define NO_KERNEL 1 -- 2.30.2