diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig.debug | 13 | ||||
| -rw-r--r-- | lib/Makefile | 2 | ||||
| -rw-r--r-- | lib/btree.c | 3 | ||||
| -rw-r--r-- | lib/cpumask.c | 1 | ||||
| -rw-r--r-- | lib/crc32.c | 1 | ||||
| -rw-r--r-- | lib/debugobjects.c | 1 | ||||
| -rw-r--r-- | lib/decompress_unlzo.c | 22 | ||||
| -rw-r--r-- | lib/devres.c | 1 | ||||
| -rw-r--r-- | lib/dma-debug.c | 2 | ||||
| -rw-r--r-- | lib/dynamic_debug.c | 1 | ||||
| -rw-r--r-- | lib/flex_array.c | 2 | ||||
| -rw-r--r-- | lib/genalloc.c | 1 | ||||
| -rw-r--r-- | lib/inflate.c | 1 | ||||
| -rw-r--r-- | lib/kasprintf.c | 1 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 1 | ||||
| -rw-r--r-- | lib/kref.c | 1 | ||||
| -rw-r--r-- | lib/lcm.c | 15 | ||||
| -rw-r--r-- | lib/radix-tree.c | 13 | ||||
| -rw-r--r-- | lib/ratelimit.c | 11 | ||||
| -rw-r--r-- | lib/rwsem-spinlock.c | 14 | ||||
| -rw-r--r-- | lib/rwsem.c | 5 | ||||
| -rw-r--r-- | lib/scatterlist.c | 1 | ||||
| -rw-r--r-- | lib/swiotlb.c | 1 | ||||
| -rw-r--r-- | lib/textsearch.c | 1 | ||||
| -rw-r--r-- | lib/vsprintf.c | 24 | ||||
| -rw-r--r-- | lib/zlib_inflate/inffast.c | 72 | 
26 files changed, 132 insertions, 79 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index b520ec1f33c..935248bdbc4 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -103,7 +103,8 @@ config HEADERS_CHECK  config DEBUG_SECTION_MISMATCH  	bool "Enable full Section mismatch analysis" -	depends on UNDEFINED +	depends on UNDEFINED || (BLACKFIN) +	default y  	# This option is on purpose disabled for now.  	# It will be enabled when we are down to a reasonable number  	# of section mismatch warnings (< 10 for an allyesconfig build) @@ -355,7 +356,7 @@ config SLUB_STATS  config DEBUG_KMEMLEAK  	bool "Kernel memory leak detector"  	depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \ -		(X86 || ARM || PPC || S390 || SUPERH) +		(X86 || ARM || PPC || S390 || SPARC64 || SUPERH || MICROBLAZE)  	select DEBUG_FS if SYSFS  	select STACKTRACE if STACKTRACE_SUPPORT @@ -532,6 +533,14 @@ config LOCK_STAT  	 For more details, see Documentation/lockstat.txt +	 This also enables lock events required by "perf lock", +	 subcommand of perf. +	 If you want to use "perf lock", you also need to turn on +	 CONFIG_EVENT_TRACING. + +	 CONFIG_LOCK_STAT defines "contended" and "acquired" lock events. +	 (CONFIG_LOCKDEP defines "acquire" and "release" events.) +  config DEBUG_LOCKDEP  	bool "Lock dependency engine debugging"  	depends on DEBUG_KERNEL && LOCKDEP diff --git a/lib/Makefile b/lib/Makefile index 2e152aed719..0d4015205c6 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -21,7 +21,7 @@ lib-y	+= kobject.o kref.o klist.o  obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \  	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ -	 string_helpers.o gcd.o list_sort.o +	 string_helpers.o gcd.o lcm.o list_sort.o  ifeq ($(CONFIG_DEBUG_KOBJECT),y)  CFLAGS_kobject.o += -DDEBUG diff --git a/lib/btree.c b/lib/btree.c index 41859a82021..c9c6f035152 100644 --- a/lib/btree.c +++ b/lib/btree.c @@ -95,7 +95,8 @@ static unsigned long *btree_node_alloc(struct btree_head *head, gfp_t gfp)  	unsigned long *node;  	node = mempool_alloc(head->mempool, gfp); -	memset(node, 0, NODESIZE); +	if (likely(node)) +		memset(node, 0, NODESIZE);  	return node;  } diff --git a/lib/cpumask.c b/lib/cpumask.c index 7bb4142a502..05d6aca7fc1 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -1,3 +1,4 @@ +#include <linux/slab.h>  #include <linux/kernel.h>  #include <linux/bitops.h>  #include <linux/cpumask.h> diff --git a/lib/crc32.c b/lib/crc32.c index 0f45fbff34c..bc5b936e914 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -25,7 +25,6 @@  #include <linux/module.h>  #include <linux/compiler.h>  #include <linux/types.h> -#include <linux/slab.h>  #include <linux/init.h>  #include <asm/atomic.h>  #include "crc32defs.h" diff --git a/lib/debugobjects.c b/lib/debugobjects.c index a9a8996d286..b862b30369f 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -12,6 +12,7 @@  #include <linux/sched.h>  #include <linux/seq_file.h>  #include <linux/debugfs.h> +#include <linux/slab.h>  #include <linux/hash.h>  #define ODEBUG_HASH_BITS	14 diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c index db521f45626..bcb3a4bd68f 100644 --- a/lib/decompress_unlzo.c +++ b/lib/decompress_unlzo.c @@ -97,7 +97,7 @@ STATIC inline int INIT unlzo(u8 *input, int in_len,  	u32 src_len, dst_len;  	size_t tmp;  	u8 *in_buf, *in_buf_save, *out_buf; -	int obytes_processed = 0; +	int ret = -1;  	set_error_fn(error_fn); @@ -174,15 +174,22 @@ STATIC inline int INIT unlzo(u8 *input, int in_len,  		/* decompress */  		tmp = dst_len; -		r = lzo1x_decompress_safe((u8 *) in_buf, src_len, + +		/* When the input data is not compressed at all, +		 * lzo1x_decompress_safe will fail, so call memcpy() +		 * instead */ +		if (unlikely(dst_len == src_len)) +			memcpy(out_buf, in_buf, src_len); +		else { +			r = lzo1x_decompress_safe((u8 *) in_buf, src_len,  						out_buf, &tmp); -		if (r != LZO_E_OK || dst_len != tmp) { -			error("Compressed data violation"); -			goto exit_2; +			if (r != LZO_E_OK || dst_len != tmp) { +				error("Compressed data violation"); +				goto exit_2; +			}  		} -		obytes_processed += dst_len;  		if (flush)  			flush(out_buf, dst_len);  		if (output) @@ -196,6 +203,7 @@ STATIC inline int INIT unlzo(u8 *input, int in_len,  			in_buf += src_len;  	} +	ret = 0;  exit_2:  	if (!input)  		free(in_buf); @@ -203,7 +211,7 @@ exit_1:  	if (!output)  		free(out_buf);  exit: -	return obytes_processed; +	return ret;  }  #define decompress unlzo diff --git a/lib/devres.c b/lib/devres.c index 72c8909006d..49368608f98 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -1,5 +1,6 @@  #include <linux/pci.h>  #include <linux/io.h> +#include <linux/gfp.h>  #include <linux/module.h>  void devm_ioremap_release(struct device *dev, void *res) diff --git a/lib/dma-debug.c b/lib/dma-debug.c index ba8b67039d1..01e64270e24 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c @@ -570,7 +570,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,  	 * Now parse out the first token and use it as the name for the  	 * driver to filter for.  	 */ -	for (i = 0; i < NAME_MAX_LEN; ++i) { +	for (i = 0; i < NAME_MAX_LEN - 1; ++i) {  		current_driver_name[i] = buf[i];  		if (isspace(buf[i]) || buf[i] == ' ' || buf[i] == 0)  			break; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f9350291598..d6b8b9b1abf 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -25,6 +25,7 @@  #include <linux/uaccess.h>  #include <linux/dynamic_debug.h>  #include <linux/debugfs.h> +#include <linux/slab.h>  extern struct _ddebug __start___verbose[];  extern struct _ddebug __stop___verbose[]; diff --git a/lib/flex_array.c b/lib/flex_array.c index 66eef2e4483..41b1804fa72 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c @@ -99,7 +99,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,  	ret->element_size = element_size;  	ret->total_nr_elements = total;  	if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO)) -		memset(ret->parts[0], FLEX_ARRAY_FREE, +		memset(&ret->parts[0], FLEX_ARRAY_FREE,  						FLEX_ARRAY_BASE_BYTES_LEFT);  	return ret;  } diff --git a/lib/genalloc.c b/lib/genalloc.c index e67f97495dd..736c3b06398 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -10,6 +10,7 @@   * Version 2.  See the file COPYING for more details.   */ +#include <linux/slab.h>  #include <linux/module.h>  #include <linux/bitmap.h>  #include <linux/genalloc.h> diff --git a/lib/inflate.c b/lib/inflate.c index d10255973a9..677b738c220 100644 --- a/lib/inflate.c +++ b/lib/inflate.c @@ -103,6 +103,7 @@        the two sets of lengths.   */  #include <linux/compiler.h> +#include <linux/slab.h>  #ifdef RCSID  static char rcsid[] = "#Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp #"; diff --git a/lib/kasprintf.c b/lib/kasprintf.c index c5ff1fd1003..9c4233b2378 100644 --- a/lib/kasprintf.c +++ b/lib/kasprintf.c @@ -6,6 +6,7 @@  #include <stdarg.h>  #include <linux/module.h> +#include <linux/slab.h>  #include <linux/types.h>  #include <linux/string.h> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index c9d3a3e8405..7b48d44ced6 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -18,6 +18,7 @@  #include <linux/string.h>  #include <linux/kobject.h>  #include <linux/module.h> +#include <linux/slab.h>  #include <linux/socket.h>  #include <linux/skbuff.h> diff --git a/lib/kref.c b/lib/kref.c index 9ecd6e86561..6d19f690380 100644 --- a/lib/kref.c +++ b/lib/kref.c @@ -13,6 +13,7 @@  #include <linux/kref.h>  #include <linux/module.h> +#include <linux/slab.h>  /**   * kref_set - initialize object and set refcount to requested number. diff --git a/lib/lcm.c b/lib/lcm.c new file mode 100644 index 00000000000..157cd88a6ff --- /dev/null +++ b/lib/lcm.c @@ -0,0 +1,15 @@ +#include <linux/kernel.h> +#include <linux/gcd.h> +#include <linux/module.h> + +/* Lowest common multiple */ +unsigned long lcm(unsigned long a, unsigned long b) +{ +	if (a && b) +		return (a * b) / gcd(a, b); +	else if (b) +		return b; + +	return a; +} +EXPORT_SYMBOL_GPL(lcm); diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 6b9670d6bbf..2a087e0f986 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -28,7 +28,6 @@  #include <linux/slab.h>  #include <linux/notifier.h>  #include <linux/cpu.h> -#include <linux/gfp.h>  #include <linux/string.h>  #include <linux/bitops.h>  #include <linux/rcupdate.h> @@ -556,6 +555,10 @@ EXPORT_SYMBOL(radix_tree_tag_clear);   *   *  0: tag not present or not set   *  1: tag set + * + * Note that the return value of this function may not be relied on, even if + * the RCU lock is held, unless tag modification and node deletion are excluded + * from concurrency.   */  int radix_tree_tag_get(struct radix_tree_root *root,  			unsigned long index, unsigned int tag) @@ -596,12 +599,8 @@ int radix_tree_tag_get(struct radix_tree_root *root,  		 */  		if (!tag_get(node, tag, offset))  			saw_unset_tag = 1; -		if (height == 1) { -			int ret = tag_get(node, tag, offset); - -			BUG_ON(ret && saw_unset_tag); -			return !!ret; -		} +		if (height == 1) +			return !!tag_get(node, tag, offset);  		node = rcu_dereference_raw(node->slots[offset]);  		shift -= RADIX_TREE_MAP_SHIFT;  		height--; diff --git a/lib/ratelimit.c b/lib/ratelimit.c index 09f5ce1810d..027a03f4c56 100644 --- a/lib/ratelimit.c +++ b/lib/ratelimit.c @@ -16,9 +16,14 @@  /*   * __ratelimit - rate limiting   * @rs: ratelimit_state data + * @func: name of calling function   * - * This enforces a rate limit: not more than @rs->ratelimit_burst callbacks - * in every @rs->ratelimit_jiffies + * This enforces a rate limit: not more than @rs->burst callbacks + * in every @rs->interval + * + * RETURNS: + * 0 means callbacks will be suppressed. + * 1 means go ahead and do it.   */  int ___ratelimit(struct ratelimit_state *rs, const char *func)  { @@ -35,7 +40,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func)  	 * the entity that is holding the lock already:  	 */  	if (!spin_trylock_irqsave(&rs->lock, flags)) -		return 1; +		return 0;  	if (!rs->begin)  		rs->begin = jiffies; diff --git a/lib/rwsem-spinlock.c b/lib/rwsem-spinlock.c index ccf95bff798..ffc9fc7f3b0 100644 --- a/lib/rwsem-spinlock.c +++ b/lib/rwsem-spinlock.c @@ -143,13 +143,14 @@ void __sched __down_read(struct rw_semaphore *sem)  {  	struct rwsem_waiter waiter;  	struct task_struct *tsk; +	unsigned long flags; -	spin_lock_irq(&sem->wait_lock); +	spin_lock_irqsave(&sem->wait_lock, flags);  	if (sem->activity >= 0 && list_empty(&sem->wait_list)) {  		/* granted */  		sem->activity++; -		spin_unlock_irq(&sem->wait_lock); +		spin_unlock_irqrestore(&sem->wait_lock, flags);  		goto out;  	} @@ -164,7 +165,7 @@ void __sched __down_read(struct rw_semaphore *sem)  	list_add_tail(&waiter.list, &sem->wait_list);  	/* we don't need to touch the semaphore struct anymore */ -	spin_unlock_irq(&sem->wait_lock); +	spin_unlock_irqrestore(&sem->wait_lock, flags);  	/* wait to be given the lock */  	for (;;) { @@ -209,13 +210,14 @@ void __sched __down_write_nested(struct rw_semaphore *sem, int subclass)  {  	struct rwsem_waiter waiter;  	struct task_struct *tsk; +	unsigned long flags; -	spin_lock_irq(&sem->wait_lock); +	spin_lock_irqsave(&sem->wait_lock, flags);  	if (sem->activity == 0 && list_empty(&sem->wait_list)) {  		/* granted */  		sem->activity = -1; -		spin_unlock_irq(&sem->wait_lock); +		spin_unlock_irqrestore(&sem->wait_lock, flags);  		goto out;  	} @@ -230,7 +232,7 @@ void __sched __down_write_nested(struct rw_semaphore *sem, int subclass)  	list_add_tail(&waiter.list, &sem->wait_list);  	/* we don't need to touch the semaphore struct anymore */ -	spin_unlock_irq(&sem->wait_lock); +	spin_unlock_irqrestore(&sem->wait_lock, flags);  	/* wait to be given the lock */  	for (;;) { diff --git a/lib/rwsem.c b/lib/rwsem.c index 3e3365e5665..ceba8e28807 100644 --- a/lib/rwsem.c +++ b/lib/rwsem.c @@ -136,9 +136,10 @@ __rwsem_do_wake(struct rw_semaphore *sem, int downgrading)   out:  	return sem; -	/* undo the change to count, but check for a transition 1->0 */ +	/* undo the change to the active count, but check for a transition +	 * 1->0 */   undo: -	if (rwsem_atomic_update(-RWSEM_ACTIVE_BIAS, sem) != 0) +	if (rwsem_atomic_update(-RWSEM_ACTIVE_BIAS, sem) & RWSEM_ACTIVE_MASK)  		goto out;  	goto try_again;  } diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 0d475d8167b..9afa25b52a8 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -7,6 +7,7 @@   * Version 2. See the file COPYING for more details.   */  #include <linux/module.h> +#include <linux/slab.h>  #include <linux/scatterlist.h>  #include <linux/highmem.h> diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 437eedb5a53..5fddf720da7 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -28,6 +28,7 @@  #include <linux/types.h>  #include <linux/ctype.h>  #include <linux/highmem.h> +#include <linux/gfp.h>  #include <asm/io.h>  #include <asm/dma.h> diff --git a/lib/textsearch.c b/lib/textsearch.c index 9fbcb44c554..d608331b3e4 100644 --- a/lib/textsearch.c +++ b/lib/textsearch.c @@ -103,6 +103,7 @@  #include <linux/rcupdate.h>  #include <linux/err.h>  #include <linux/textsearch.h> +#include <linux/slab.h>  static LIST_HEAD(ts_ops);  static DEFINE_SPINLOCK(ts_mod_lock); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 0d461c7c14d..46d34b0b74a 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -118,6 +118,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)  	return simple_strtoull(cp, endp, base);  } +EXPORT_SYMBOL(simple_strtoll);  /**   * strict_strtoul - convert a string to an unsigned long strictly @@ -408,12 +409,12 @@ enum format_type {  };  struct printf_spec { -	u16	type; -	s16	field_width;	/* width of output field */ +	u8	type;		/* format_type enum */  	u8	flags;		/* flags to number() */ -	u8	base; -	s8	precision;	/* # of digits/chars */ -	u8	qualifier; +	u8	base;		/* number base, 8, 10 or 16 only */ +	u8	qualifier;	/* number qualifier, one of 'hHlLtzZ' */ +	s16	field_width;	/* width of output field */ +	s16	precision;	/* # of digits/chars */  };  static char *number(char *buf, char *end, unsigned long long num, @@ -609,6 +610,12 @@ static char *resource_string(char *buf, char *end, struct resource *res,  		.precision = -1,  		.flags = SPECIAL | SMALL | ZEROPAD,  	}; +	static const struct printf_spec bus_spec = { +		.base = 16, +		.field_width = 2, +		.precision = -1, +		.flags = SMALL | ZEROPAD, +	};  	static const struct printf_spec dec_spec = {  		.base = 10,  		.precision = -1, @@ -629,7 +636,7 @@ static char *resource_string(char *buf, char *end, struct resource *res,  	 * 64-bit res (sizeof==8): 20 chars in dec, 18 in hex ("0x" + 16) */  #define RSRC_BUF_SIZE		((2 * sizeof(resource_size_t)) + 4)  #define FLAG_BUF_SIZE		(2 * sizeof(res->flags)) -#define DECODED_BUF_SIZE	sizeof("[mem - 64bit pref disabled]") +#define DECODED_BUF_SIZE	sizeof("[mem - 64bit pref window disabled]")  #define RAW_BUF_SIZE		sizeof("[mem - flags 0x]")  	char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE,  		     2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; @@ -651,6 +658,9 @@ static char *resource_string(char *buf, char *end, struct resource *res,  	} else if (res->flags & IORESOURCE_DMA) {  		p = string(p, pend, "dma ", str_spec);  		specp = &dec_spec; +	} else if (res->flags & IORESOURCE_BUS) { +		p = string(p, pend, "bus ", str_spec); +		specp = &bus_spec;  	} else {  		p = string(p, pend, "??? ", str_spec);  		specp = &mem_spec; @@ -666,6 +676,8 @@ static char *resource_string(char *buf, char *end, struct resource *res,  			p = string(p, pend, " 64bit", str_spec);  		if (res->flags & IORESOURCE_PREFETCH)  			p = string(p, pend, " pref", str_spec); +		if (res->flags & IORESOURCE_WINDOW) +			p = string(p, pend, " window", str_spec);  		if (res->flags & IORESOURCE_DISABLED)  			p = string(p, pend, " disabled", str_spec);  	} else { diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c index 215447c5526..2c13ecc5bb2 100644 --- a/lib/zlib_inflate/inffast.c +++ b/lib/zlib_inflate/inffast.c @@ -8,21 +8,6 @@  #include "inflate.h"  #include "inffast.h" -/* Only do the unaligned "Faster" variant when - * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set - * - * On powerpc, it won't be as we don't include autoconf.h - * automatically for the boot wrapper, which is intended as - * we run in an environment where we may not be able to deal - * with (even rare) alignment faults. In addition, we do not - * define __KERNEL__ for arch/powerpc/boot unlike x86 - */ - -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS -#include <asm/unaligned.h> -#include <asm/byteorder.h> -#endif -  #ifndef ASMINF  /* Allow machine dependent optimization for post-increment or pre-increment. @@ -36,14 +21,31 @@     - Pentium III (Anderson)     - M68060 (Nikl)   */ +union uu { +	unsigned short us; +	unsigned char b[2]; +}; + +/* Endian independed version */ +static inline unsigned short +get_unaligned16(const unsigned short *p) +{ +	union uu  mm; +	unsigned char *b = (unsigned char *)p; + +	mm.b[0] = b[0]; +	mm.b[1] = b[1]; +	return mm.us; +} +  #ifdef POSTINC  #  define OFF 0  #  define PUP(a) *(a)++ -#  define UP_UNALIGNED(a) get_unaligned((a)++) +#  define UP_UNALIGNED(a) get_unaligned16((a)++)  #else  #  define OFF 1  #  define PUP(a) *++(a) -#  define UP_UNALIGNED(a) get_unaligned(++(a)) +#  define UP_UNALIGNED(a) get_unaligned16(++(a))  #endif  /* @@ -256,7 +258,6 @@ void inflate_fast(z_streamp strm, unsigned start)                      }                  }                  else { -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS  		    unsigned short *sout;  		    unsigned long loops; @@ -274,22 +275,25 @@ void inflate_fast(z_streamp strm, unsigned start)  			sfrom = (unsigned short *)(from - OFF);  			loops = len >> 1;  			do +#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +			    PUP(sout) = PUP(sfrom); +#else  			    PUP(sout) = UP_UNALIGNED(sfrom); +#endif  			while (--loops);  			out = (unsigned char *)sout + OFF;  			from = (unsigned char *)sfrom + OFF;  		    } else { /* dist == 1 or dist == 2 */  			unsigned short pat16; -			pat16 = *(sout-2+2*OFF); -			if (dist == 1) -#if defined(__BIG_ENDIAN) -			    pat16 = (pat16 & 0xff) | ((pat16 & 0xff) << 8); -#elif defined(__LITTLE_ENDIAN) -			    pat16 = (pat16 & 0xff00) | ((pat16 & 0xff00) >> 8); -#else -#error __BIG_ENDIAN nor __LITTLE_ENDIAN is defined -#endif +			pat16 = *(sout-1+OFF); +			if (dist == 1) { +				union uu mm; +				/* copy one char pattern to both bytes */ +				mm.us = pat16; +				mm.b[0] = mm.b[1]; +				pat16 = mm.us; +			}  			loops = len >> 1;  			do  			    PUP(sout) = pat16; @@ -298,20 +302,6 @@ void inflate_fast(z_streamp strm, unsigned start)  		    }  		    if (len & 1)  			PUP(out) = PUP(from); -#else /* CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */ -                    from = out - dist;          /* copy direct from output */ -                    do {                        /* minimum length is three */ -			 PUP(out) = PUP(from); -			 PUP(out) = PUP(from); -			 PUP(out) = PUP(from); -			 len -= 3; -                    } while (len > 2); -                    if (len) { -			 PUP(out) = PUP(from); -			 if (len > 1) -			     PUP(out) = PUP(from); -                    } -#endif /* !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS */                  }              }              else if ((op & 64) == 0) {          /* 2nd level distance code */  |