version 1.1, 2001/10/02 11:17:07 |
version 1.2, 2002/09/11 07:26:59 |
|
|
|
/* $Id$ |
|
|
|
Copyright (C) 2000 The PARI group. |
|
|
|
This file is part of the PARI/GP package. |
|
|
|
PARI/GP is free software; you can redistribute it and/or modify it under the |
|
terms of the GNU General Public License as published by the Free Software |
|
Foundation. It is distributed in the hope that it will be useful, but WITHOUT |
|
ANY WARRANTY WHATSOEVER. |
|
|
|
Check the License for details. You should have received a copy of it, along |
|
with the package; see the file 'COPYING'. If not, write to the Free Software |
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
|
ulong overflow; |
ulong overflow; |
ulong hiremainder; |
ulong hiremainder; |
|
|
Line 6 ulong hiremainder; |
|
Line 21 ulong hiremainder; |
|
#define SAVE_OVERFLOW |
#define SAVE_OVERFLOW |
#define SAVE_HIREMAINDER |
#define SAVE_HIREMAINDER |
|
|
|
#ifndef ASMINLINE |
|
BEGINEXTERN |
|
extern long addll(ulong a, ulong b); |
|
extern long addllx(ulong a, ulong b); |
|
extern long subll(ulong a, ulong b); |
|
extern long subllx(ulong a, ulong b); |
|
extern long shiftl(ulong x, ulong y); |
|
extern long shiftlr(ulong x, ulong y); |
|
extern long mulll(ulong x, ulong y); |
|
extern long addmul(ulong x, ulong y); |
|
ENDEXTERN |
|
|
|
#else /* ASMINLINE */ |
/* From the PARI source, using gcc __asm__ format. */ |
/* From the PARI source, using gcc __asm__ format. */ |
|
|
#define addll(a, b)\ |
#define addll(a, b)\ |
Line 72 __asm__ volatile ("subq %4,%5,%2\n\tcmpult %4,%8,%3\n\ |
|
Line 99 __asm__ volatile ("subq %4,%5,%2\n\tcmpult %4,%8,%3\n\ |
|
: "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (hiremainder), "2" ((ulong) 0)); \ |
: "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (hiremainder), "2" ((ulong) 0)); \ |
__value; \ |
__value; \ |
}) |
}) |
|
#endif |
/* |
|
The end of the present file is a slight adaptation of source code |
|
extracted from gmp-3.1.1 (from T. Granlund), files longlong.h and |
|
gmp-impl.h |
|
|
|
Copyright (C) 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000 Free Software |
|
Foundation, Inc. |
|
*/ |
|
|
|
extern const unsigned char __clz_tab[]; |
|
extern ulong invert_word(ulong); |
|
|
|
#define bfffo(x) \ |
|
({ \ |
|
ulong __xr = (x); \ |
|
ulong __a; \ |
|
\ |
|
for (__a = 56; __a > 0; __a -= 8) \ |
|
if (((__xr >> __a) & 0xff) != 0) \ |
|
break; \ |
|
64 - (__clz_tab[__xr >> __a] + __a); \ |
|
}) |
|
|
|
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ |
|
do { \ |
|
ulong __x; \ |
|
__x = (al) - (bl); \ |
|
(sh) = (ah) - (bh) - (__x > (al)); \ |
|
(sl) = __x; \ |
|
} while (0) |
|
|
|
#define divll(x, y) \ |
|
({ \ |
|
register ulong _di, _x = (x), _y = (y), _q, _ql, _r; \ |
|
register ulong _xh, _xl, _k, __hire; \ |
|
\ |
|
if (_y & 0x8000000000000000UL) \ |
|
{ _k = 0; __hire = hiremainder; } \ |
|
else \ |
|
{ \ |
|
_k = bfffo(_y); \ |
|
__hire = (hiremainder << _k) | (_x >> (64 - _k)); \ |
|
_x <<= _k; _y <<= _k; \ |
|
} \ |
|
_di = invert_word(_y); \ |
|
_ql = mulll (__hire, _di); \ |
|
_q = __hire + hiremainder; \ |
|
_xl = mulll(_q, _y); _xh = hiremainder; \ |
|
sub_ddmmss (_xh, _r, __hire, _x, _xh, _xl); \ |
|
if (_xh != 0) \ |
|
{ \ |
|
sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; \ |
|
if (_xh != 0) \ |
|
{ sub_ddmmss (_xh, _r, _xh, _r, 0, _y); _q += 1; } \ |
|
} \ |
|
if (_r >= _y) \ |
|
{ _r -= _y; _q += 1; } \ |
|
hiremainder = _r >> _k; \ |
|
_q; \ |
|
}) |
|
|
|
|
|