]> rtime.felk.cvut.cz Git - mcf548x/linux.git/blob - arch/m68k/lib/muldi3.c
Fixes (asm, entry, irq, linker, defconfig)
[mcf548x/linux.git] / arch / m68k / lib / muldi3.c
1 /* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and
2                            gcc-2.7.2.3/longlong.h which is: */
3 /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #define BITS_PER_UNIT 8
23
24 #ifdef CONFIG_COLDFIRE
25 #define umul_ppmm(w1, w0, u, v) \
26   do { \
27        unsigned long long x; \
28        x = (unsigned long long)u * v; \
29        w0 = (unsigned long)(x & 0x00000000ffffffff); \
30        w1 = (unsigned long)(x & 0xffffffff00000000) >> 32; \
31      } while (0)
32 #else /* CONFIG_COLDFIRE */
33 #define umul_ppmm(w1, w0, u, v) \
34   __asm__ ("mulu%.l %3,%1:%0"                                           \
35            : "=d" ((USItype)(w0)),                                      \
36              "=d" ((USItype)(w1))                                       \
37            : "%0" ((USItype)(u)),                                       \
38              "dmi" ((USItype)(v)))
39 #endif /* CONFIG_COLDFIRE */
40
41 #define __umulsidi3(u, v) \
42   ({DIunion __w;                                                        \
43     umul_ppmm (__w.s.high, __w.s.low, u, v);                            \
44     __w.ll; })
45
46 typedef          int SItype     __attribute__ ((mode (SI)));
47 typedef unsigned int USItype    __attribute__ ((mode (SI)));
48 typedef          int DItype     __attribute__ ((mode (DI)));
49 typedef int word_type __attribute__ ((mode (__word__)));
50
51 struct DIstruct {SItype high, low;};
52
53 typedef union
54 {
55   struct DIstruct s;
56   DItype ll;
57 } DIunion;
58
59 DItype
60 __muldi3 (DItype u, DItype v)
61 {
62   DIunion w;
63   DIunion uu, vv;
64
65   uu.ll = u,
66   vv.ll = v;
67
68   w.ll = __umulsidi3 (uu.s.low, vv.s.low);
69   w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
70                + (USItype) uu.s.high * (USItype) vv.s.low);
71
72   return w.ll;
73 }