Polly 19.0.0git
Macros | Functions | Variables
imdrover.c File Reference
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "imath.h"
#include "imdrover.h"
#include "imrat.h"
#include "iprime.h"

Go to the source code of this file.

Macros

#define FAIL(E)   return (imath_errno = (E), false)
 
#define VCHECK(X, V)
 
#define CHECK(X)   VCHECK(X, MP_OK)
 
#define ECHECK(X)   VCHECK(X, expect)
 
#define ACHECK(X)
 
#define OUTPUT_LIMIT   2048
 
#define NUM_REGS   16
 
#define OTHER_ERROR   -1024
 

Functions

void trim_line (char *line)
 Removes leading and trailing whitespace from a zero-terminated line.
 
static mp_result read_int_value (mp_int z, char *str)
 
static mp_result read_rat_value (mp_rat q, char *str)
 
static bool read_long (long *z, char *str)
 
static bool parse_int_values (testspec_t *t, mp_int *in, mp_int *out, mp_result *rval)
 
static bool parse_rat_values (testspec_t *t, mp_rat *in, mp_rat *out, mp_result *rval)
 
static bool parse_result_code (char *str, mp_result *code)
 
static int parse_binary (char *str, unsigned char *buf, int limit)
 
static void done_testing (void)
 
void init_testing (void)
 
void reset_registers (void)
 
bool test_init (testspec_t *t, FILE *ofp)
 
bool test_set (testspec_t *t, FILE *ofp)
 
bool test_neg (testspec_t *t, FILE *ofp)
 
bool test_abs (testspec_t *t, FILE *ofp)
 
bool test_add (testspec_t *t, FILE *ofp)
 
bool test_sub (testspec_t *t, FILE *ofp)
 
bool test_mul (testspec_t *t, FILE *ofp)
 
bool test_mulp2 (testspec_t *t, FILE *ofp)
 
bool test_mulv (testspec_t *t, FILE *ofp)
 
bool test_sqr (testspec_t *t, FILE *ofp)
 
bool test_div (testspec_t *t, FILE *ofp)
 
bool test_divp2 (testspec_t *t, FILE *ofp)
 
bool test_divv (testspec_t *t, FILE *ofp)
 
bool test_expt (testspec_t *t, FILE *ofp)
 
bool test_exptv (testspec_t *t, FILE *ofp)
 
bool test_exptf (testspec_t *t, FILE *ofp)
 
bool test_mod (testspec_t *t, FILE *ofp)
 
bool test_gcd (testspec_t *t, FILE *ofp)
 
bool test_egcd (testspec_t *t, FILE *ofp)
 
bool test_lcm (testspec_t *t, FILE *ofp)
 
bool test_sqrt (testspec_t *t, FILE *ofp)
 
bool test_root (testspec_t *t, FILE *ofp)
 
bool test_invmod (testspec_t *t, FILE *ofp)
 
bool test_exptmod (testspec_t *t, FILE *ofp)
 
bool test_exptmod_ev (testspec_t *t, FILE *ofp)
 
bool test_exptmod_bv (testspec_t *t, FILE *ofp)
 
bool test_comp (testspec_t *t, FILE *ofp)
 
bool test_ucomp (testspec_t *t, FILE *ofp)
 
bool test_zcomp (testspec_t *t, FILE *ofp)
 
bool test_vcomp (testspec_t *t, FILE *ofp)
 
bool test_uvcomp (testspec_t *t, FILE *ofp)
 
bool test_tostr (testspec_t *t, FILE *ofp)
 
bool test_tobin (testspec_t *t, FILE *ofp)
 
bool test_to_int (testspec_t *t, FILE *ofp)
 
bool test_to_uint (testspec_t *t, FILE *ofp)
 
bool test_read_binary (testspec_t *t, FILE *ofp)
 
bool test_to_uns (testspec_t *t, FILE *ofp)
 
bool test_read_uns (testspec_t *t, FILE *ofp)
 
bool test_meta (testspec_t *t, FILE *ofp)
 
bool test_qneg (testspec_t *t, FILE *ofp)
 
bool test_qrecip (testspec_t *t, FILE *ofp)
 
bool test_qabs (testspec_t *t, FILE *ofp)
 
bool test_qadd (testspec_t *t, FILE *ofp)
 
bool test_qsub (testspec_t *t, FILE *ofp)
 
bool test_qmul (testspec_t *t, FILE *ofp)
 
bool test_qdiv (testspec_t *t, FILE *ofp)
 
bool test_qaddz (testspec_t *t, FILE *ofp)
 
bool test_qsubz (testspec_t *t, FILE *ofp)
 
bool test_qmulz (testspec_t *t, FILE *ofp)
 
bool test_qdivz (testspec_t *t, FILE *ofp)
 
bool test_qexpt (testspec_t *t, FILE *ofp)
 
bool test_qtostr (testspec_t *t, FILE *ofp)
 
bool test_qtodec (testspec_t *t, FILE *ofp)
 
bool test_qrdec (testspec_t *t, FILE *ofp)
 
bool test_is_prime (testspec_t *t, FILE *OFP)
 

Variables

mp_result imath_errno
 
char * imath_errmsg
 
static char g_output [OUTPUT_LIMIT]
 
static mpz_t g_zreg [NUM_REGS]
 
static mpq_t g_qreg [NUM_REGS]
 
static unsigned char g_bin1 [OUTPUT_LIMIT]
 
static unsigned char g_bin2 [OUTPUT_LIMIT]
 

Macro Definition Documentation

◆ ACHECK

#define ACHECK (   X)
Value:
do { \
if (!(X)) { \
FAIL(MP_BADARG); \
} \
} while (0)
static RegisterPass< ScopViewerWrapperPass > X("view-scops", "Polly - View Scops of function")
#define MP_BADARG
Definition: wrap.h:4

Definition at line 54 of file imdrover.c.

◆ CHECK

#define CHECK (   X)    VCHECK(X, MP_OK)

Definition at line 52 of file imdrover.c.

◆ ECHECK

#define ECHECK (   X)    VCHECK(X, expect)

Definition at line 53 of file imdrover.c.

◆ FAIL

#define FAIL (   E)    return (imath_errno = (E), false)

Definition at line 42 of file imdrover.c.

◆ NUM_REGS

#define NUM_REGS   16

Definition at line 62 of file imdrover.c.

◆ OTHER_ERROR

#define OTHER_ERROR   -1024

Definition at line 63 of file imdrover.c.

◆ OUTPUT_LIMIT

#define OUTPUT_LIMIT   2048

Definition at line 61 of file imdrover.c.

◆ VCHECK

#define VCHECK (   X,
 
)
Value:
do { \
mp_result res_; \
if ((res_ = (X)) != (V)) { \
FAIL(res_); \
} \
} while (0)
int mp_result
Definition: imath/imath.h:40

Definition at line 45 of file imdrover.c.

Function Documentation

◆ done_testing()

static void done_testing ( void  )
static

Definition at line 398 of file imdrover.c.

References g_qreg, g_zreg, mp_int_clear, mp_rat_clear, and NUM_REGS.

Referenced by init_testing().

◆ init_testing()

void init_testing ( void  )

Definition at line 411 of file imdrover.c.

References assert, done_testing(), g_output, g_qreg, g_zreg, imath_errmsg, mp_int_init, MP_OK, mp_rat_init, and NUM_REGS.

Referenced by main().

◆ parse_binary()

static int parse_binary ( char *  str,
unsigned char *  buf,
int  limit 
)
static

Definition at line 380 of file imdrover.c.

References pos(), read_long(), str, and trim_line().

Referenced by test_read_binary(), test_read_uns(), test_to_uns(), and test_tobin().

◆ parse_int_values()

static bool parse_int_values ( testspec_t t,
mp_int in,
mp_int out,
mp_result rval 
)
static

◆ parse_rat_values()

static bool parse_rat_values ( testspec_t t,
mp_rat in,
mp_rat out,
mp_result rval 
)
static

◆ parse_result_code()

static bool parse_result_code ( char *  str,
mp_result code 
)
static

◆ read_int_value()

static mp_result read_int_value ( mp_int  z,
char *  str 
)
static

Definition at line 103 of file imdrover.c.

References mp_int_read_string, MP_RANGE, and str.

Referenced by parse_int_values().

◆ read_long()

static bool read_long ( long *  z,
char *  str 
)
static

Definition at line 168 of file imdrover.c.

References str.

Referenced by parse_binary(), parse_result_code(), test_qrdec(), test_qtodec(), and test_qtostr().

◆ read_rat_value()

static mp_result read_rat_value ( mp_rat  q,
char *  str 
)
static

Definition at line 134 of file imdrover.c.

References MP_RANGE, mp_rat_read_decimal, mp_rat_read_string, and str.

Referenced by parse_rat_values().

◆ reset_registers()

void reset_registers ( void  )

Definition at line 427 of file imdrover.c.

References g_qreg, g_zreg, mp_int_zero, mp_rat_zero, and NUM_REGS.

◆ test_abs()

bool test_abs ( testspec_t t,
FILE *  ofp 
)

◆ test_add()

bool test_add ( testspec_t t,
FILE *  ofp 
)

◆ test_comp()

bool test_comp ( testspec_t t,
FILE *  ofp 
)

Definition at line 897 of file imdrover.c.

References ACHECK, FAIL, g_output, mp_int_compare, OTHER_ERROR, parse_int_values(), res, and t.

◆ test_div()

bool test_div ( testspec_t t,
FILE *  ofp 
)

◆ test_divp2()

bool test_divp2 ( testspec_t t,
FILE *  ofp 
)

◆ test_divv()

bool test_divv ( testspec_t t,
FILE *  ofp 
)

◆ test_egcd()

bool test_egcd ( testspec_t t,
FILE *  ofp 
)

◆ test_expt()

bool test_expt ( testspec_t t,
FILE *  ofp 
)

◆ test_exptf()

bool test_exptf ( testspec_t t,
FILE *  ofp 
)

◆ test_exptmod()

bool test_exptmod ( testspec_t t,
FILE *  ofp 
)

◆ test_exptmod_bv()

bool test_exptmod_bv ( testspec_t t,
FILE *  ofp 
)

◆ test_exptmod_ev()

bool test_exptmod_ev ( testspec_t t,
FILE *  ofp 
)

◆ test_exptv()

bool test_exptv ( testspec_t t,
FILE *  ofp 
)

◆ test_gcd()

bool test_gcd ( testspec_t t,
FILE *  ofp 
)

◆ test_init()

bool test_init ( testspec_t t,
FILE *  ofp 
)

◆ test_invmod()

bool test_invmod ( testspec_t t,
FILE *  ofp 
)

◆ test_is_prime()

bool test_is_prime ( testspec_t t,
FILE *  OFP 
)

Definition at line 1453 of file imdrover.c.

References ACHECK, ECHECK, mp_int_is_prime(), parse_int_values(), and t.

◆ test_lcm()

bool test_lcm ( testspec_t t,
FILE *  ofp 
)

◆ test_meta()

bool test_meta ( testspec_t t,
FILE *  ofp 
)

Definition at line 1121 of file imdrover.c.

References FAIL, g_output, MP_BADARG, mp_int_to_string, OUTPUT_LIMIT, parse_int_values(), and t.

◆ test_mod()

bool test_mod ( testspec_t t,
FILE *  ofp 
)

◆ test_mul()

bool test_mul ( testspec_t t,
FILE *  ofp 
)

◆ test_mulp2()

bool test_mulp2 ( testspec_t t,
FILE *  ofp 
)

◆ test_mulv()

bool test_mulv ( testspec_t t,
FILE *  ofp 
)

◆ test_neg()

bool test_neg ( testspec_t t,
FILE *  ofp 
)

◆ test_qabs()

bool test_qabs ( testspec_t t,
FILE *  ofp 
)

◆ test_qadd()

bool test_qadd ( testspec_t t,
FILE *  ofp 
)

◆ test_qaddz()

bool test_qaddz ( testspec_t t,
FILE *  ofp 
)

◆ test_qdiv()

bool test_qdiv ( testspec_t t,
FILE *  ofp 
)

◆ test_qdivz()

bool test_qdivz ( testspec_t t,
FILE *  ofp 
)

◆ test_qexpt()

bool test_qexpt ( testspec_t t,
FILE *  ofp 
)

◆ test_qmul()

bool test_qmul ( testspec_t t,
FILE *  ofp 
)

◆ test_qmulz()

bool test_qmulz ( testspec_t t,
FILE *  ofp 
)

◆ test_qneg()

bool test_qneg ( testspec_t t,
FILE *  ofp 
)

◆ test_qrdec()

bool test_qrdec ( testspec_t t,
FILE *  ofp 
)

◆ test_qrecip()

bool test_qrecip ( testspec_t t,
FILE *  ofp 
)

◆ test_qsub()

bool test_qsub ( testspec_t t,
FILE *  ofp 
)

◆ test_qsubz()

bool test_qsubz ( testspec_t t,
FILE *  ofp 
)

◆ test_qtodec()

bool test_qtodec ( testspec_t t,
FILE *  ofp 
)

◆ test_qtostr()

bool test_qtostr ( testspec_t t,
FILE *  ofp 
)

◆ test_read_binary()

bool test_read_binary ( testspec_t t,
FILE *  ofp 
)

◆ test_read_uns()

bool test_read_uns ( testspec_t t,
FILE *  ofp 
)

◆ test_root()

bool test_root ( testspec_t t,
FILE *  ofp 
)

◆ test_set()

bool test_set ( testspec_t t,
FILE *  ofp 
)

◆ test_sqr()

bool test_sqr ( testspec_t t,
FILE *  ofp 
)

◆ test_sqrt()

bool test_sqrt ( testspec_t t,
FILE *  ofp 
)

◆ test_sub()

bool test_sub ( testspec_t t,
FILE *  ofp 
)

◆ test_to_int()

bool test_to_int ( testspec_t t,
FILE *  ofp 
)

◆ test_to_uint()

bool test_to_uint ( testspec_t t,
FILE *  ofp 
)

◆ test_to_uns()

bool test_to_uns ( testspec_t t,
FILE *  ofp 
)

◆ test_tobin()

bool test_tobin ( testspec_t t,
FILE *  ofp 
)

◆ test_tostr()

bool test_tostr ( testspec_t t,
FILE *  ofp 
)

◆ test_ucomp()

bool test_ucomp ( testspec_t t,
FILE *  ofp 
)

Definition at line 911 of file imdrover.c.

References ACHECK, FAIL, g_output, mp_int_compare_unsigned, OTHER_ERROR, parse_int_values(), res, and t.

◆ test_uvcomp()

bool test_uvcomp ( testspec_t t,
FILE *  ofp 
)

Definition at line 955 of file imdrover.c.

References ACHECK, FAIL, g_output, mp_int_compare_uvalue, OTHER_ERROR, parse_int_values(), res, and t.

◆ test_vcomp()

bool test_vcomp ( testspec_t t,
FILE *  ofp 
)

Definition at line 939 of file imdrover.c.

References ACHECK, FAIL, g_output, mp_int_compare_value, OTHER_ERROR, parse_int_values(), res, and t.

◆ test_zcomp()

bool test_zcomp ( testspec_t t,
FILE *  ofp 
)

Definition at line 925 of file imdrover.c.

References ACHECK, FAIL, g_output, mp_int_compare_zero, OTHER_ERROR, parse_int_values(), res, and t.

◆ trim_line()

void trim_line ( char *  line)

Removes leading and trailing whitespace from a zero-terminated line.

Definition at line 260 of file imtest.c.

Referenced by parse_binary(), parse_int_values(), parse_rat_values(), read_line(), test_qrdec(), test_qtodec(), test_qtostr(), test_read_binary(), test_read_uns(), test_to_uns(), test_tobin(), and test_tostr().

Variable Documentation

◆ g_bin1

unsigned char g_bin1[OUTPUT_LIMIT]
static

Definition at line 68 of file imdrover.c.

Referenced by test_read_binary(), test_read_uns(), test_to_uns(), and test_tobin().

◆ g_bin2

unsigned char g_bin2[OUTPUT_LIMIT]
static

Definition at line 69 of file imdrover.c.

Referenced by test_to_uns(), and test_tobin().

◆ g_output

char g_output[OUTPUT_LIMIT]
static

◆ g_qreg

mpq_t g_qreg[NUM_REGS]
static

Definition at line 67 of file imdrover.c.

Referenced by done_testing(), init_testing(), parse_rat_values(), reset_registers(), and test_qrdec().

◆ g_zreg

mpz_t g_zreg[NUM_REGS]
static

◆ imath_errmsg

char* imath_errmsg

Definition at line 39 of file imdrover.c.

Referenced by init_testing(), and run_test().

◆ imath_errno

mp_result imath_errno

Definition at line 38 of file imdrover.c.

Referenced by run_test().