summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-10-07 09:27:31 -0700
committerJason Ekstrand <[email protected]>2015-10-07 09:36:27 -0700
commit941a1059541197dfb356b45f1e003745533c4b0e (patch)
tree71cd557bf5362a26a30e26c311790fb5ba75ead4
parentb1c024a9321cba865d152eb5f64ac74cff47125e (diff)
anv/private: Add a typed_memcpy macro
This is amazingly helpful when copying arrays of things around.
-rw-r--r--src/vulkan/anv_private.h5
1 files changed, 5 insertions, 0 deletions
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