mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
util: Add util_memcpy_cpu_to_le32() v3
v2: - Preserve word boundaries. v3: - Use const and restrict. - Fix indentation. Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
parent
3d636b4785
commit
f0e0737922
1 changed files with 17 additions and 0 deletions
|
|
@ -812,6 +812,23 @@ util_bswap16(uint16_t n)
|
|||
(n << 8);
|
||||
}
|
||||
|
||||
static INLINE void*
|
||||
util_memcpy_cpu_to_le32(void * restrict dest, const void * restrict src, size_t n)
|
||||
{
|
||||
#ifdef PIPE_ARCH_BIG_ENDIAN
|
||||
size_t i, e;
|
||||
asset(n % 4 == 0);
|
||||
|
||||
for (i = 0, e = n / 4; i < e; i++) {
|
||||
uint32_t * restrict d = (uint32_t* restrict)dest;
|
||||
const uint32_t * restrict s = (const uint32_t* restrict)src;
|
||||
d[i] = util_bswap32(s[i]);
|
||||
}
|
||||
return dest;
|
||||
#else
|
||||
return memcpy(dest, src, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp X to [MIN, MAX].
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue