72df58184d5766d67132e7dff9014f95f6de2790
[openwrt.git] / target / linux / generic-2.6 / patches / 005-gcc4_fix.patch
1 diff -ruN linux-2.6.15.1/include/asm-i386/libgcc.h linux-2.6.15.1-openwrt/include/asm-i386/libgcc.h
2 --- linux-2.6.15.1/include/asm-i386/libgcc.h    1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.15.1-openwrt/include/asm-i386/libgcc.h    2006-02-01 15:47:53.000000000 +0100
4 @@ -0,0 +1,8 @@
5 +#ifndef __ASM_LIBGCC_H
6 +#define __ASM_LIBGCC_H
7 +
8 +#undef ARCH_NEEDS_ashldi3
9 +#undef ARCH_NEEDS_ashrdi3
10 +#undef ARCH_NEEDS_lshrdi3
11 +
12 +#endif /* __ASM_LIBGCC_H */
13 diff -Nur linux-2.6.15.1/include/asm-mips/libgcc.h linux-2.6.15.1-openwrt/include/asm-mips/libgcc.h
14 --- linux-2.6.15.1/include/asm-mips/libgcc.h    1970-01-01 01:00:00.000000000 +0100
15 +++ linux-2.6.15.1-openwrt/include/asm-mips/libgcc.h    2006-01-20 10:32:28.000000000 +0100
16 @@ -0,0 +1,8 @@
17 +#ifndef __ASM_LIBGCC_H
18 +#define __ASM_LIBGCC_H
19 +
20 +#define ARCH_NEEDS_ashldi3
21 +#define ARCH_NEEDS_ashrdi3
22 +#define ARCH_NEEDS_lshrdi3
23 +
24 +#endif /* __ASM_LIBGCC_H */
25 diff -Nur linux-2.6.15.1/include/linux/libgcc.h linux-2.6.15.1-openwrt/include/linux/libgcc.h
26 --- linux-2.6.15.1/include/linux/libgcc.h       1970-01-01 01:00:00.000000000 +0100
27 +++ linux-2.6.15.1-openwrt/include/linux/libgcc.h       2006-01-20 10:33:38.000000000 +0100
28 @@ -0,0 +1,32 @@
29 +#ifndef __LINUX_LIBGCC_H
30 +#define __LINUX_LIBGCC_H
31 +
32 +#include <asm/byteorder.h>
33 +#include <asm/libgcc.h>
34 +
35 +typedef long long DWtype;
36 +typedef int Wtype;
37 +typedef unsigned int UWtype;
38 +typedef int word_type __attribute__ ((mode (__word__)));
39 +
40 +#define BITS_PER_UNIT 8
41 +
42 +#ifdef __BIG_ENDIAN
43 +struct DWstruct {
44 +       Wtype high, low;
45 +};
46 +#elif defined(__LITTLE_ENDIAN)
47 +struct DWstruct {
48 +       Wtype low, high;
49 +};
50 +#else
51 +#error I feel sick.
52 +#endif
53 +
54 +typedef union
55 +{
56 +       struct DWstruct s;
57 +       DWtype ll;
58 +} DWunion;
59 +
60 +#endif /* __LINUX_LIBGCC_H */
61 diff -Nur linux-2.6.15.1/lib/ashldi3.c linux-2.6.15.1-openwrt/lib/ashldi3.c
62 --- linux-2.6.15.1/lib/ashldi3.c        1970-01-01 01:00:00.000000000 +0100
63 +++ linux-2.6.15.1-openwrt/lib/ashldi3.c        2006-01-20 10:38:41.000000000 +0100
64 @@ -0,0 +1,32 @@
65 +#include <linux/libgcc.h>
66 +#include <linux/module.h>
67 +
68 +#ifdef ARCH_NEEDS_ashldi3
69 +
70 +DWtype __ashldi3(DWtype u, word_type b)
71 +{
72 +       DWunion uu, w;
73 +       word_type bm;
74 +
75 +       if (b == 0)
76 +               return u;
77 +
78 +       uu.ll = u;
79 +       bm = (sizeof(Wtype) * BITS_PER_UNIT) - b;
80 +
81 +       if (bm <= 0) {
82 +               w.s.low = 0;
83 +               w.s.high = (UWtype) uu.s.low << -bm;
84 +       } else {
85 +               const UWtype carries = (UWtype) uu.s.low >> bm;
86 +
87 +               w.s.low = (UWtype) uu.s.low << b;
88 +               w.s.high = ((UWtype) uu.s.high << b) | carries;
89 +       }
90 +
91 +       return w.ll;
92 +}
93 +
94 +EXPORT_SYMBOL(__ashldi3);
95 +
96 +#endif /* ARCH_NEEDS_ashldi3 */
97 diff -Nur linux-2.6.15.1/lib/ashrdi3.c linux-2.6.15.1-openwrt/lib/ashrdi3.c
98 --- linux-2.6.15.1/lib/ashrdi3.c        1970-01-01 01:00:00.000000000 +0100
99 +++ linux-2.6.15.1-openwrt/lib/ashrdi3.c        2006-01-20 10:39:29.000000000 +0100
100 @@ -0,0 +1,36 @@
101 +#include <linux/libgcc.h>
102 +#include <linux/module.h>
103 +
104 +/* Unless shift functions are defined with full ANSI prototypes,
105 +   parameter b will be promoted to int if word_type is smaller than an int.  */
106 +#ifdef ARCH_NEEDS_ashrdi3
107 +
108 +DWtype __ashrdi3(DWtype 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 = (sizeof(Wtype) * BITS_PER_UNIT) - b;
118 +
119 +       if (bm <= 0) {
120 +               /* w.s.high = 1..1 or 0..0 */
121 +               w.s.high =
122 +                   uu.s.high >> (sizeof(Wtype) * BITS_PER_UNIT - 1);
123 +               w.s.low = uu.s.high >> -bm;
124 +       } else {
125 +               const UWtype carries = (UWtype) uu.s.high << bm;
126 +
127 +               w.s.high = uu.s.high >> b;
128 +               w.s.low = ((UWtype) uu.s.low >> b) | carries;
129 +       }
130 +
131 +       return w.ll;
132 +}
133 +
134 +EXPORT_SYMBOL(__ashrdi3);
135 +
136 +#endif /* ARCH_NEEDS_ashrdi3 */
137 diff -Nur linux-2.6.15.1/lib/lshrdi3.c linux-2.6.15.1-openwrt/lib/lshrdi3.c
138 --- linux-2.6.15.1/lib/lshrdi3.c        1970-01-01 01:00:00.000000000 +0100
139 +++ linux-2.6.15.1-openwrt/lib/lshrdi3.c        2006-01-20 10:40:10.000000000 +0100
140 @@ -0,0 +1,34 @@
141 +#include <linux/libgcc.h>
142 +#include <linux/module.h>
143 +
144 +/* Unless shift functions are defined with full ANSI prototypes,
145 +   parameter b will be promoted to int if word_type is smaller than an int.  */
146 +#ifdef ARCH_NEEDS_lshrdi3
147 +
148 +DWtype __lshrdi3(DWtype u, word_type b)
149 +{
150 +       DWunion uu, w;
151 +       word_type bm;
152 +
153 +       if (b == 0)
154 +               return u;
155 +
156 +       uu.ll = u;
157 +       bm = (sizeof(Wtype) * BITS_PER_UNIT) - b;
158 +
159 +       if (bm <= 0) {
160 +               w.s.high = 0;
161 +               w.s.low = (UWtype) uu.s.high >> -bm;
162 +       } else {
163 +               const UWtype carries = (UWtype) uu.s.high << bm;
164 +
165 +               w.s.high = (UWtype) uu.s.high >> b;
166 +               w.s.low = ((UWtype) uu.s.low >> b) | carries;
167 +       }
168 +
169 +       return w.ll;
170 +}
171 +
172 +EXPORT_SYMBOL(__lshrdi3);
173 +
174 +#endif /* ARCH_NEEDS_lshrdi3 */
175 diff -Nur linux-2.6.15.1/lib/Makefile linux-2.6.15.1-openwrt/lib/Makefile
176 --- linux-2.6.15.1/lib/Makefile 2006-01-15 07:16:02.000000000 +0100
177 +++ linux-2.6.15.1-openwrt/lib/Makefile 2006-01-20 10:34:19.000000000 +0100
178 @@ -8,6 +8,7 @@
179          sha1.o
180  
181  lib-y  += kobject.o kref.o kobject_uevent.o klist.o
182 +obj-y  += ashldi3.o ashrdi3.o lshrdi3.o
183  
184  obj-y += sort.o parser.o halfmd4.o
185  
186 diff -Nur linux-2.6.15.1/include/asm-arm/libgcc.h linux-2.6.15.1-openwrt/include/asm-arm/libgcc.h
187 --- linux-2.6.15.1/include/asm-arm/libgcc.h     1970-01-01 01:00:00.000000000 +0100
188 +++ linux-2.6.15.1-openwrt/include/asm-arm/libgcc.h     2006-04-12 23:01:18.000000000 +0200
189 @@ -0,0 +1,8 @@
190 +#ifndef __ASM_LIBGCC_H
191 +#define __ASM_LIBGCC_H
192 +
193 +#undef ARCH_NEEDS_ashldi3
194 +#undef ARCH_NEEDS_ashrdi3
195 +#undef ARCH_NEEDS_lshrdi3
196 +
197 +#endif /* __ASM_LIBGCC_H */