shmobile: Use power domains for platform runtime PM
[linux/fpc-iii.git] / arch / microblaze / lib / muldi3.c
blob0585bccb7fad2f30d6ad8110eff7bc0b80771dff
1 #include <linux/module.h>
3 #include "libgcc.h"
5 #define DWtype long long
6 #define UWtype unsigned long
7 #define UHWtype unsigned short
9 #define W_TYPE_SIZE 32
11 #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
12 #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
13 #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
15 /* If we still don't have umul_ppmm, define it using plain C. */
16 #if !defined(umul_ppmm)
17 #define umul_ppmm(w1, w0, u, v) \
18 do { \
19 UWtype __x0, __x1, __x2, __x3; \
20 UHWtype __ul, __vl, __uh, __vh; \
22 __ul = __ll_lowpart(u); \
23 __uh = __ll_highpart(u); \
24 __vl = __ll_lowpart(v); \
25 __vh = __ll_highpart(v); \
27 __x0 = (UWtype) __ul * __vl; \
28 __x1 = (UWtype) __ul * __vh; \
29 __x2 = (UWtype) __uh * __vl; \
30 __x3 = (UWtype) __uh * __vh; \
32 __x1 += __ll_highpart(__x0); /* this can't give carry */\
33 __x1 += __x2; /* but this indeed can */ \
34 if (__x1 < __x2) /* did we get it? */ \
35 __x3 += __ll_B; /* yes, add it in the proper pos */ \
37 (w1) = __x3 + __ll_highpart(__x1); \
38 (w0) = __ll_lowpart(__x1) * __ll_B + __ll_lowpart(__x0);\
39 } while (0)
40 #endif
42 #if !defined(__umulsidi3)
43 #define __umulsidi3(u, v) ({ \
44 DWunion __w; \
45 umul_ppmm(__w.s.high, __w.s.low, u, v); \
46 __w.ll; \
48 #endif
50 DWtype __muldi3(DWtype u, DWtype v)
52 const DWunion uu = {.ll = u};
53 const DWunion vv = {.ll = v};
54 DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)};
56 w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
57 + (UWtype) uu.s.high * (UWtype) vv.s.low);
59 return w.ll;
61 EXPORT_SYMBOL(__muldi3);