summaryrefslogtreecommitdiff
path: root/mpfr-test.h
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2002-05-27 13:48:56 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2002-05-27 13:48:56 +0000
commita8bbca8da73288c230b02e23f8844502e700f844 (patch)
tree121921db74799d1c64ac6832e018fbc6119f7eb8 /mpfr-test.h
parent6cc9ba1510baa89ceb8a9590f03c916c9142ade2 (diff)
downloadmpfr-a8bbca8da73288c230b02e23f8844502e700f844.tar.gz
Patch by Kevin Ryde for memory leak checking + misc declaration fixes.
Code moved from mpfr-test.h to tests.c. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1932 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'mpfr-test.h')
-rw-r--r--mpfr-test.h119
1 files changed, 9 insertions, 110 deletions
diff --git a/mpfr-test.h b/mpfr-test.h
index a4e22d2ec..57245322f 100644
--- a/mpfr-test.h
+++ b/mpfr-test.h
@@ -72,12 +72,6 @@ MA 02111-1307, USA. */
#define random() (mrand48() & 0x7fffffff)
#endif
-void mpfr_test_init _PROTO ((void));
-double drand _PROTO ((void));
-int ulp _PROTO ((double, double));
-double dbl _PROTO ((double, int));
-double Ulp _PROTO ((double));
-
#define MINNORM 2.2250738585072013831e-308 /* 2^(-1022), smallest normalized */
#define MAXNORM 1.7976931348623157081e308 /* 2^(1023)*(2-2^(-52)) */
@@ -92,109 +86,14 @@ double Ulp _PROTO ((double));
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ABS(x) (((x)>0) ? (x) : -(x))
-/* initialization function for tests using the hardware floats */
-void
-mpfr_test_init ()
-{
- double c, d;
- int j;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
+void tests_memory_start _PROTO ((void));
+void tests_memory_end _PROTO ((void));
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
-#ifdef HAVE_DENORMS
- d = DBL_MIN;
- if (2.0 * (d / 2.0) != d)
- {
- fprintf (stderr, "Warning: no denormalized numbers\n");
- exit (1);
- }
-#endif
+void tests_start_mpfr _PROTO ((void));
+void tests_end_mpfr _PROTO ((void));
-#ifdef HAVE_SETFPUCW
- /* sets the precision to double */
- __setfpucw((_FPU_DEFAULT & (~_FPU_EXTENDED)) | _FPU_DOUBLE);
-#endif
- c = 1.46484375e-3;
- d = 1.0;
- for (j=0; j<54; j++) d *= 0.5;
- d = 0.75 + d;
- d /= 1 << 9;
- if (c != d)
- {
- fprintf (stderr, "Warning: extended precision not disabled\n");
- exit (1);
- }
-}
-
-/* generate a random double using the whole range of possible values,
- including denormalized numbers, NaN, infinities, ... */
-double
-drand (void)
-{
- double d; int *i, expo;
-
- i = (int*) &d;
- d = 1.0;
- if (i[0] == 0)
- expo = 1; /* little endian, exponent in i[1] */
- else
- expo = 0;
- i[0] = LONG_RAND();
- i[1] = LONG_RAND();
- while (i[expo] >= 2146435072)
- i[expo] = LONG_RAND(); /* avoids NaNs */
- if ((LONG_RAND() % 2) && !isnan (d))
- d = -d; /* generates negative numbers */
- return d;
-}
-
-/* returns ulp(x) for x a 'normal' double-precision number */
-double
-Ulp (double x)
-{
- double y, eps;
-
- if (x < 0) x = -x;
-
- y = x * 2.220446049250313080847263336181640625e-16 ; /* x / 2^52 */
-
- /* as ulp(x) <= y = x/2^52 < 2*ulp(x),
- we have x + ulp(x) <= x + y <= x + 2*ulp(x),
- therefore o(x + y) = x + ulp(x) or x + 2*ulp(x) */
-
- eps = x + y;
- eps = eps - x; /* ulp(x) or 2*ulp(x) */
-
- return (eps > y) ? 0.5 * eps : eps;
-}
-
-/* returns the number of ulp's between a and b,
- where a and b can be any floating-point number, except NaN
- */
-int
-ulp (double a, double b)
-{
- double twoa;
-
- if (a == b) return 0; /* also deals with a=b=inf or -inf */
-
- twoa = a + a;
- if (twoa == a) /* a is +/-0.0 or +/-Inf */
- return ((b < a) ? INT_MAX : -INT_MAX);
-
- return (a - b) / Ulp (a);
-}
-
-/* return double m*2^e */
-double
-dbl (double m, int e)
-{
- if (e>=0) while (e-->0) m *= 2.0;
- else while (e++<0) m /= 2.0;
- return m;
-}
+void mpfr_test_init _PROTO ((void));
+double drand _PROTO ((void));
+int ulp _PROTO ((double, double));
+double dbl _PROTO ((double, int));
+double Ulp _PROTO ((double));