YoushouldhavereceivedacopyoftheGNUGeneralPublicLicensealongwith
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 perhapsnotalwayssinceitmightupsetcuttingandpastingintobcor
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. Setthisinmain()orwiththedebugger. IfhexadecimalisgoingtobefedintoGNUbc,remembertouse-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.
/* Print "value\n" to a set of files, one file for each element of the given arrayofmpnstyleptr,size.Anypreviouscontentsofthefilesare overwritten,soyouneeddifferentfilenameseachtimethisiscalled. Eachfileis"filenameN"whereNis0tocount-1.
Overwritingthefilesisafeature,itmeansyougetolddatareplaced whenyourunatestprogramrepeatedly.Theoutputstyleisn't particularlypretty,butatleastitgetssomethingout,andyoucancat
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 und die Messung sind noch experimentell.