diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-07-16 00:59:42 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-07-16 00:59:42 +0200 |
| commit | c216ac3049102422a41ba2c9476b0dbf4f3e4034 (patch) | |
| tree | 809793e1f01fafcb67422f654b6e9dbcab897660 /src/blind-dot-product.c | |
| parent | Install the scripts (diff) | |
| download | blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.gz blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.bz2 blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.xz | |
Use #include instead of #define
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-dot-product.c')
| -rw-r--r-- | src/blind-dot-product.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/blind-dot-product.c b/src/blind-dot-product.c index b9699c2..1d7053d 100644 --- a/src/blind-dot-product.c +++ b/src/blind-dot-product.c @@ -1,27 +1,11 @@ /* See LICENSE file for copyright and license details. */ +#ifndef TYPE #include "common.h" USAGE("right-hand-stream") -#define PROCESS(TYPE, SUFFIX)\ - static void\ - process_##SUFFIX(struct stream *left, struct stream *right, size_t n)\ - {\ - size_t i, j, s = left->n_chan * sizeof(TYPE);\ - TYPE v, *l, *r;\ - for (i = 0; i < n; i += s) {\ - l = (TYPE *)(left->buf + i);\ - r = (TYPE *)(right->buf + i);\ - v = 0;\ - for (j = 0; j < left->n_chan; j++)\ - v += l[j] * r[j];\ - for (j = 0; j < left->n_chan; j++)\ - l[j] = v;\ - }\ - } - -PROCESS(double, lf) -PROCESS(float, f) +#define FILE "blind-dot-product.c" +#include "define-functions.h" int main(int argc, char *argv[]) @@ -46,3 +30,23 @@ main(int argc, char *argv[]) process_two_streams(&left, &right, STDOUT_FILENO, "<stdout>", process); return 0; } + +#else + +static void +PROCESS(struct stream *left, struct stream *right, size_t n) +{ + size_t i, j, s = left->n_chan * sizeof(TYPE); + TYPE v, *l, *r; + for (i = 0; i < n; i += s) { + l = (TYPE *)(left->buf + i); + r = (TYPE *)(right->buf + i); + v = 0; + for (j = 0; j < left->n_chan; j++) + v += l[j] * r[j]; + for (j = 0; j < left->n_chan; j++) + l[j] = v; + } +} + +#endif |
