Copyright 1999-2005 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
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 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.
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/. */
/* Future: Would like commas printed between limbs in hex or binary, but perhaps not always since it might upset cutting and pasting into bc or
whatever. */
#include <stdio.h> #include <stdlib.h> #include <string.h> /* for strlen */
#include"gmp-impl.h"
#include"tests.h"
/* Number base for the various trace printing routines. Set this in main() or with the debugger. If hexadecimal is going to be fed into GNU bc, remember to use -16
because bc requires upper case. */
/* Print "namenum=value\n" to stdout for an mpz_t value.
"name" should have a "%d" to get the number. */ void
mpz_tracen (constchar *name, int num, mpz_srcptr z)
{ if (name != NULL && name[0] != '\0')
{
printf (name, num);
putchar ('=');
}
mpz_trace (NULL, z);
}
/* Print "name=value\n" to stdout for a limb, nail doesn't have to be zero. */ void
mp_limb_trace (constchar *name, mp_limb_t n)
{ #if GMP_NAIL_BITS != 0
mp_limb_t a[2];
a[0] = n & GMP_NUMB_MASK;
a[1] = n >> GMP_NUMB_BITS;
mpn_trace (name, a, (mp_size_t) 2); #else
mpn_trace (name, &n, (mp_size_t) 1); #endif
}
/* Print "namenum=value\n" to stdout for an mpn style ptr,size.
"name" should have a "%d" to get the number. */ void
mpn_tracen (constchar *name, int num, mp_srcptr ptr, mp_size_t size)
{ if (name != NULL && name[0] != '\0')
{
printf (name, num);
putchar ('=');
}
mpn_trace (NULL, ptr, size);
}
/* Print "namenum=value\n" to stdout for an array of mpn style ptr,size.
"a" is an array of pointers, each a[i] is a pointer to "size" many limbs. The formal parameter isn't mp_srcptr because that causes compiler warnings, but the values aren't modified.
"name" should have a printf style "%d" to get the array index. */
void
mpn_tracea (constchar *name, const mp_ptr *a, int count, mp_size_t size)
{ int i; for (i = 0; i < count; i++)
mpn_tracen (name, i, a[i], size);
}
/* Print "value\n" to a file for an mpz_t value. Any previous contents of the file are overwritten, so you need different file names each time this is called.
Overwriting the file is a feature, it means you get old data replaced
when you run a test program repeatedly. */
/* Print "value\n" to a set of files, one file for each element of the given array of mpn style ptr,size. Any previous contents of the files are overwritten, so you need different file names each time this is called. Each file is "filenameN" where N is 0 to count-1.
"a" is an array of pointers, each a[i] is a pointer to "size" many limbs. The formal parameter isn't mp_srcptr because that causes compiler warnings, but the values aren't modified.
Overwriting the files is a feature, it means you get old data replaced when you run a test program repeatedly. The output style isn't particularly pretty, but at least it gets something out, and you can cat
the files into bc, or whatever. */
void
mpn_tracea_file (constchar *filename, const mp_ptr *a, int count, mp_size_t size)
{ char *s; int i;
TMP_DECL;
TMP_MARK;
s = (char *) TMP_ALLOC (strlen (filename) + 50);
for (i = 0; i < count; i++)
{
sprintf (s, "%s%d", filename, i);
mpn_trace_file (s, a[i], size);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.