kernel: refresh 3.12 patches on -rc7 release
[openwrt.git] / target / linux / generic / patches-3.12 / 062-mips_decompressor_build_fix.patch
1 From 0db3db45f5bd6df4bdc03bbd5dec672e16164c4e Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <florian@openwrt.org>
3 Date: Mon, 12 Nov 2012 12:31:55 +0100
4 Subject: [PATCH] MIPS: decompressor: fix build failure on memcpy() in
5  decompress.c
6
7 The decompress.c file includes linux/kernel.h which causes the following
8 inclusion chain to be pulled:
9 linux/kernel.h ->
10         linux/dynamic_debug.h ->
11                 linux/string.h ->
12                         asm/string.h
13
14 We end up having a the GCC builtin + architecture specific memcpy() expanding
15 into this:
16
17 void *({ size_t __len = (size_t n); void *__ret; if
18 (__builtin_constant_p(size_t n) && __len >= 64) __ret = memcpy((void *dest),
19 (const void *src), __len); else __ret = __builtin_memcpy((void *dest), (const
20 void *src), __len); __ret; })
21 {
22  [memcpy implementation in decompress.c starts here]
23  int i;
24  const char *s = src;
25  char *d = dest;
26
27  for (i = 0; i < n; i++)
28   d[i] = s[i];
29  return dest;
30 }
31
32 raising the following compilation error:
33 arch/mips/boot/compressed/decompress.c:46:8: error: expected identifier or '('
34 before '{' token
35
36 There are at least three possibilities to fix this issue:
37
38 1) define _LINUX_STRING_H_ at the beginning of decompress.c to prevent
39    further linux/string.h definitions and declarations from being used, and add
40    an explicit strstr() declaration for linux/dynamic_debug.h
41
42 2) remove the inclusion of linux/kernel.h because we actually use no definition
43    or declaration from this header file
44
45 3) undefine memcpy or re-define memcpy to memcpy thus resulting in picking up
46    the local memcpy() implementation to this compilation unit
47
48 This patch uses the second option which is the less intrusive one.
49
50 Signed-off-by: Florian Fainelli <florian@openwrt.org>
51 ---
52  arch/mips/boot/compressed/decompress.c |    2 --
53  1 file changed, 2 deletions(-)
54
55 --- a/arch/mips/boot/compressed/decompress.c
56 +++ b/arch/mips/boot/compressed/decompress.c
57 @@ -10,9 +10,7 @@
58   * Free Software Foundation;  either version 2 of the  License, or (at your
59   * option) any later version.
60   */
61 -
62  #include <linux/types.h>
63 -#include <linux/kernel.h>
64  
65  #include <asm/addrspace.h>
66