2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
|
|
|
#define add_ssaaaa(sh, sl, ah, al, bh, bl) ({ \
|
2006-09-28 16:56:43 +02:00
|
|
|
unsigned int __sh = (ah); \
|
|
|
|
unsigned int __sl = (al); \
|
|
|
|
asm volatile( \
|
|
|
|
" alr %1,%3\n" \
|
|
|
|
" brc 12,0f\n" \
|
|
|
|
" ahi %0,1\n" \
|
|
|
|
"0: alr %0,%2" \
|
|
|
|
: "+&d" (__sh), "+d" (__sl) \
|
|
|
|
: "d" (bh), "d" (bl) : "cc"); \
|
|
|
|
(sh) = __sh; \
|
|
|
|
(sl) = __sl; \
|
2005-04-17 00:20:36 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
#define sub_ddmmss(sh, sl, ah, al, bh, bl) ({ \
|
2006-09-28 16:56:43 +02:00
|
|
|
unsigned int __sh = (ah); \
|
|
|
|
unsigned int __sl = (al); \
|
|
|
|
asm volatile( \
|
|
|
|
" slr %1,%3\n" \
|
|
|
|
" brc 3,0f\n" \
|
|
|
|
" ahi %0,-1\n" \
|
|
|
|
"0: slr %0,%2" \
|
|
|
|
: "+&d" (__sh), "+d" (__sl) \
|
|
|
|
: "d" (bh), "d" (bl) : "cc"); \
|
|
|
|
(sh) = __sh; \
|
|
|
|
(sl) = __sl; \
|
2005-04-17 00:20:36 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
/* a umul b = a mul b + (a>=2<<31) ? b<<32:0 + (b>=2<<31) ? a<<32:0 */
|
|
|
|
#define umul_ppmm(wh, wl, u, v) ({ \
|
2006-09-28 16:56:43 +02:00
|
|
|
unsigned int __wh = u; \
|
|
|
|
unsigned int __wl = v; \
|
|
|
|
asm volatile( \
|
|
|
|
" ltr 1,%0\n" \
|
|
|
|
" mr 0,%1\n" \
|
|
|
|
" jnm 0f\n" \
|
|
|
|
" alr 0,%1\n" \
|
|
|
|
"0: ltr %1,%1\n" \
|
|
|
|
" jnm 1f\n" \
|
|
|
|
" alr 0,%0\n" \
|
|
|
|
"1: lr %0,0\n" \
|
|
|
|
" lr %1,1\n" \
|
|
|
|
: "+d" (__wh), "+d" (__wl) \
|
|
|
|
: : "0", "1", "cc"); \
|
|
|
|
wh = __wh; \
|
|
|
|
wl = __wl; \
|
2005-04-17 00:20:36 +02:00
|
|
|
})
|
|
|
|
|
2007-07-10 11:24:14 +02:00
|
|
|
#ifdef __s390x__
|
|
|
|
#define udiv_qrnnd(q, r, n1, n0, d) \
|
|
|
|
do { unsigned long __n; \
|
|
|
|
unsigned int __r, __d; \
|
|
|
|
__n = ((unsigned long)(n1) << 32) + n0; \
|
|
|
|
__d = (d); \
|
|
|
|
(q) = __n / __d; \
|
|
|
|
(r) = __n % __d; \
|
|
|
|
} while (0)
|
|
|
|
#else
|
2005-04-17 00:20:36 +02:00
|
|
|
#define udiv_qrnnd(q, r, n1, n0, d) \
|
2007-02-05 21:18:31 +01:00
|
|
|
do { unsigned int __r; \
|
2005-04-17 00:20:36 +02:00
|
|
|
(q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
|
|
|
|
(r) = __r; \
|
|
|
|
} while (0)
|
2007-02-05 21:18:31 +01:00
|
|
|
extern unsigned long __udiv_qrnnd (unsigned int *, unsigned int,
|
|
|
|
unsigned int , unsigned int);
|
2007-07-10 11:24:14 +02:00
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#define UDIV_NEEDS_NORMALIZATION 0
|
|
|
|
|
|
|
|
#define abort() return 0
|
|
|
|
|
|
|
|
#define __BYTE_ORDER __BIG_ENDIAN
|