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