SPARC optimizations for Encode()
Normally a SPARC processor runs in big endian mode. Save the extra labor needed for little endian machines when the target is a big endian one (sparc). Signed-off-by: Pengcheng Xu <i@jsteward.moe>
This commit is contained in:
parent
46d4fe880e
commit
a7ec8c47e2
|
@ -817,10 +817,22 @@ Encode(uint8_t *_RESTRICT_KYWD output, const uint32_t *_RESTRICT_KYWD input,
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
#if defined(__sparc)
|
||||||
output[j] = (input[i] >> 24) & 0xff;
|
if (IS_P2ALIGNED(output, sizeof (uint32_t))) {
|
||||||
output[j + 1] = (input[i] >> 16) & 0xff;
|
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||||
output[j + 2] = (input[i] >> 8) & 0xff;
|
/* LINTED E_BAD_PTR_CAST_ALIGN */
|
||||||
output[j + 3] = input[i] & 0xff;
|
*((uint32_t *)(output + j)) = input[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#endif /* little endian -- will work on big endian, but slowly */
|
||||||
|
|
||||||
|
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||||
|
output[j] = (input[i] >> 24) & 0xff;
|
||||||
|
output[j + 1] = (input[i] >> 16) & 0xff;
|
||||||
|
output[j + 2] = (input[i] >> 8) & 0xff;
|
||||||
|
output[j + 3] = input[i] & 0xff;
|
||||||
|
}
|
||||||
|
#if defined(__sparc)
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue