diff options
| author | J08nY | 2017-09-29 18:34:06 +0200 |
|---|---|---|
| committer | J08nY | 2017-09-29 18:34:06 +0200 |
| commit | 0c2b270e5e5934bb4426bc526e6d50d4e9720909 (patch) | |
| tree | 1f55cc2e4e886bb361067ca10068dd9c7fae8f34 /src | |
| parent | 73ae939ffee2c0fc027d9ac5d07b479d8e967a8c (diff) | |
| download | ecgen-0c2b270e5e5934bb4426bc526e6d50d4e9720909.tar.gz ecgen-0c2b270e5e5934bb4426bc526e6d50d4e9720909.tar.zst ecgen-0c2b270e5e5934bb4426bc526e6d50d4e9720909.zip | |
Introduce HAS_ARG(args) macro.
Diffstat (limited to 'src')
| -rw-r--r-- | src/exhaustive/anomalous.c | 10 | ||||
| -rw-r--r-- | src/exhaustive/arg.h | 6 | ||||
| -rw-r--r-- | src/exhaustive/exhaustive.c | 5 | ||||
| -rw-r--r-- | src/gen/gens.c | 4 | ||||
| -rw-r--r-- | src/gen/order.c | 7 | ||||
| -rw-r--r-- | src/gen/point.c | 11 | ||||
| -rw-r--r-- | src/misc/types.h | 3 |
7 files changed, 16 insertions, 30 deletions
diff --git a/src/exhaustive/anomalous.c b/src/exhaustive/anomalous.c index eeda573..a0d03d3 100644 --- a/src/exhaustive/anomalous.c +++ b/src/exhaustive/anomalous.c @@ -89,10 +89,7 @@ static GEN anomalous_c(size_t i, GEN p) { } GENERATOR(anomalous_gen_field) { - if (!args) { - fprintf(err, "No args to an arged function. anomalous_field\n"); - return INT_MIN; - } + HAS_ARG(args); size_t i = *(size_t *)args->args; // find suitable prime field @@ -108,10 +105,7 @@ GENERATOR(anomalous_gen_field) { } GENERATOR(anomalous_gen_equation) { - if (!args) { - fprintf(err, "No args to an arged function. anomalous_gen_equation\n"); - return INT_MIN; - } + HAS_ARG(args); size_t i = *(size_t *)args->args; pari_sp ltop = avma; diff --git a/src/exhaustive/arg.h b/src/exhaustive/arg.h index 415008c..0b10715 100644 --- a/src/exhaustive/arg.h +++ b/src/exhaustive/arg.h @@ -10,6 +10,12 @@ #include "misc/types.h" +#define HAS_ARG(args) \ + if (!(args)) { \ + fprintf(err, "No args to an arged function. %s\n", __func__); \ + return INT_MIN; \ + } + /** * @brief * @return diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index 12ccd6e..3e39a82 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -123,10 +123,7 @@ static void exhaustive_ginit(gen_f *generators, const config_t *cfg) { } } -static void exhaustive_cinit(check_t **validators, const config_t *cfg) { - - -} +static void exhaustive_cinit(check_t **validators, const config_t *cfg) {} static void exhaustive_ainit(arg_t **argss, const config_t *cfg) { if (cfg->anomalous) { diff --git a/src/gen/gens.c b/src/gen/gens.c index f5336df..11f6611 100644 --- a/src/gen/gens.c +++ b/src/gen/gens.c @@ -37,9 +37,7 @@ GENERATOR(gens_gen_one) { return gens_put(curve, generators, len); } -CHECK(gens_check_cofactor) { - return INT_MIN; -} +CHECK(gens_check_cofactor) { return INT_MIN; } UNROLL(gens_unroll) { if (curve->generators) { diff --git a/src/gen/order.c b/src/gen/order.c index 891c95b..2e20294 100644 --- a/src/gen/order.c +++ b/src/gen/order.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 J08nY */ #include "order.h" +#include "exhaustive/arg.h" #include "io/input.h" #include "io/output.h" @@ -43,11 +44,7 @@ GENERATOR(order_gen_sea) { } GENERATOR(order_gen_smallfact) { - if (!args) { - fprintf(err, "No args to an arged function. order_gen_smallfact\n"); - return INT_MIN; - } - + HAS_ARG(args); pari_ulong smallfact = *(pari_ulong *)args->args; pari_sp ltop = avma; GEN fact = mpfact(smallfact); diff --git a/src/gen/point.c b/src/gen/point.c index 11561fb..61ca7e1 100644 --- a/src/gen/point.c +++ b/src/gen/point.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 J08nY */ #include "point.h" +#include "exhaustive/arg.h" #include "io/output.h" #include "math/subgroups.h" #include "util/memory.h" @@ -103,10 +104,7 @@ GENERATOR(point_gen_random) { } GENERATOR(points_gen_random) { - if (!args) { - fprintf(err, "No args to an arged function. points_gen_random\n"); - return INT_MIN; - } + HAS_ARG(args); size_t npoints = *(size_t *)args->args; @@ -160,10 +158,7 @@ static int points_from_orders(curve_t *curve, GEN orders) { } GENERATOR(points_gen_trial) { - if (!args) { - fprintf(err, "No args to an arged function. points_gen_trial\n"); - return INT_MIN; - } + HAS_ARG(args); pari_ulong *primes = (pari_ulong *)args->args; size_t nprimes = args->nargs; diff --git a/src/misc/types.h b/src/misc/types.h index 958ab63..103cf8a 100644 --- a/src/misc/types.h +++ b/src/misc/types.h @@ -144,8 +144,7 @@ typedef UNROLL((*unroll_f)); * @param args Current optional generator argument * @return state diff */ -#define CHECK(check_name) \ - GENERATOR(check_name) +#define CHECK(check_name) GENERATOR(check_name) typedef CHECK((*check_f)); |
