1 /* Copyright 1996, 2001 Free Software Foundation, Inc.
3 This file is part of the GNU MP Library.
5 The GNU MP Library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or (at your
8 option) any later version.
10 The GNU MP Library is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
32 #define REFCALL refmpn_add_n
33 #define TESTCALL mpn_add_n
37 #define REFCALL refmpn_sub_n
38 #define TESTCALL mpn_sub_n
44 main (int argc, char **argv)
46 mp_size_t alloc_size, max_size, size, i, cumul_size;
47 mp_ptr s1, s2, dx, dy;
48 int s1_align, s2_align, d_align;
58 max_size = atol (*argv);
62 alloc_size = max_size + 32;
63 s1 = malloc (alloc_size * BYTES_PER_MP_LIMB);
64 s2 = malloc (alloc_size * BYTES_PER_MP_LIMB);
65 dx = malloc (alloc_size * BYTES_PER_MP_LIMB);
66 dy = malloc (alloc_size * BYTES_PER_MP_LIMB);
69 for (pass = 0; pass < n_passes; pass++)
71 size = random () % max_size + 1;
74 if (cumul_size >= 1000000)
76 cumul_size -= 1000000;
77 printf ("\r%ld", pass); fflush (stdout);
79 s1_align = random () % 32;
80 s2_align = random () % 32;
81 d_align = random () % 32;
83 mpn_random2 (s1 + s1_align, size);
84 mpn_random2 (s2 + s2_align, size);
86 for (i = 0; i < alloc_size; i++)
87 dx[i] = dy[i] = i + 0x9876500;
89 cx = TESTCALL (dx + d_align, s1 + s1_align, s2 + s2_align, size);
90 cy = REFCALL (dy + d_align, s1 + s1_align, s2 + s2_align, size);
92 if (cx != cy || mpn_cmp (dx, dy, alloc_size) != 0)
96 printf ("%ld passes OK\n", n_passes);