summaryrefslogtreecommitdiffstats
path: root/module/icp
diff options
context:
space:
mode:
authorKireinaHoro <[email protected]>2017-10-11 13:16:46 +0800
committerKireinaHoro <[email protected]>2017-10-12 01:36:16 +0800
commita7ec8c47e21c76624149beb1c9490c0e1bedf2a8 (patch)
treed889dcd8fcb739070f0b7d9afbdf07a57469f499 /module/icp
parent46d4fe880e15848b272593ae68333577206d9c5b (diff)
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 <[email protected]>
Diffstat (limited to 'module/icp')
-rw-r--r--module/icp/algs/sha1/sha1.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/module/icp/algs/sha1/sha1.c b/module/icp/algs/sha1/sha1.c
index 5a4a7da92..7f28b3796 100644
--- a/module/icp/algs/sha1/sha1.c
+++ b/module/icp/algs/sha1/sha1.c
@@ -817,10 +817,22 @@ Encode(uint8_t *_RESTRICT_KYWD output, const uint32_t *_RESTRICT_KYWD input,
{
size_t i, j;
- 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)
+ if (IS_P2ALIGNED(output, sizeof (uint32_t))) {
+ for (i = 0, j = 0; j < len; i++, j += 4) {
+ /* LINTED E_BAD_PTR_CAST_ALIGN */
+ *((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
}