aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ecgen.c8
-rw-r--r--src/exhaustive/exhaustive.c5
-rw-r--r--src/exhaustive/exhaustive.h4
-rw-r--r--src/gen/seed.c1
-rw-r--r--src/invalid/invalid.c14
-rw-r--r--src/invalid/invalid_thread.c11
-rw-r--r--src/invalid/invalid_thread.h2
-rw-r--r--src/io/output.c8
-rw-r--r--src/misc/config.h12
-rw-r--r--src/misc/types.h4
10 files changed, 34 insertions, 35 deletions
diff --git a/src/ecgen.c b/src/ecgen.c
index 713ebbe..685d35f 100644
--- a/src/ecgen.c
+++ b/src/ecgen.c
@@ -24,12 +24,12 @@
* @copyright GPL v2.0
*/
#include <pari/pari.h>
-#include "misc/config.h"
#include "cm/cm.h"
#include "exhaustive/exhaustive.h"
#include "invalid/invalid.h"
#include "io/input.h"
#include "io/output.h"
+#include "misc/config.h"
#include "util/timeout.h"
const char *argp_program_version =
@@ -70,10 +70,10 @@ bool init(void) {
pari_ENDCATCH avma = ltop;
// open outfile
- if (!output_init(cfg)) return false;
+ if (!output_init()) return false;
// open infile
- if (!input_init(cfg)) return false;
+ if (!input_init()) return false;
return true;
}
@@ -137,7 +137,7 @@ int quit(int status) {
*/
int main(int argc, char *argv[]) {
// Parse cli args
- memset(cfg, 0, sizeof(cfg_s));
+ memset(cfg, 0, sizeof(config_t));
argp_parse(&argp, argc, argv, 0, 0, cfg);
if (!init()) {
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c
index 81ca834..5bfdffb 100644
--- a/src/exhaustive/exhaustive.c
+++ b/src/exhaustive/exhaustive.c
@@ -195,7 +195,8 @@ void exhaustive_uinit(unroll_f *unrolls) {
}
int exhaustive_gen_retry(curve_t *curve, const exhaustive_t *setup,
- offset_e start_offset, offset_e end_offset, int retry) {
+ offset_e start_offset, offset_e end_offset,
+ int retry) {
if (start_offset == end_offset) {
return 2;
}
@@ -291,7 +292,7 @@ int exhaustive_gen_retry(curve_t *curve, const exhaustive_t *setup,
}
int exhaustive_gen(curve_t *curve, const exhaustive_t *setup,
- offset_e start_offset, offset_e end_offset) {
+ offset_e start_offset, offset_e end_offset) {
return exhaustive_gen_retry(curve, setup, start_offset, end_offset, 0);
}
diff --git a/src/exhaustive/exhaustive.h b/src/exhaustive/exhaustive.h
index d212e64..720dab9 100644
--- a/src/exhaustive/exhaustive.h
+++ b/src/exhaustive/exhaustive.h
@@ -41,7 +41,7 @@ void exhaustive_uinit(unroll_f *unrolls);
* @return
*/
int exhaustive_gen_retry(curve_t *curve, const exhaustive_t *setup,
- offset_e start_offset, offset_e end_offset, int retry);
+ offset_e start_offset, offset_e end_offset, int retry);
/**
*
@@ -52,7 +52,7 @@ int exhaustive_gen_retry(curve_t *curve, const exhaustive_t *setup,
* @return
*/
int exhaustive_gen(curve_t *curve, const exhaustive_t *setup,
- offset_e start_offset, offset_e end_offset);
+ offset_e start_offset, offset_e end_offset);
/**
*
diff --git a/src/gen/seed.c b/src/gen/seed.c
index f349982..a13588e 100644
--- a/src/gen/seed.c
+++ b/src/gen/seed.c
@@ -4,7 +4,6 @@
*/
#include "seed.h"
-#include <misc/types.h>
#include "util/bits.h"
#include "util/memory.h"
diff --git a/src/invalid/invalid.c b/src/invalid/invalid.c
index e908aa4..4533020 100644
--- a/src/invalid/invalid.c
+++ b/src/invalid/invalid.c
@@ -92,8 +92,8 @@ static size_t invalid_primes(GEN order, pari_ulong **primes) {
}
static size_t invalid_curves_single(const curve_t *curve, pari_ulong *primes,
- size_t nprimes, curve_t **curves,
- exhaustive_t *setup) {
+ size_t nprimes, curve_t **curves,
+ exhaustive_t *setup) {
arg_t *invalid_argss[OFFSET_END] = {NULL};
exhaustive_t invalid_setup = {.generators = setup->generators,
.validators = setup->validators,
@@ -129,7 +129,8 @@ static size_t invalid_curves_single(const curve_t *curve, pari_ulong *primes,
if (total > 0) {
if (!exhaustive_gen_retry(invalid, setup, OFFSET_GENERATORS,
OFFSET_POINTS, 1)) {
- curve_unroll(invalid, avma, btop); // necessary to free the ellinit
+ curve_unroll(invalid, avma,
+ btop); // necessary to free the ellinit
avma = btop;
continue;
}
@@ -156,8 +157,7 @@ static size_t invalid_curves_single(const curve_t *curve, pari_ulong *primes,
* generate prime order points, this is expensive (order needs to be
* factorised, so only do it if we want the curve)
*/
- exhaustive_gen(invalid, &invalid_setup, OFFSET_POINTS,
- OFFSET_END);
+ exhaustive_gen(invalid, &invalid_setup, OFFSET_POINTS, OFFSET_END);
size_t count = 0;
for (size_t i = nprimes; i-- > 0;) {
@@ -209,8 +209,8 @@ static size_t invalid_curves_single(const curve_t *curve, pari_ulong *primes,
}
static size_t invalid_curves_threaded(const curve_t *curve, pari_ulong *primes,
- size_t nprimes, curve_t **curves,
- exhaustive_t *setup) {
+ size_t nprimes, curve_t **curves,
+ exhaustive_t *setup) {
pthread_t pthreads[cfg->threads];
thread_t threads[cfg->threads];
struct pari_thread pari_threads[cfg->threads];
diff --git a/src/invalid/invalid_thread.c b/src/invalid/invalid_thread.c
index 8967d31..255c61f 100644
--- a/src/invalid/invalid_thread.c
+++ b/src/invalid/invalid_thread.c
@@ -23,8 +23,7 @@ void *invalid_thread(void *arg) {
while (*thread->generated < thread->nprimes) {
pari_sp btop = avma;
- exhaustive_gen(invalid, thread->setup, OFFSET_B,
- OFFSET_GENERATORS);
+ exhaustive_gen(invalid, thread->setup, OFFSET_B, OFFSET_GENERATORS);
size_t ndivides = 0;
for (size_t i = thread->nprimes; i-- > 0;) {
if (dvdis(invalid->order, thread->primes[i])) {
@@ -34,8 +33,8 @@ void *invalid_thread(void *arg) {
}
if (ndivides > 0 &&
- exhaustive_gen_retry(invalid, &invalid_setup,
- OFFSET_GENERATORS, OFFSET_POINTS, 1)) {
+ exhaustive_gen_retry(invalid, &invalid_setup, OFFSET_GENERATORS,
+ OFFSET_POINTS, 1)) {
pthread_mutex_lock(thread->mutex_state);
size_t nfree = 0;
// can be up to ndivides, but also lower...
@@ -54,8 +53,8 @@ void *invalid_thread(void *arg) {
if (nfree > 0) {
arg_t prime_divisors = {primes, nprimes};
invalid_argss[OFFSET_POINTS] = &prime_divisors;
- exhaustive_gen(invalid, &invalid_setup,
- OFFSET_POINTS, OFFSET_END);
+ exhaustive_gen(invalid, &invalid_setup, OFFSET_POINTS,
+ OFFSET_END);
pthread_mutex_lock(thread->mutex_state);
size_t count = 0;
diff --git a/src/invalid/invalid_thread.h b/src/invalid/invalid_thread.h
index e93bbda..d05c29a 100644
--- a/src/invalid/invalid_thread.h
+++ b/src/invalid/invalid_thread.h
@@ -8,8 +8,8 @@
#ifndef ECGEN_INVALID_THREAD_H
#define ECGEN_INVALID_THREAD_H
-#include <exhaustive/exhaustive.h>
#include <pthread.h>
+#include "exhaustive/exhaustive.h"
#include "misc/types.h"
typedef enum { STATE_FREE, STATE_GENERATING, STATE_GENERATED } state_e;
diff --git a/src/io/output.c b/src/io/output.c
index 2b6358f..01332b2 100644
--- a/src/io/output.c
+++ b/src/io/output.c
@@ -250,9 +250,7 @@ char *output_sjson(curve_t *curve) {
return result;
}
-char *output_sjson_separator() {
- return output_malloc(",\n");
-}
+char *output_sjson_separator() { return output_malloc(",\n"); }
char *output_sjson_begin() { return output_malloc("[\n"); }
@@ -266,9 +264,7 @@ void output_f(FILE *out, curve_t *curve) {
}
}
-void output_o(curve_t *curve) {
- output_f(out, curve);
-}
+void output_o(curve_t *curve) { output_f(out, curve); }
void output_f_separator(FILE *out) {
char *s = output_s_separator();
diff --git a/src/misc/config.h b/src/misc/config.h
index 0a534ef..2ad6736 100644
--- a/src/misc/config.h
+++ b/src/misc/config.h
@@ -48,7 +48,8 @@ typedef struct {
bool random;
/** @brief Whether the curves should have prime order. */
bool prime;
- /** @brief Whether the curves should be generated as invalid, for some curve. */
+ /** @brief Whether the curves should be generated as invalid, for some
+ * curve. */
bool invalid;
/** @brief Whether the Complex Multiplication method should be used. */
bool cm;
@@ -65,7 +66,8 @@ typedef struct {
seed_e seed_algo;
/** @brief What seed to use, if any, to generate the curves. */
char *seed;
- /** @brief Whether the curves should be uniquely generated (one generator). */
+ /** @brief Whether the curves should be uniquely generated (one generator).
+ */
bool unique;
/** @brief What points to generate on the curves. */
struct points_s points;
@@ -74,11 +76,13 @@ typedef struct {
char *datadir;
/** @brief How much memory to allocate for the PARI stack. */
unsigned long memory;
- /** @brief How many threads to use, only useful for invalid generation(atm). */
+ /** @brief How many threads to use, only useful for invalid generation(atm).
+ */
unsigned long threads;
/** @brief How much memory to allocate for the PARI stack, per thread. */
unsigned long thread_memory;
- /** @brief How long of a timeout interval, if any, to give to parameter generation. */
+ /** @brief How long of a timeout interval, if any, to give to parameter
+ * generation. */
unsigned long timeout;
/** @brief What output format to use. */
diff --git a/src/misc/types.h b/src/misc/types.h
index 3cb3fd4..aecf207 100644
--- a/src/misc/types.h
+++ b/src/misc/types.h
@@ -118,7 +118,7 @@ typedef struct {
* @param state The current generation state
* @return state diff
*/
-#define GENERATOR(gen_name) \
+#define GENERATOR(gen_name) \
int gen_name(curve_t *curve, arg_t *args, offset_e state)
typedef GENERATOR((*gen_f));
@@ -130,7 +130,7 @@ typedef GENERATOR((*gen_f));
* @param to
* @return
*/
-#define UNROLL(unroll_name) \
+#define UNROLL(unroll_name) \
int unroll_name(curve_t *curve, pari_sp from, pari_sp to)
typedef UNROLL((*unroll_f));