diff options
| author | J08nY | 2017-06-01 01:46:25 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-01 01:46:25 +0200 |
| commit | 261e0ce6530387db48a07c3f8925dd67e63c28bf (patch) | |
| tree | 6f41122a982f13a0ba828d7ade2b8af326546ae3 /src | |
| parent | 63427ed3415b25bd29c5e1fe71ef9883d955bfcf (diff) | |
| download | ecgen-261e0ce6530387db48a07c3f8925dd67e63c28bf.tar.gz ecgen-261e0ce6530387db48a07c3f8925dd67e63c28bf.tar.zst ecgen-261e0ce6530387db48a07c3f8925dd67e63c28bf.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/exhaustive/anomalous.c | 9 | ||||
| -rw-r--r-- | src/exhaustive/anomalous.h | 8 | ||||
| -rw-r--r-- | src/exhaustive/exhaustive.c | 14 | ||||
| -rw-r--r-- | src/gen/equation.c | 2 | ||||
| -rw-r--r-- | src/gen/seed.c | 8 | ||||
| -rw-r--r-- | src/gen/seed.h | 30 | ||||
| -rw-r--r-- | src/gen/types.c | 6 | ||||
| -rw-r--r-- | src/gen/types.h | 4 | ||||
| -rw-r--r-- | src/invalid/invalid.c | 4 | ||||
| -rw-r--r-- | src/invalid/invalid_thread.c | 2 | ||||
| -rw-r--r-- | src/io/input.h | 2 | ||||
| -rw-r--r-- | src/io/output.h | 2 |
12 files changed, 45 insertions, 46 deletions
diff --git a/src/exhaustive/anomalous.c b/src/exhaustive/anomalous.c index 89cc89c..507d8ca 100644 --- a/src/exhaustive/anomalous.c +++ b/src/exhaustive/anomalous.c @@ -87,7 +87,7 @@ static GEN anomalous_c(size_t i, GEN p) { return gerepilecopy(ltop, c); } -int anomalous_field(curve_t *curve, const config_t *cfg, arg_t *args) { +GENERATOR(anomalous_gen_field) { if (!args) { fprintf(stderr, "No args to an arged function. anomalous_field\n"); return INT_MIN; @@ -106,9 +106,10 @@ int anomalous_field(curve_t *curve, const config_t *cfg, arg_t *args) { return 1; } -int anomalous_equation(curve_t *curve, const config_t *cfg, arg_t *args) { +GENERATOR(anomalous_gen_equation) { if (!args) { - fprintf(stderr, "No args to an arged function. anomalous_equation\n"); + fprintf(stderr, + "No args to an arged function. anomalous_gen_equation\n"); return INT_MIN; } size_t i = *(size_t *)args->args; @@ -126,7 +127,7 @@ int anomalous_equation(curve_t *curve, const config_t *cfg, arg_t *args) { return 1; } -int anomalous_order(curve_t *curve, const config_t *cfg, arg_t *args) { +GENERATOR(anomalous_gen_order) { // copy field to order curve->order = gcopy(curve->field); obj_insert(curve->curve, 1, curve->order); diff --git a/src/exhaustive/anomalous.h b/src/exhaustive/anomalous.h index 9111919..ff6c053 100644 --- a/src/exhaustive/anomalous.h +++ b/src/exhaustive/anomalous.h @@ -9,9 +9,9 @@ #define ECGEN_ANOMALOUS_H #include <pari/pari.h> -#include "io/cli.h" #include "arg.h" #include "gen/types.h" +#include "io/cli.h" typedef struct disc_t { GEN d; @@ -27,7 +27,7 @@ typedef struct disc_t { * @param args the index of the discriminant to use, in the disc_table * @return state diff */ -int anomalous_field(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(anomalous_gen_field); /** * GENERATOR(gen_t) @@ -37,7 +37,7 @@ int anomalous_field(curve_t *curve, const config_t *cfg, arg_t *args); * @param args the index of the discriminant to use, in the disc_table * @return state diff */ -int anomalous_equation(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(anomalous_gen_equation); /** * GENERATOR(gen_t) @@ -47,7 +47,7 @@ int anomalous_equation(curve_t *curve, const config_t *cfg, arg_t *args); * @param args unused * @return state diff */ -int anomalous_order(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(anomalous_gen_order); /** * @brief Initialize anomalous generation, allocate and set the disc_table. diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index 5c50a71..d9b9a6a 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -4,7 +4,6 @@ */ #include "exhaustive.h" #include "anomalous.h" -#include "io/output.h" #include "gen/curve.h" #include "gen/equation.h" #include "gen/field.h" @@ -12,18 +11,19 @@ #include "gen/order.h" #include "gen/point.h" #include "gen/seed.h" +#include "io/output.h" #include "util/memory.h" static void exhaustive_ginit(gen_t *generators, const config_t *cfg) { if (cfg->from_seed) { // setup ANSI X9.62 generators if (cfg->seed) { - generators[OFFSET_SEED] = &seed_argument; + generators[OFFSET_SEED] = &seed_gen_argument; } else { if (cfg->random) { - generators[OFFSET_SEED] = &seed_random; + generators[OFFSET_SEED] = &seed_gen_random; } else { - generators[OFFSET_SEED] = &seed_input; + generators[OFFSET_SEED] = &seed_gen_input; } } generators[OFFSET_A] = &a_gen_seed; @@ -35,7 +35,7 @@ static void exhaustive_ginit(gen_t *generators, const config_t *cfg) { if (cfg->anomalous) { generators[OFFSET_A] = &gen_skip; - generators[OFFSET_B] = &anomalous_equation; + generators[OFFSET_B] = &anomalous_gen_equation; } else if (cfg->random) { generators[OFFSET_A] = &a_gen_random; generators[OFFSET_B] = &b_gen_random; @@ -55,7 +55,7 @@ static void exhaustive_ginit(gen_t *generators, const config_t *cfg) { } else if (cfg->cofactor) { generators[OFFSET_ORDER] = &order_gen_smallfact; } else if (cfg->anomalous) { - generators[OFFSET_ORDER] = &anomalous_order; + generators[OFFSET_ORDER] = &anomalous_gen_order; } else { generators[OFFSET_ORDER] = &order_gen_any; } @@ -69,7 +69,7 @@ static void exhaustive_ginit(gen_t *generators, const config_t *cfg) { } if (cfg->anomalous) { - generators[OFFSET_FIELD] = &anomalous_field; + generators[OFFSET_FIELD] = &anomalous_gen_field; } else if (cfg->random) { generators[OFFSET_FIELD] = &field_gen_random; } else { diff --git a/src/gen/equation.c b/src/gen/equation.c index 14409b4..7c90ab7 100644 --- a/src/gen/equation.c +++ b/src/gen/equation.c @@ -3,8 +3,8 @@ * Copyright (C) 2017 J08nY */ #include "equation.h" -#include "io/input.h" #include "field.h" +#include "io/input.h" GENERATOR(a_gen_random) { curve->a = genrand(curve->field); diff --git a/src/gen/seed.c b/src/gen/seed.c index 44663c8..f26a9a2 100644 --- a/src/gen/seed.c +++ b/src/gen/seed.c @@ -54,7 +54,7 @@ static GEN seed_stoi(const char *cstr) { return gerepilecopy(ltop, seed); } -char *seed_itos(GEN seed) { +static char *seed_itos(GEN seed) { pari_sp ltop = avma; GEN bits = binary_zv(seed); @@ -69,7 +69,7 @@ char *seed_itos(GEN seed) { return result; } -int seed_random(curve_t *curve, const config_t *cfg, arg_t *args) { +GENERATOR(seed_gen_random) { curve->seed = seed_new(); curve->seed->seed = random_int(160); curve->seed->raw = seed_itos(curve->seed->seed); @@ -77,7 +77,7 @@ int seed_random(curve_t *curve, const config_t *cfg, arg_t *args) { return 1; } -int seed_argument(curve_t *curve, const config_t *cfg, arg_t *args) { +GENERATOR(seed_gen_argument) { curve->seed = seed_new(); curve->seed->seed = seed_stoi(cfg->seed); curve->seed->raw = cfg->seed; @@ -85,7 +85,7 @@ int seed_argument(curve_t *curve, const config_t *cfg, arg_t *args) { return 1; } -int seed_input(curve_t *curve, const config_t *cfg, arg_t *args) { +GENERATOR(seed_gen_input) { pari_sp ltop = avma; GEN str = input_string("seed:"); diff --git a/src/gen/seed.h b/src/gen/seed.h index e4b7ac0..82eb499 100644 --- a/src/gen/seed.h +++ b/src/gen/seed.h @@ -55,29 +55,29 @@ void seed_free(seed_t **seed); /** * - * @param curve - * @param config - * @param args - * @return + * @param curve A curve_t being generated + * @param cfg An application config + * @param args unused + * @return state diff */ -int seed_random(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(seed_gen_random); /** * - * @param curve - * @param config - * @param args - * @return + * @param curve A curve_t being generated + * @param cfg An application config + * @param args unused + * @return state diff */ -int seed_argument(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(seed_gen_argument); /** * - * @param curve - * @param config - * @param args - * @return + * @param curve A curve_t being generated + * @param cfg An application config + * @param args unused + * @return state diff */ -int seed_input(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(seed_gen_input); #endif // ECGEN_SEED_H diff --git a/src/gen/types.c b/src/gen/types.c index afd6542..63d5401 100644 --- a/src/gen/types.c +++ b/src/gen/types.c @@ -4,8 +4,6 @@ */ #include "types.h" -int gen_skip(curve_t *curve, const config_t *cfg, arg_t *args) { return 1; } +GENERATOR(gen_skip) { return 1; } -int unroll_skip(curve_t *curve, const config_t *cfg, pari_sp from, pari_sp to) { - return -1; -} +UNROLL(unroll_skip) { return -1; } diff --git a/src/gen/types.h b/src/gen/types.h index a6494cf..5500e85 100644 --- a/src/gen/types.h +++ b/src/gen/types.h @@ -116,7 +116,7 @@ typedef UNROLL((*unroll_t)); * @param args unused * @return state diff */ -int gen_skip(curve_t *curve, const config_t *cfg, arg_t *args); +GENERATOR(gen_skip); /** * UNROLL(unroll_t) @@ -127,6 +127,6 @@ int gen_skip(curve_t *curve, const config_t *cfg, arg_t *args); * @param to * @return */ -int unroll_skip(curve_t *curve, const config_t *cfg, pari_sp from, pari_sp to); +UNROLL(unroll_skip); #endif // ECGEN_TYPES_H diff --git a/src/invalid/invalid.c b/src/invalid/invalid.c index 00daf24..1d51a15 100644 --- a/src/invalid/invalid.c +++ b/src/invalid/invalid.c @@ -4,14 +4,14 @@ */ #include "invalid.h" #include "exhaustive/exhaustive.h" -#include "invalid_thread.h" -#include "io/output.h" #include "gen/curve.h" #include "gen/equation.h" #include "gen/field.h" #include "gen/gens.h" #include "gen/order.h" #include "gen/point.h" +#include "invalid_thread.h" +#include "io/output.h" #include "util/memory.h" static void invalid_original_ginit(gen_t *generators, const config_t *cfg) { diff --git a/src/invalid/invalid_thread.c b/src/invalid/invalid_thread.c index 3d86b47..b94e456 100644 --- a/src/invalid/invalid_thread.c +++ b/src/invalid/invalid_thread.c @@ -5,8 +5,8 @@ #include "invalid_thread.h" #include "exhaustive/exhaustive.h" -#include "io/output.h" #include "gen/curve.h" +#include "io/output.h" #include "util/random.h" void *invalid_thread(void *arg) { diff --git a/src/io/input.h b/src/io/input.h index 5db3964..2759973 100644 --- a/src/io/input.h +++ b/src/io/input.h @@ -8,8 +8,8 @@ #ifndef ECGEN_INPUT_H #define ECGEN_INPUT_H -#include "util/random.h" #include "gen/types.h" +#include "util/random.h" /** * diff --git a/src/io/output.h b/src/io/output.h index 5c098e1..459834d 100644 --- a/src/io/output.h +++ b/src/io/output.h @@ -33,7 +33,7 @@ #define debug_log_end(...) \ do { \ - fprintf(verbose, "[ ] %lu ", time(NULL)); \ + fprintf(verbose, "[*] %lu ", time(NULL)); \ debug(__VA_ARGS__); \ fprintf(verbose, "\n"); \ } while (0) |
