[hbbtv/youtubetv] Fixed hanup bug and segmentation fault on 3rd-party images.
[vuplus_openembedded] / recipes / linux / linux-dm7025 / linuxmips-2.6.12-gcc44-compile-fixes.patch
1 --- linux-2.6.12.6.org/arch/mips/Makefile       2010-08-03 13:53:13.786025121 +0200
2 +++ linux-2.6.12.6/arch/mips/Makefile   2010-08-03 13:46:01.066025294 +0200
3 @@ -22,7 +22,7 @@
4  # Select the object file format to substitute into the linker script.
5  #
6  ifdef CONFIG_CPU_LITTLE_ENDIAN
7 -32bit-tool-prefix      = mipsel-linux-
8 +32bit-tool-prefix      = mipsel-oe-linux-
9  64bit-tool-prefix      = mips64el-linux-
10  32bit-bfd              = elf32-tradlittlemips
11  64bit-bfd              = elf64-tradlittlemips
12 --- linux-2.6.12.6.org/arch/mips/kernel/time.c  2005-08-29 18:55:27.000000000 +0200
13 +++ linux-2.6.12.6/arch/mips/kernel/time.c      2010-08-03 13:42:31.590021528 +0200
14 @@ -268,10 +268,14 @@
15         /* .. relative to previous jiffy (32 bits is enough) */
16         count -= timerlo;
17  
18 +#ifndef GCC_NO_H_CONSTRAINT
19         __asm__("multu  %1,%2"
20                 : "=h" (res)
21                 : "r" (count), "r" (sll32_usecs_per_cycle)
22                 : "lo", GCC_REG_ACCUM);
23 +#else
24 +       res = ((uintx_t)count * sll32_usecs_per_cycle) >> BITS_PER_LONG;
25 +#endif
26  
27         /*
28          * Due to possible jiffies inconsistencies, we need to check
29 @@ -323,10 +327,14 @@
30         /* .. relative to previous jiffy (32 bits is enough) */
31         count -= timerlo;
32  
33 +#ifndef GCC_NO_H_CONSTRAINT
34         __asm__("multu  %1,%2"
35                 : "=h" (res)
36                 : "r" (count), "r" (quotient)
37                 : "lo", GCC_REG_ACCUM);
38 +#else
39 +       res = ((uintx_t)count * quotient) >> BITS_PER_LONG;
40 +#endif
41  
42         /*
43          * Due to possible jiffies inconsistencies, we need to check
44 @@ -379,10 +387,14 @@
45         /* .. relative to previous jiffy (32 bits is enough) */
46         count -= timerlo;
47  
48 +#ifndef GCC_NO_H_CONSTRAINT
49         __asm__("multu  %1,%2"
50                 : "=h" (res)
51                 : "r" (count), "r" (quotient)
52                 : "lo", GCC_REG_ACCUM);
53 +#else
54 +       res = ((uintx_t)count * quotient) >> BITS_PER_LONG;
55 +#endif
56  
57         /*
58          * Due to possible jiffies inconsistencies, we need to check
59 --- linux-2.6.12.6.org/arch/mips/lib/Makefile   2010-08-03 13:53:14.270022698 +0200
60 +++ linux-2.6.12.6/arch/mips/lib/Makefile       2010-08-03 13:48:44.066022062 +0200
61 @@ -7,6 +7,6 @@
62  
63  obj-y  += iomap.o
64  
65 -obj-y += ucmpdi2.o
66 +obj-y += ucmpdi2.o ashrdi3.o ashldi3.o lshrdi3.o
67  
68  EXTRA_AFLAGS := $(CFLAGS)
69 --- linux-2.6.12.6.org/arch/mips/lib/ashldi3.c  1970-01-01 01:00:00.000000000 +0100
70 +++ linux-2.6.12.6/arch/mips/lib/ashldi3.c      2006-09-20 05:42:06.000000000 +0200
71 @@ -0,0 +1,29 @@
72 +#include <linux/module.h>
73 +
74 +#include "libgcc.h"
75 +
76 +long long __ashldi3(long long u, word_type b)
77 +{
78 +       DWunion uu, w;
79 +       word_type bm;
80 +
81 +       if (b == 0)
82 +               return u;
83 +
84 +       uu.ll = u;
85 +       bm = 32 - b;
86 +
87 +       if (bm <= 0) {
88 +               w.s.low = 0;
89 +               w.s.high = (unsigned int) uu.s.low << -bm;
90 +       } else {
91 +               const unsigned int carries = (unsigned int) uu.s.low >> bm;
92 +
93 +               w.s.low = (unsigned int) uu.s.low << b;
94 +               w.s.high = ((unsigned int) uu.s.high << b) | carries;
95 +       }
96 +
97 +       return w.ll;
98 +}
99 +
100 +EXPORT_SYMBOL(__ashldi3);
101 --- linux-2.6.12.6.org/arch/mips/lib/ashrdi3.c  1970-01-01 01:00:00.000000000 +0100
102 +++ linux-2.6.12.6/arch/mips/lib/ashrdi3.c      2006-09-20 05:42:06.000000000 +0200
103 @@ -0,0 +1,31 @@
104 +#include <linux/module.h>
105 +
106 +#include "libgcc.h"
107 +
108 +long long __ashrdi3(long long u, word_type b)
109 +{
110 +       DWunion uu, w;
111 +       word_type bm;
112 +
113 +       if (b == 0)
114 +               return u;
115 +
116 +       uu.ll = u;
117 +       bm = 32 - b;
118 +
119 +       if (bm <= 0) {
120 +               /* w.s.high = 1..1 or 0..0 */
121 +               w.s.high =
122 +                   uu.s.high >> 31;
123 +               w.s.low = uu.s.high >> -bm;
124 +       } else {
125 +               const unsigned int carries = (unsigned int) uu.s.high << bm;
126 +
127 +               w.s.high = uu.s.high >> b;
128 +               w.s.low = ((unsigned int) uu.s.low >> b) | carries;
129 +       }
130 +
131 +       return w.ll;
132 +}
133 +
134 +EXPORT_SYMBOL(__ashrdi3);
135 --- linux-2.6.12.6-org/arch/mips/lib/lshrdi3.c  1970-01-01 01:00:00.000000000 +0100
136 +++ linux-2.6.12.6/arch/mips/lib/lshrdi3.c      2006-09-20 05:42:06.000000000 +0200
137 @@ -0,0 +1,29 @@
138 +#include <linux/module.h>
139 +
140 +#include "libgcc.h"
141 +
142 +long long __lshrdi3(long long u, word_type b)
143 +{
144 +       DWunion uu, w;
145 +       word_type bm;
146 +
147 +       if (b == 0)
148 +               return u;
149 +
150 +       uu.ll = u;
151 +       bm = 32 - b;
152 +
153 +       if (bm <= 0) {
154 +               w.s.high = 0;
155 +               w.s.low = (unsigned int) uu.s.high >> -bm;
156 +       } else {
157 +               const unsigned int carries = (unsigned int) uu.s.high << bm;
158 +
159 +               w.s.high = (unsigned int) uu.s.high >> b;
160 +               w.s.low = ((unsigned int) uu.s.low >> b) | carries;
161 +       }
162 +
163 +       return w.ll;
164 +}
165 +
166 +EXPORT_SYMBOL(__lshrdi3);
167 --- linux-2.6.12.6.org/fs/squashfs/.tmp_versions/squashfs.mod   1970-01-01 01:00:00.000000000 +0100
168 +++ linux-2.6.12.6/fs/squashfs/.tmp_versions/squashfs.mod       2010-08-03 13:49:46.214025683 +0200
169 @@ -0,0 +1,2 @@
170 +/home/ghost/misc/dreambox/bitbake_7025_new/dm7025/build/tmp/work/dm7025-oe-linux/linux-dm7025-2.6.12.6-s7/linux-2.6.12.6/fs/squashfs/squashfs.ko
171 +/home/ghost/misc/dreambox/bitbake_7025_new/dm7025/build/tmp/work/dm7025-oe-linux/linux-dm7025-2.6.12.6-s7/linux-2.6.12.6/fs/squashfs/inode.o /home/ghost/misc/dreambox/bitbake_7025_new/dm7025/build/tmp/work/dm7025-oe-linux/linux-dm7025-2.6.12.6-s7/linux-2.6.12.6/fs/squashfs/squashfs2_0.o
172 --- linux-2.6.12.6.org/include/asm-mips/compiler.h      2005-08-29 18:55:27.000000000 +0200
173 +++ linux-2.6.12.6/include/asm-mips/compiler.h  2010-08-03 13:44:08.106021617 +0200
174 @@ -8,10 +8,21 @@
175  #ifndef _ASM_COMPILER_H
176  #define _ASM_COMPILER_H
177  
178 +#include <asm/types.h>
179 +
180  #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
181  #define GCC_REG_ACCUM "$0"
182  #else
183  #define GCC_REG_ACCUM "accum"
184  #endif
185  
186 +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
187 +#define GCC_NO_H_CONSTRAINT
188 +#ifdef CONFIG_64BIT
189 +typedef unsigned int uintx_t __attribute__((mode(TI)));
190 +#else
191 +typedef u64 uintx_t;
192 +#endif
193 +#endif
194 +
195  #endif /* _ASM_COMPILER_H */
196 --- linux-2.6.12.6.org/include/asm-mips/delay.h 2005-08-29 18:55:27.000000000 +0200
197 +++ linux-2.6.12.6/include/asm-mips/delay.h     2010-08-03 13:44:17.914022072 +0200
198 @@ -37,6 +37,37 @@
199                 :"0" (loops));
200  }
201  
202 +/*
203 + * convert usecs to loops
204 + *
205 + * handle removal of 'h' constraint in GCC 4.4
206 + */
207 +
208 +#ifndef GCC_NO_H_CONSTRAINT    /* gcc <= 4.3 */
209 +static inline unsigned long __usecs_to_loops(unsigned long usecs, unsigned long lpj)
210 +{
211 +       unsigned long lo;
212 +
213 +       if (sizeof(long) == 4)
214 +               __asm__("multu\t%2, %3"
215 +               : "=h" (usecs), "=l" (lo)
216 +               : "r" (usecs), "r" (lpj)
217 +               : GCC_REG_ACCUM);
218 +       else if (sizeof(long) == 8)
219 +               __asm__("dmultu\t%2, %3"
220 +               : "=h" (usecs), "=l" (lo)
221 +               : "r" (usecs), "r" (lpj)
222 +               : GCC_REG_ACCUM);
223 +
224 +       return usecs;
225 +}
226 +#else  /* GCC_NO_H_CONSTRAINT, gcc >= 4.4 */
227 +static inline unsigned long __usecs_to_loops(unsigned long usecs,
228 +               unsigned long lpj)
229 +{
230 +       return ((uintx_t)usecs * lpj) >> BITS_PER_LONG;
231 +}
232 +#endif
233  
234  /*
235   * Division by multiplication: you don't have to worry about
236 @@ -51,8 +82,6 @@
237  
238  static inline void __udelay(unsigned long usecs, unsigned long lpj)
239  {
240 -       unsigned long lo;
241 -
242         /*
243          * The common rates of 1000 and 128 are rounded wrongly by the
244          * catchall case for 64-bit.  Excessive precission?  Probably ...
245 @@ -67,19 +96,7 @@
246         usecs *= (unsigned long) (((0x8000000000000000ULL / (500000 / HZ)) +
247                                    0x80000000ULL) >> 32);
248  #endif
249 -
250 -       if (sizeof(long) == 4)
251 -               __asm__("multu\t%2, %3"
252 -               : "=h" (usecs), "=l" (lo)
253 -               : "r" (usecs), "r" (lpj)
254 -               : GCC_REG_ACCUM);
255 -       else if (sizeof(long) == 8)
256 -               __asm__("dmultu\t%2, %3"
257 -               : "=h" (usecs), "=l" (lo)
258 -               : "r" (usecs), "r" (lpj)
259 -               : GCC_REG_ACCUM);
260 -
261 -       __delay(usecs);
262 +       __delay(__usecs_to_loops(usecs, lpj));
263  }
264  
265  #ifdef CONFIG_SMP
266 --- linux-2.6.12.6.org/include/asm-mips/div64.h 2005-08-29 18:55:27.000000000 +0200
267 +++ linux-2.6.12.6/include/asm-mips/div64.h     2010-08-03 13:44:26.090021496 +0200
268 @@ -53,6 +53,23 @@
269         (res) = __quot; \
270         __mod; })
271  
272 +/*
273 + * __do_divu -- unsigned interger dividing
274 + *
275 + * handle removal of 'h' constraint in GCC 4.4
276 + */
277 +#ifndef GCC_NO_H_CONSTRAINT /* gcc <= 4.3*/
278 +#define __do_divu() ({ \
279 + __asm__("divu $0, %z2, %z3" \
280 + : "=h" (__upper), "=l" (__high) \
281 + : "Jr" (__high), "Jr" (__base) \
282 + : GCC_REG_ACCUM); })
283 +#else /* gcc >= 4.4 */
284 +#define __do_divu() ({ \
285 + __upper = (uintx_t)__high % __base; \
286 + __high = (uintx_t)__high / __base; })
287 +#endif
288 +
289  #define do_div(n, base) ({ \
290         unsigned long long __quot; \
291         unsigned long __mod; \
292 @@ -67,10 +84,7 @@
293         __upper = __high; \
294         \
295         if (__high) \
296 -               __asm__("divu   $0, %z2, %z3" \
297 -                       : "=h" (__upper), "=l" (__high) \
298 -                       : "Jr" (__high), "Jr" (__base) \
299 -                       : GCC_REG_ACCUM); \
300 +               __do_divu(); \
301         \
302         __mod = do_div64_32(__low, __upper, __low, __base); \
303         \