summaryrefslogtreecommitdiff
path: root/gmp/tests/mpf/reuse.c
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-05-27 17:39:31 +0100
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-05-27 17:53:32 +0100
commit26c75cf8267919f81a1759c9c965a52c660233f9 (patch)
treecf2a39cf56c2c8ac45760854413ab233e6263974 /gmp/tests/mpf/reuse.c
parent56892c1d217baea02092b51a09bbc924130ca84c (diff)
downloadgcc-tarball-26c75cf8267919f81a1759c9c965a52c660233f9.tar.gz
Diffstat (limited to 'gmp/tests/mpf/reuse.c')
-rw-r--r--gmp/tests/mpf/reuse.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/gmp/tests/mpf/reuse.c b/gmp/tests/mpf/reuse.c
index 3a382530b6..f373ac700e 100644
--- a/gmp/tests/mpf/reuse.c
+++ b/gmp/tests/mpf/reuse.c
@@ -1,21 +1,21 @@
/* Test that routines allow reusing a source variable as destination.
-Copyright 1996, 2000-2002, 2012 Free Software Foundation, Inc.
+Copyright 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
-This file is part of the GNU MP Library test suite.
+This file is part of the GNU MP Library.
-The GNU MP Library test suite 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; either version 3 of the License,
-or (at your option) any later version.
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
-The GNU MP Library test suite is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-Public License for more details.
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
-You should have received a copy of the GNU General Public License along with
-the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
@@ -50,42 +50,42 @@ main (void)
#define EXPO 32
#endif
-void dump_abort (const char *, mpf_t, mpf_t);
+void dump_abort __GMP_PROTO ((char *, mpf_t, mpf_t));
-typedef void (*dss_func) (mpf_ptr, mpf_srcptr, mpf_srcptr);
+typedef void (*dss_func) __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
dss_func dss_funcs[] =
{
mpf_div, mpf_add, mpf_mul, mpf_sub,
};
-const char *dss_func_names[] =
+char *dss_func_names[] =
{
"mpf_div", "mpf_add", "mpf_mul", "mpf_sub",
};
-typedef void (*dsi_func) (mpf_ptr, mpf_srcptr, unsigned long int);
+typedef void (*dsi_func) __GMP_PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
dsi_func dsi_funcs[] =
{
mpf_div_ui, mpf_add_ui, mpf_mul_ui, mpf_sub_ui,
- mpf_mul_2exp, mpf_div_2exp, mpf_pow_ui
+ mpf_mul_2exp, mpf_div_2exp
};
-const char *dsi_func_names[] =
+char *dsi_func_names[] =
{
"mpf_div_ui", "mpf_add_ui", "mpf_mul_ui", "mpf_sub_ui",
- "mpf_mul_2exp", "mpf_div_2exp", "mpf_pow_ui"
+ "mpf_mul_2exp", "mpf_div_2exp"
};
-typedef void (*dis_func) (mpf_ptr, unsigned long int, mpf_srcptr);
+typedef void (*dis_func) __GMP_PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
dis_func dis_funcs[] =
{
mpf_ui_div, mpf_ui_sub,
};
-const char *dis_func_names[] =
+char *dis_func_names[] =
{
"mpf_ui_div", "mpf_ui_sub",
};
@@ -148,22 +148,14 @@ main (int argc, char **argv)
in2i = urandom ();
for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++)
{
- unsigned long this_in2i = in2i;
-
/* Don't divide by 0. */
- if (dsi_funcs[i] == mpf_div_ui && this_in2i == 0)
+ if (strcmp (dsi_func_names[i], "mpf_div_ui") == 0 && in2i == 0)
continue;
- /* Avoid overflow/underflow in the exponent. */
- if (dsi_funcs[i] == mpf_mul_2exp || dsi_funcs[i] == mpf_div_2exp)
- this_in2i %= 0x100000;
- else if (dsi_funcs[i] == mpf_pow_ui)
- this_in2i %= 0x1000;
-
- (dsi_funcs[i]) (res1, in1, this_in2i);
+ (dsi_funcs[i]) (res1, in1, in2i);
mpf_set (out1, in1);
- (dsi_funcs[i]) (out1, out1, this_in2i);
+ (dsi_funcs[i]) (out1, out1, in2i);
mpf_set (res2, out1);
if (mpf_cmp (res1, res2) != 0)
@@ -174,7 +166,7 @@ main (int argc, char **argv)
for (i = 0; i < sizeof (dis_funcs) / sizeof (dis_func); i++)
{
/* Don't divide by 0. */
- if (dis_funcs[i] == mpf_ui_div
+ if (strcmp (dis_func_names[i], "mpf_ui_div") == 0
&& mpf_cmp_ui (in2, 0) == 0)
continue;
@@ -202,7 +194,7 @@ main (int argc, char **argv)
}
void
-dump_abort (const char *name, mpf_t res1, mpf_t res2)
+dump_abort (char *name, mpf_t res1, mpf_t res2)
{
printf ("failure in %s:\n", name);
mpf_dump (res1);
@@ -211,9 +203,9 @@ dump_abort (const char *name, mpf_t res1, mpf_t res2)
}
#if 0
-void mpf_abs (mpf_ptr, mpf_srcptr);
-void mpf_sqrt (mpf_ptr, mpf_srcptr);
-void mpf_neg (mpf_ptr, mpf_srcptr);
+void mpf_abs __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+void mpf_sqrt __GMP_PROTO ((mpf_ptr, mpf_srcptr));
+void mpf_neg __GMP_PROTO ((mpf_ptr, mpf_srcptr));
#endif
#endif /* ! DLL_EXPORT */