From: Jason Ekstrand Date: Wed, 7 Oct 2015 16:27:31 +0000 (-0700) Subject: anv/private: Add a typed_memcpy macro X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=941a1059541197dfb356b45f1e003745533c4b0e;p=mesa.git anv/private: Add a typed_memcpy macro This is amazingly helpful when copying arrays of things around. --- 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