diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zlib_inflate/inffast.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c index 05e1559fa156..215447c55261 100644 --- a/lib/zlib_inflate/inffast.c +++ b/lib/zlib_inflate/inffast.c | |||
@@ -4,12 +4,25 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/zutil.h> | 6 | #include <linux/zutil.h> |
7 | #include <asm/unaligned.h> | ||
8 | #include <asm/byteorder.h> | ||
9 | #include "inftrees.h" | 7 | #include "inftrees.h" |
10 | #include "inflate.h" | 8 | #include "inflate.h" |
11 | #include "inffast.h" | 9 | #include "inffast.h" |
12 | 10 | ||
11 | /* Only do the unaligned "Faster" variant when | ||
12 | * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set | ||
13 | * | ||
14 | * On powerpc, it won't be as we don't include autoconf.h | ||
15 | * automatically for the boot wrapper, which is intended as | ||
16 | * we run in an environment where we may not be able to deal | ||
17 | * with (even rare) alignment faults. In addition, we do not | ||
18 | * define __KERNEL__ for arch/powerpc/boot unlike x86 | ||
19 | */ | ||
20 | |||
21 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | ||
22 | #include <asm/unaligned.h> | ||
23 | #include <asm/byteorder.h> | ||
24 | #endif | ||
25 | |||
13 | #ifndef ASMINF | 26 | #ifndef ASMINF |
14 | 27 | ||
15 | /* Allow machine dependent optimization for post-increment or pre-increment. | 28 | /* Allow machine dependent optimization for post-increment or pre-increment. |
@@ -243,6 +256,7 @@ void inflate_fast(z_streamp strm, unsigned start) | |||
243 | } | 256 | } |
244 | } | 257 | } |
245 | else { | 258 | else { |
259 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | ||
246 | unsigned short *sout; | 260 | unsigned short *sout; |
247 | unsigned long loops; | 261 | unsigned long loops; |
248 | 262 | ||
@@ -284,6 +298,20 @@ void inflate_fast(z_streamp strm, unsigned start) | |||
284 | } | 298 | } |
285 | if (len & 1) | 299 | if (len & 1) |
286 | PUP(out) = PUP(from); | 300 | PUP(out) = PUP(from); |
301 | #else /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */ | ||
302 | from = out - dist; /* copy direct from output */ | ||
303 | do { /* minimum length is three */ | ||
304 | PUP(out) = PUP(from); | ||
305 | PUP(out) = PUP(from); | ||
306 | PUP(out) = PUP(from); | ||
307 | len -= 3; | ||
308 | } while (len > 2); | ||
309 | if (len) { | ||
310 | PUP(out) = PUP(from); | ||
311 | if (len > 1) | ||
312 | PUP(out) = PUP(from); | ||
313 | } | ||
314 | #endif /* !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */ | ||
287 | } | 315 | } |
288 | } | 316 | } |
289 | else if ((op & 64) == 0) { /* 2nd level distance code */ | 317 | else if ((op & 64) == 0) { /* 2nd level distance code */ |