removed some unnecessary tools; added swap support to kernel
[openwrt_grafs.git] / target / linux / ubicom32 / patches-2.6.30 / 120-libgcc_func.patch
blobfee4ece003d80188a7a6c909946692969cb141aa
1 --- a/arch/ubicom32/Makefile
2 +++ b/arch/ubicom32/Makefile
3 @@ -60,9 +60,6 @@ cflags-$(CONFIG_UBICOM32_V4) := -march=
4 ldflags-$(CONFIG_LINKER_RELAXATION) := --relax
5 LDFLAGS_vmlinux := $(ldflags-y)
7 -GCCLIBDIR := $(dir $(shell $(CC) $(cflags-y) -print-libgcc-file-name))
8 -GCC_LIBS := $(GCCLIBDIR)/libgcc.a
10 KBUILD_CFLAGS += $(cflags-y) -ffunction-sections
11 KBUILD_AFLAGS += $(cflags-y)
13 @@ -84,7 +81,6 @@ core-y += arch/$(ARCH)/kernel/ \
14 drivers-$(CONFIG_OPROFILE) += arch/ubicom32/oprofile/
16 libs-y += arch/$(ARCH)/lib/
17 -libs-y += $(GCC_LIBS)
19 archclean:
21 --- a/arch/ubicom32/lib/Makefile
22 +++ b/arch/ubicom32/lib/Makefile
23 @@ -30,3 +30,4 @@
26 lib-y := checksum.o delay.o mem_ubicom32.o
27 +lib-y += ashldi3.o ashrdi3.o divmod.o lshrdi3.o muldi3.o
28 --- /dev/null
29 +++ b/arch/ubicom32/lib/ashldi3.c
30 @@ -0,0 +1,62 @@
31 +/* ashrdi3.c extracted from gcc-2.95.2/libgcc2.c which is: */
32 +/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
34 +This file is part of GNU CC.
36 +GNU CC is free software; you can redistribute it and/or modify
37 +it under the terms of the GNU General Public License as published by
38 +the Free Software Foundation; either version 2, or (at your option)
39 +any later version.
41 +GNU CC is distributed in the hope that it will be useful,
42 +but WITHOUT ANY WARRANTY; without even the implied warranty of
43 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 +GNU General Public License for more details.
46 +You should have received a copy of the GNU General Public License
47 +along with GNU CC; see the file COPYING. If not, write to
48 +the Free Software Foundation, 59 Temple Place - Suite 330,
49 +Boston, MA 02111-1307, USA. */
51 +#define BITS_PER_UNIT 8
53 +typedef int SItype __attribute__ ((mode (SI)));
54 +typedef unsigned int USItype __attribute__ ((mode (SI)));
55 +typedef int DItype __attribute__ ((mode (DI)));
56 +typedef int word_type __attribute__ ((mode (__word__)));
58 +struct DIstruct {SItype high, low;};
60 +typedef union
62 + struct DIstruct s;
63 + DItype ll;
64 +} DIunion;
66 +DItype
67 +__ashldi3 (DItype u, word_type b)
69 + DIunion w;
70 + word_type bm;
71 + DIunion uu;
73 + if (b == 0)
74 + return u;
76 + uu.ll = u;
78 + bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
79 + if (bm <= 0)
80 + {
81 + w.s.low = 0;
82 + w.s.high = (USItype)uu.s.low << -bm;
83 + }
84 + else
85 + {
86 + USItype carries = (USItype)uu.s.low >> bm;
87 + w.s.low = (USItype)uu.s.low << b;
88 + w.s.high = ((USItype)uu.s.high << b) | carries;
89 + }
91 + return w.ll;
93 --- /dev/null
94 +++ b/arch/ubicom32/lib/ashrdi3.c
95 @@ -0,0 +1,63 @@
96 +/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
97 +/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
99 +This file is part of GNU CC.
101 +GNU CC is free software; you can redistribute it and/or modify
102 +it under the terms of the GNU General Public License as published by
103 +the Free Software Foundation; either version 2, or (at your option)
104 +any later version.
106 +GNU CC is distributed in the hope that it will be useful,
107 +but WITHOUT ANY WARRANTY; without even the implied warranty of
108 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109 +GNU General Public License for more details.
111 +You should have received a copy of the GNU General Public License
112 +along with GNU CC; see the file COPYING. If not, write to
113 +the Free Software Foundation, 59 Temple Place - Suite 330,
114 +Boston, MA 02111-1307, USA. */
116 +#define BITS_PER_UNIT 8
118 +typedef int SItype __attribute__ ((mode (SI)));
119 +typedef unsigned int USItype __attribute__ ((mode (SI)));
120 +typedef int DItype __attribute__ ((mode (DI)));
121 +typedef int word_type __attribute__ ((mode (__word__)));
123 +struct DIstruct {SItype high, low;};
125 +typedef union
127 + struct DIstruct s;
128 + DItype ll;
129 +} DIunion;
131 +DItype
132 +__ashrdi3 (DItype u, word_type b)
134 + DIunion w;
135 + word_type bm;
136 + DIunion uu;
138 + if (b == 0)
139 + return u;
141 + uu.ll = u;
143 + bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
144 + if (bm <= 0)
146 + /* w.s.high = 1..1 or 0..0 */
147 + w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
148 + w.s.low = uu.s.high >> -bm;
150 + else
152 + USItype carries = (USItype)uu.s.high << bm;
153 + w.s.high = uu.s.high >> b;
154 + w.s.low = ((USItype)uu.s.low >> b) | carries;
157 + return w.ll;
159 --- /dev/null
160 +++ b/arch/ubicom32/lib/divmod.c
161 @@ -0,0 +1,85 @@
162 +unsigned long
163 +udivmodsi4(unsigned long num, unsigned long den, int modwanted)
165 + unsigned long bit = 1;
166 + unsigned long res = 0;
168 + while (den < num && bit && !(den & (1L<<31)))
170 + den <<=1;
171 + bit <<=1;
173 + while (bit)
175 + if (num >= den)
177 + num -= den;
178 + res |= bit;
180 + bit >>=1;
181 + den >>=1;
183 + if (modwanted) return num;
184 + return res;
187 +long
188 +__udivsi3 (long a, long b)
190 + return udivmodsi4 (a, b, 0);
193 +long
194 +__umodsi3 (long a, long b)
196 + return udivmodsi4 (a, b, 1);
199 +long
200 +__divsi3 (long a, long b)
202 + int neg = 0;
203 + long res;
205 + if (a < 0)
207 + a = -a;
208 + neg = !neg;
211 + if (b < 0)
213 + b = -b;
214 + neg = !neg;
217 + res = udivmodsi4 (a, b, 0);
219 + if (neg)
220 + res = -res;
222 + return res;
225 +long
226 +__modsi3 (long a, long b)
228 + int neg = 0;
229 + long res;
231 + if (a < 0)
233 + a = -a;
234 + neg = 1;
237 + if (b < 0)
238 + b = -b;
240 + res = udivmodsi4 (a, b, 1);
242 + if (neg)
243 + res = -res;
245 + return res;
247 --- /dev/null
248 +++ b/arch/ubicom32/lib/lshrdi3.c
249 @@ -0,0 +1,62 @@
250 +/* lshrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
251 +/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
253 +This file is part of GNU CC.
255 +GNU CC is free software; you can redistribute it and/or modify
256 +it under the terms of the GNU General Public License as published by
257 +the Free Software Foundation; either version 2, or (at your option)
258 +any later version.
260 +GNU CC is distributed in the hope that it will be useful,
261 +but WITHOUT ANY WARRANTY; without even the implied warranty of
262 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263 +GNU General Public License for more details.
265 +You should have received a copy of the GNU General Public License
266 +along with GNU CC; see the file COPYING. If not, write to
267 +the Free Software Foundation, 59 Temple Place - Suite 330,
268 +Boston, MA 02111-1307, USA. */
270 +#define BITS_PER_UNIT 8
272 +typedef int SItype __attribute__ ((mode (SI)));
273 +typedef unsigned int USItype __attribute__ ((mode (SI)));
274 +typedef int DItype __attribute__ ((mode (DI)));
275 +typedef int word_type __attribute__ ((mode (__word__)));
277 +struct DIstruct {SItype high, low;};
279 +typedef union
281 + struct DIstruct s;
282 + DItype ll;
283 +} DIunion;
285 +DItype
286 +__lshrdi3 (DItype u, word_type b)
288 + DIunion w;
289 + word_type bm;
290 + DIunion uu;
292 + if (b == 0)
293 + return u;
295 + uu.ll = u;
297 + bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
298 + if (bm <= 0)
300 + w.s.high = 0;
301 + w.s.low = (USItype)uu.s.high >> -bm;
303 + else
305 + USItype carries = (USItype)uu.s.high << bm;
306 + w.s.high = (USItype)uu.s.high >> b;
307 + w.s.low = ((USItype)uu.s.low >> b) | carries;
310 + return w.ll;
312 --- /dev/null
313 +++ b/arch/ubicom32/lib/muldi3.c
314 @@ -0,0 +1,87 @@
315 +/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and
316 + gcc-2.7.2.3/longlong.h which is: */
317 +/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
319 +This file is part of GNU CC.
321 +GNU CC is free software; you can redistribute it and/or modify
322 +it under the terms of the GNU General Public License as published by
323 +the Free Software Foundation; either version 2, or (at your option)
324 +any later version.
326 +GNU CC is distributed in the hope that it will be useful,
327 +but WITHOUT ANY WARRANTY; without even the implied warranty of
328 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
329 +GNU General Public License for more details.
331 +You should have received a copy of the GNU General Public License
332 +along with GNU CC; see the file COPYING. If not, write to
333 +the Free Software Foundation, 59 Temple Place - Suite 330,
334 +Boston, MA 02111-1307, USA. */
336 +#define UWtype USItype
337 +#define UHWtype USItype
338 +#define W_TYPE_SIZE 32
339 +#define __BITS4 (W_TYPE_SIZE / 4)
340 +#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
341 +#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
342 +#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
344 +#define umul_ppmm(w1, w0, u, v) \
345 + do { \
346 + UWtype __x0, __x1, __x2, __x3; \
347 + UHWtype __ul, __vl, __uh, __vh; \
349 + __ul = __ll_lowpart (u); \
350 + __uh = __ll_highpart (u); \
351 + __vl = __ll_lowpart (v); \
352 + __vh = __ll_highpart (v); \
354 + __x0 = (UWtype) __ul * __vl; \
355 + __x1 = (UWtype) __ul * __vh; \
356 + __x2 = (UWtype) __uh * __vl; \
357 + __x3 = (UWtype) __uh * __vh; \
359 + __x1 += __ll_highpart (__x0);/* this can't give carry */ \
360 + __x1 += __x2; /* but this indeed can */ \
361 + if (__x1 < __x2) /* did we get it? */ \
362 + __x3 += __ll_B; /* yes, add it in the proper pos. */ \
364 + (w1) = __x3 + __ll_highpart (__x1); \
365 + (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
366 + } while (0)
369 +#define __umulsidi3(u, v) \
370 + ({DIunion __w; \
371 + umul_ppmm (__w.s.high, __w.s.low, u, v); \
372 + __w.ll; })
374 +typedef int SItype __attribute__ ((mode (SI)));
375 +typedef unsigned int USItype __attribute__ ((mode (SI)));
376 +typedef int DItype __attribute__ ((mode (DI)));
377 +typedef int word_type __attribute__ ((mode (__word__)));
379 +struct DIstruct {SItype high, low;};
381 +typedef union
383 + struct DIstruct s;
384 + DItype ll;
385 +} DIunion;
387 +DItype
388 +__muldi3 (DItype u, DItype v)
390 + DIunion w;
391 + DIunion uu, vv;
393 + uu.ll = u,
394 + vv.ll = v;
396 + w.ll = __umulsidi3 (uu.s.low, vv.s.low);
397 + w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
398 + + (USItype) uu.s.high * (USItype) vv.s.low);
400 + return w.ll;
402 --- a/arch/ubicom32/kernel/ubicom32_ksyms.c
403 +++ b/arch/ubicom32/kernel/ubicom32_ksyms.c
404 @@ -72,7 +72,6 @@ EXPORT_SYMBOL(memmove);
405 extern void __ashldi3(void);
406 extern void __ashrdi3(void);
407 extern void __divsi3(void);
408 -extern void __divdi3(void);
409 extern void __lshrdi3(void);
410 extern void __modsi3(void);
411 extern void __muldi3(void);
412 @@ -83,7 +82,6 @@ extern void __umodsi3(void);
413 EXPORT_SYMBOL(__ashldi3);
414 EXPORT_SYMBOL(__ashrdi3);
415 EXPORT_SYMBOL(__divsi3);
416 -EXPORT_SYMBOL(__divdi3);
417 EXPORT_SYMBOL(__lshrdi3);
418 EXPORT_SYMBOL(__modsi3);
419 EXPORT_SYMBOL(__muldi3);