2 Copyright 1996, 1997, 1998, 2000, 2001, 2007, 2009 Free Software Foundation,
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
25 #if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined (__hpux)
31 if (CLOCKS_PER_SEC < 100000)
32 return clock () * 1000 / CLOCKS_PER_SEC;
33 return clock () / (CLOCKS_PER_SEC / 1000);
36 #include <sys/types.h>
38 #include <sys/resource.h>
46 return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
53 #error "Don't know CLOCK of your machine"
63 #define TIMES OPS/(SIZE+1)
69 mp_limb_t nptr[2 * SIZE];
70 mp_limb_t dptr[2 * SIZE];
71 mp_limb_t qptr[2 * SIZE];
72 mp_limb_t pptr[2 * SIZE + 1];
73 mp_limb_t rptr[2 * SIZE];
74 mp_size_t nsize, dsize, qsize, rsize, psize;
78 for (test = 0; ; test++)
80 printf ("%d\n", test);
82 nsize = random () % (2 * SIZE) + 1;
83 dsize = random () % nsize + 1;
89 mpn_random2 (nptr, nsize);
90 mpn_random2 (dptr, dsize);
91 dptr[dsize - 1] |= (mp_limb_t) 1 << (GMP_LIMB_BITS - 1);
93 MPN_COPY (rptr, nptr, nsize);
94 qlimb = mpn_divrem (qptr, (mp_size_t) 0, rptr, nsize, dptr, dsize);
96 qsize = nsize - dsize;
99 if (qsize == 0 || qsize > 2 * SIZE)
101 continue; /* bogus */
107 mpn_mul (pptr, qptr, qsize, dptr, dsize);
109 mpn_mul (pptr, dptr, dsize, qptr, qsize);
110 psize = qsize + dsize;
111 psize -= pptr[psize - 1] == 0;
112 cy = mpn_add (pptr, pptr, psize, rptr, rsize);
117 if (nsize != psize || mpn_cmp (nptr, pptr, nsize) != 0)