anv/private: Add a typed_memcpy macro

This is amazingly helpful when copying arrays of things around.
This commit is contained in:
Jason Ekstrand 2015-10-07 09:27:31 -07:00
parent b1c024a932
commit 941a105954
1 changed files with 5 additions and 0 deletions

View File

@ -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