fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / machine / h8500 / mulsi3.c
bloba923e8db5ec9f7e6834f882c38ffaa5a9fb8b4ff
2 typedef union {
3 struct {
4 unsigned int msw;
5 unsigned int lsw;
6 } s;
7 long v;
8 } u;
10 long __mulsi3(u a, u b)
12 int s;
13 long pp1;
14 long pp2;
15 long r;
17 if (a.s.msw == 0 &&
18 b.s.msw == 0)
20 return (long)a.s.lsw * b.s.lsw;
23 s = 0;
24 if (a.v < 0)
26 s = 1;
27 a.v = - a.v;
29 if (b.v < 0)
31 s = 1-s;
32 b.v = - b.v;
35 pp1 = (long)a.s.lsw * b.s.lsw ;
36 pp2 = (long)a.s.lsw * b.s.msw + (long)a.s.msw * b.s.lsw;
38 pp1 += pp2 << 16;
40 if (s)
42 pp1 = -pp1;
44 return pp1;
46 long __mulpsi3(long a, long b)
48 return a*b;
52 short
53 __mulhi3(short a, short b)
55 int r;
57 r = 0;
58 while (a)
60 if (a & 1)
62 r += b;
65 b<<=1;
66 a>>=1;
69 return r;