Changeset c739102 in mainline for uspace/app/tester/float/softfloat1.c


Ignore:
Timestamp:
2012-11-21T23:26:22Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0f2c80a
Parents:
bebf97d (diff), 1f7753a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/float/softfloat1.c

    rbebf97d rc739102  
    3434#include <mul.h>
    3535#include <div.h>
     36#include <comparison.h>
    3637#include <bool.h>
    3738#include "../tester.h"
     
    4546typedef void (* float_op_t)(float, float, float *, float_t *);
    4647typedef void (* double_op_t)(double, double, double *, double_t *);
     48typedef void (* double_cmp_op_t)(double, double, cmptype_t *, cmptype_t *);
    4749typedef void (* template_t)(void *, unsigned, unsigned, cmptype_t *,
    4850    cmptype_t *);
     
    6668       
    6769        return -a;
     70}
     71
     72static int dcmp(double a, double b)
     73{
     74        if (a < b)
     75                return -1;
     76        else if (a > b)
     77                return 1;
     78
     79        return 0;
    6880}
    6981
     
    96108        *pic = (cmptype_t) (c * PRECISION);
    97109        *pisc = (cmptype_t) (sc.val * PRECISION);
     110}
     111
     112static void
     113double_compare_template(void *f, unsigned i, unsigned j, cmptype_t *pis,
     114    cmptype_t *piss)
     115{
     116        double_cmp_op_t op = (double_cmp_op_t) f;
     117       
     118        op(dop_a[i], dop_b[j], pis, piss);
    98119}
    99120
     
    221242}
    222243
     244static void
     245double_cmp_operator(double a, double b, cmptype_t *pis, cmptype_t *piss)
     246{
     247        *pis = dcmp(a, b);
     248
     249        double_t sa;
     250        double_t sb;
     251
     252        sa.val = a;
     253        sb.val = b;
     254
     255        if (is_double_lt(sa.data, sb.data))
     256                *piss = -1;
     257        else if (is_double_gt(sa.data, sb.data))
     258                *piss = 1;
     259        else if (is_double_eq(sa.data, sb.data))
     260                *piss = 0;
     261        else
     262                *piss = 42;
     263}
     264
    223265const char *test_softfloat1(void)
    224266{
     
    249291                TPRINTF("%s\n", err);
    250292        }
     293        if (!test_template(double_compare_template, double_cmp_operator)) {
     294                err = "Double comparison failed";
     295                TPRINTF("%s\n", err);
     296        }
    251297       
    252298        return err;
Note: See TracChangeset for help on using the changeset viewer.