diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-04-09 17:33:31 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-04-09 17:57:27 +0200 |
| commit | deec79ce61b8661d3ad76f3ecc10a80d1ce19cdd (patch) | |
| tree | 34a8863335a8eee38ec28419812e99a3c27cef64 /src/blind-arithm.c | |
| parent | Add blind-skip-pattern (diff) | |
| download | blind-deec79ce61b8661d3ad76f3ecc10a80d1ce19cdd.tar.gz blind-deec79ce61b8661d3ad76f3ecc10a80d1ce19cdd.tar.bz2 blind-deec79ce61b8661d3ad76f3ecc10a80d1ce19cdd.tar.xz | |
Clean up
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-arithm.c')
| -rw-r--r-- | src/blind-arithm.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/blind-arithm.c b/src/blind-arithm.c index bc30bee..613783e 100644 --- a/src/blind-arithm.c +++ b/src/blind-arithm.c @@ -25,34 +25,23 @@ typedef void (*process_func)(struct stream *left, struct stream *right, size_t n X(div, *lh /= rh)\ X(exp, *lh = pow(*lh, rh))\ X(log, *lh = log(*lh) / log(rh))\ - X(min, *lh = *lh < rh ? *lh : rh)\ - X(max, *lh = *lh > rh ? *lh : rh)\ + X(min, *lh = MIN(*lh, rh))\ + X(max, *lh = MAX(*lh, rh))\ X(abs, *lh = fabs(*lh - rh) + rh) +#define C(CH, CHI, ALGO)\ + (!skip_##CH ? ((lh = ((double *)(left->buf + i)) + (CHI),\ + rh = ((double *)(right->buf + i))[CHI],\ + (ALGO)), 0) : 0) + #define X(NAME, ALGO)\ static void\ process_lf_##NAME(struct stream *left, struct stream *right, size_t n)\ {\ size_t i;\ double *lh, rh;\ - for (i = 0; i < n; i += 4 * sizeof(double)) {\ - if (!skip_x) {\ - lh = ((double *)(left->buf + i)) + 0, rh = ((double *)(right->buf + i))[0];\ - ALGO;\ - }\ - if (!skip_y) {\ - lh = ((double *)(left->buf + i)) + 1, rh = ((double *)(right->buf + i))[1];\ - ALGO;\ - }\ - if (!skip_z) {\ - lh = ((double *)(left->buf + i)) + 2, rh = ((double *)(right->buf + i))[2];\ - ALGO;\ - }\ - if (!skip_a) {\ - lh = ((double *)(left->buf + i)) + 3, rh = ((double *)(right->buf + i))[3];\ - ALGO;\ - }\ - }\ + for (i = 0; i < n; i += 4 * sizeof(double))\ + C(x, 0, ALGO), C(y, 1, ALGO), C(z, 2, ALGO), C(a, 3, ALGO);\ } LIST_OPERATORS #undef X |
