OK, I have made the modifications as per your suggestions. Should I proceed with
resubmitting the patch? And how should I acknowledge your contribution? I'm not quite
clear on that for the first submission. Thank you for your guidance.
Thanks,
Yulong
diff --git a/lzorle_decompress.c b/lzorle_decompress.c
index bd7ee3f..5e83430 100644
--- a/lzorle_decompress.c
+++ b/lzorle_decompress.c
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <string.h>
+#include "defs.h"
+
/* This MAX_255_COUNT is the maximum number of times we can add 255 to a base
* count without overflowing an integer. The multiply will overflow when
* multiplying 255 by more than MAXINT/255. The sum will overflow earlier
@@ -91,7 +93,28 @@ int lzorle_decompress_safe(const unsigned char *in, unsigned long
in_len,
}
t += 3;
copy_literal_run:
- {
+ if (get_kernel_config("CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS", NULL) ==
IKCONFIG_Y) {
+ if (HAVE_IP(t + 15) && HAVE_OP(t + 15)) {
+ const unsigned char *ie = ip + t;
+ unsigned char *oe = op + t;
+ do {
+ COPY8(op, ip);
+ op += 8;
+ ip += 8;
+ COPY8(op, ip);
+ op += 8;
+ ip += 8;
+ } while (ip < ie);
+ ip = ie;
+ op = oe;
+ } else {
+ NEED_OP(t);
+ NEED_IP(t + 3);
+ do {
+ *op++ = *ip++;
+ } while (--t > 0);
+ }
+ } else {
NEED_OP(t);
NEED_IP(t + 3);
do {
@@ -194,7 +217,45 @@ copy_literal_run:
}
}
TEST_LB(m_pos);
- {
+
+ if (get_kernel_config("CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS", NULL) ==
IKCONFIG_Y) {
+ if (op - m_pos >= 8) {
+ unsigned char *oe = op + t;
+ if (HAVE_OP(t + 15)) {
+ do {
+ COPY8(op, m_pos);
+ op += 8;
+ m_pos += 8;
+ COPY8(op, m_pos);
+ op += 8;
+ m_pos += 8;
+ } while (op < oe);
+ op = oe;
+ if (HAVE_IP(6)) {
+ state = next;
+ COPY4(op, ip);
+ op += next;
+ ip += next;
+ continue;
+ }
+ } else {
+ NEED_OP(t);
+ do {
+ *op++ = *m_pos++;
+ } while (op < oe);
+ }
+ } else {
+ unsigned char *oe = op + t;
+ NEED_OP(t);
+ op[0] = m_pos[0];
+ op[1] = m_pos[1];
+ op += 2;
+ m_pos += 2;
+ do {
+ *op++ = *m_pos++;
+ } while (op < oe);
+ }
+ } else {
unsigned char *oe = op + t;
NEED_OP(t);
op[0] = m_pos[0];
@@ -208,7 +269,20 @@ copy_literal_run:
match_next:
state = next;
t = next;
- {
+ if (get_kernel_config("CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS", NULL) ==
IKCONFIG_Y) {
+ if (HAVE_IP(6) && HAVE_OP(4)) {
+ COPY4(op, ip);
+ op += t;
+ ip += t;
+ } else {
+ NEED_IP(t + 3);
+ NEED_OP(t);
+ while (t > 0) {
+ *op++ = *ip++;
+ t--;
+ }
+ }
+ } else {
NEED_IP(t + 3);
NEED_OP(t);
while (t > 0) {