Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28495 views
License: GPL3
ubuntu2004
1
/* Extracted from gmp-4.1.2
2
* FIXME: This file is unused until somebody implements
3
* invert_word(x) = return floor( 2^(2*BIL)/x ) */
4
extern ulong invert_word(ulong);
5
6
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
7
__extension__ ({ \
8
ulong __x; \
9
__x = (al) - (bl); \
10
(sh) = (ah) - (bh) - (__x > (al)); \
11
(sl) = __x; \
12
})
13
14
#define divll(x, y) \
15
__extension__ ({ \
16
register ulong _di, _x = (x), _y = (y), _q, _ql, _r; \
17
register ulong _xh, _xl, _k, __hire; \
18
\
19
if (_y & 0x8000000000000000UL) \
20
{ _k = 0; __hire = hiremainder; } \
21
else \
22
{ \
23
_k = bfffo(_y); \
24
__hire = (hiremainder << _k) | (_x >> (64 - _k)); \
25
_x <<= _k; _y <<= _k; \
26
} \
27
_di = invert_word(_y); \
28
_ql = mulll (__hire, _di); \
29
_q = __hire + hiremainder; \
30
_xl = mulll(_q, _y); _xh = hiremainder; \
31
sub_ddmmss (_xh, _r, __hire, _x, _xh, _xl); \
32
if (_xh != 0) \
33
{ \
34
sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; \
35
if (_xh != 0) \
36
{ sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; } \
37
} \
38
if (_r >= _y) \
39
{ _r -= _y; _q += 1; } \
40
hiremainder = _r >> _k; \
41
_q; \
42
})
43
44