From 3bfaf74033cc770006b1e18c941ac83a5bfe1f8f Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 1 Feb 2018 01:53:00 +0100 Subject: [PATCH] protect include of c-files the way it was before, pre_gen/mpi.c couldn't be built --- gen.pl | 1 + src/generators/comba_mult_gen.c | 2 ++ src/generators/comba_mult_smallgen.c | 2 ++ src/generators/comba_sqr_gen.c | 2 ++ src/generators/comba_sqr_smallgen.c | 2 ++ src/mul/fp_mul_comba_12.c | 2 ++ src/mul/fp_mul_comba_17.c | 2 ++ src/mul/fp_mul_comba_20.c | 2 ++ src/mul/fp_mul_comba_24.c | 2 ++ src/mul/fp_mul_comba_28.c | 2 ++ src/mul/fp_mul_comba_3.c | 2 ++ src/mul/fp_mul_comba_32.c | 2 ++ src/mul/fp_mul_comba_4.c | 2 ++ src/mul/fp_mul_comba_48.c | 2 ++ src/mul/fp_mul_comba_6.c | 2 ++ src/mul/fp_mul_comba_64.c | 2 ++ src/mul/fp_mul_comba_7.c | 2 ++ src/mul/fp_mul_comba_8.c | 2 ++ src/mul/fp_mul_comba_9.c | 2 ++ src/mul/fp_mul_comba_small_set.c | 2 ++ src/sqr/fp_sqr_comba_12.c | 2 ++ src/sqr/fp_sqr_comba_17.c | 2 ++ src/sqr/fp_sqr_comba_20.c | 2 ++ src/sqr/fp_sqr_comba_24.c | 2 ++ src/sqr/fp_sqr_comba_28.c | 2 ++ src/sqr/fp_sqr_comba_3.c | 2 ++ src/sqr/fp_sqr_comba_32.c | 2 ++ src/sqr/fp_sqr_comba_4.c | 2 ++ src/sqr/fp_sqr_comba_48.c | 2 ++ src/sqr/fp_sqr_comba_6.c | 2 ++ src/sqr/fp_sqr_comba_64.c | 2 ++ src/sqr/fp_sqr_comba_7.c | 2 ++ src/sqr/fp_sqr_comba_8.c | 2 ++ src/sqr/fp_sqr_comba_9.c | 2 ++ src/sqr/fp_sqr_comba_generic.c | 2 ++ src/sqr/fp_sqr_comba_small_set.c | 2 ++ 36 files changed, 71 insertions(+) diff --git a/gen.pl b/gen.pl index 488f8cb..d0566fa 100644 --- a/gen.pl +++ b/gen.pl @@ -6,6 +6,7 @@ use strict; open( OUT, ">mpi.c" ) or die "Couldn't open mpi.c for writing: $!"; +print OUT "#define TFM_PRE_GEN_MPI_C\n"; foreach my $filename (glob "src/*/*fp_*.c") { next if ($filename eq "fp_sqr_comba_generic.c"); open( SRC, "<$filename" ) or die "Couldn't open $filename for reading: $!"; diff --git a/src/generators/comba_mult_gen.c b/src/generators/comba_mult_gen.c index 30fe7b2..f33ca0c 100644 --- a/src/generators/comba_mult_gen.c +++ b/src/generators/comba_mult_gen.c @@ -19,8 +19,10 @@ int main(int argc, char **argv) /* print out preamble */ printf( +"#ifndef TFM_PRE_GEN_MPI_C\n" "#define TFM_DEFINES\n" "#include \"fp_mul_comba.c\"\n" +"#endif\n" "\n" "#if defined(TFM_MUL%d) && FP_SIZE >= %d\n" "void fp_mul_comba%d(fp_int *A, fp_int *B, fp_int *C)\n" diff --git a/src/generators/comba_mult_smallgen.c b/src/generators/comba_mult_smallgen.c index db9fddb..4153516 100644 --- a/src/generators/comba_mult_smallgen.c +++ b/src/generators/comba_mult_smallgen.c @@ -7,8 +7,10 @@ int main(int argc, char **argv) /* print out preamble */ printf( +"#ifndef TFM_PRE_GEN_MPI_C\n" "#define TFM_DEFINES\n" "#include \"fp_mul_comba.c\"\n" +"#endif\n" "\n" "#if defined(TFM_SMALL_SET)\n" "void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C)\n" diff --git a/src/generators/comba_sqr_gen.c b/src/generators/comba_sqr_gen.c index 8ebe650..ab2dca0 100644 --- a/src/generators/comba_sqr_gen.c +++ b/src/generators/comba_sqr_gen.c @@ -17,8 +17,10 @@ int main(int argc, char **argv) N = atoi(argv[1]); printf( +"#ifndef TFM_PRE_GEN_MPI_C\n" "#define TFM_DEFINES\n" "#include \"fp_sqr_comba.c\"\n" +"#endif\n" "\n" "#if defined(TFM_SQR%d) && FP_SIZE >= %d\n" "void fp_sqr_comba%d(fp_int *A, fp_int *B)\n" diff --git a/src/generators/comba_sqr_smallgen.c b/src/generators/comba_sqr_smallgen.c index f5dc3e5..9c9e02f 100644 --- a/src/generators/comba_sqr_smallgen.c +++ b/src/generators/comba_sqr_smallgen.c @@ -16,8 +16,10 @@ int main(int argc, char **argv) int x, y, z, N, f; printf( +"#ifndef TFM_PRE_GEN_MPI_C\n" "#define TFM_DEFINES\n" "#include \"fp_sqr_comba.c\"\n" +"#endif\n" "\n" "#if defined(TFM_SMALL_SET)\n" "void fp_sqr_comba_small(fp_int *A, fp_int *B)\n" diff --git a/src/mul/fp_mul_comba_12.c b/src/mul/fp_mul_comba_12.c index 95346c7..a547d5a 100644 --- a/src/mul/fp_mul_comba_12.c +++ b/src/mul/fp_mul_comba_12.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL12) && FP_SIZE >= 24 void fp_mul_comba12(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_17.c b/src/mul/fp_mul_comba_17.c index 8bc360c..820032f 100644 --- a/src/mul/fp_mul_comba_17.c +++ b/src/mul/fp_mul_comba_17.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL17) && FP_SIZE >= 34 void fp_mul_comba17(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_20.c b/src/mul/fp_mul_comba_20.c index 905741d..c2e2c0a 100644 --- a/src/mul/fp_mul_comba_20.c +++ b/src/mul/fp_mul_comba_20.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL20) && FP_SIZE >= 40 void fp_mul_comba20(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_24.c b/src/mul/fp_mul_comba_24.c index 0aaccad..8243284 100644 --- a/src/mul/fp_mul_comba_24.c +++ b/src/mul/fp_mul_comba_24.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL24) && FP_SIZE >= 48 void fp_mul_comba24(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_28.c b/src/mul/fp_mul_comba_28.c index d72c08e..ffd58f9 100644 --- a/src/mul/fp_mul_comba_28.c +++ b/src/mul/fp_mul_comba_28.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL28) && FP_SIZE >= 56 void fp_mul_comba28(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_3.c b/src/mul/fp_mul_comba_3.c index 0e0cea1..9bfb347 100644 --- a/src/mul/fp_mul_comba_3.c +++ b/src/mul/fp_mul_comba_3.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL3) && FP_SIZE >= 6 void fp_mul_comba3(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_32.c b/src/mul/fp_mul_comba_32.c index f8c304e..30fb24d 100644 --- a/src/mul/fp_mul_comba_32.c +++ b/src/mul/fp_mul_comba_32.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL32) && FP_SIZE >= 64 void fp_mul_comba32(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_4.c b/src/mul/fp_mul_comba_4.c index 7a3769e..980423f 100644 --- a/src/mul/fp_mul_comba_4.c +++ b/src/mul/fp_mul_comba_4.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL4) && FP_SIZE >= 8 void fp_mul_comba4(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_48.c b/src/mul/fp_mul_comba_48.c index 2d87b02..34cd66d 100644 --- a/src/mul/fp_mul_comba_48.c +++ b/src/mul/fp_mul_comba_48.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL48) && FP_SIZE >= 96 void fp_mul_comba48(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_6.c b/src/mul/fp_mul_comba_6.c index d337be2..22afe33 100644 --- a/src/mul/fp_mul_comba_6.c +++ b/src/mul/fp_mul_comba_6.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL6) && FP_SIZE >= 12 void fp_mul_comba6(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_64.c b/src/mul/fp_mul_comba_64.c index 8b9b9cf..eeca498 100644 --- a/src/mul/fp_mul_comba_64.c +++ b/src/mul/fp_mul_comba_64.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL64) && FP_SIZE >= 128 void fp_mul_comba64(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_7.c b/src/mul/fp_mul_comba_7.c index c526c1c..e3e3f09 100644 --- a/src/mul/fp_mul_comba_7.c +++ b/src/mul/fp_mul_comba_7.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL7) && FP_SIZE >= 14 void fp_mul_comba7(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_8.c b/src/mul/fp_mul_comba_8.c index b60ea25..90952c8 100644 --- a/src/mul/fp_mul_comba_8.c +++ b/src/mul/fp_mul_comba_8.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL8) && FP_SIZE >= 16 void fp_mul_comba8(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_9.c b/src/mul/fp_mul_comba_9.c index edc53d9..3e5778f 100644 --- a/src/mul/fp_mul_comba_9.c +++ b/src/mul/fp_mul_comba_9.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_MUL9) && FP_SIZE >= 18 void fp_mul_comba9(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/mul/fp_mul_comba_small_set.c b/src/mul/fp_mul_comba_small_set.c index c4b9413..4d20165 100644 --- a/src/mul/fp_mul_comba_small_set.c +++ b/src/mul/fp_mul_comba_small_set.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_mul_comba.c" +#endif #if defined(TFM_SMALL_SET) void fp_mul_comba_small(fp_int *A, fp_int *B, fp_int *C) diff --git a/src/sqr/fp_sqr_comba_12.c b/src/sqr/fp_sqr_comba_12.c index 53f2bdd..30db6a0 100644 --- a/src/sqr/fp_sqr_comba_12.c +++ b/src/sqr/fp_sqr_comba_12.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR12) && FP_SIZE >= 24 void fp_sqr_comba12(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_17.c b/src/sqr/fp_sqr_comba_17.c index 5c25fb5..194c79a 100644 --- a/src/sqr/fp_sqr_comba_17.c +++ b/src/sqr/fp_sqr_comba_17.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR17) && FP_SIZE >= 34 void fp_sqr_comba17(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_20.c b/src/sqr/fp_sqr_comba_20.c index 506f754..f14cc9e 100644 --- a/src/sqr/fp_sqr_comba_20.c +++ b/src/sqr/fp_sqr_comba_20.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR20) && FP_SIZE >= 40 void fp_sqr_comba20(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_24.c b/src/sqr/fp_sqr_comba_24.c index 4c9f0f8..8def148 100644 --- a/src/sqr/fp_sqr_comba_24.c +++ b/src/sqr/fp_sqr_comba_24.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR24) && FP_SIZE >= 48 void fp_sqr_comba24(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_28.c b/src/sqr/fp_sqr_comba_28.c index bd13a0a..aa5406b 100644 --- a/src/sqr/fp_sqr_comba_28.c +++ b/src/sqr/fp_sqr_comba_28.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR28) && FP_SIZE >= 56 void fp_sqr_comba28(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_3.c b/src/sqr/fp_sqr_comba_3.c index ea0c272..e92ce89 100644 --- a/src/sqr/fp_sqr_comba_3.c +++ b/src/sqr/fp_sqr_comba_3.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR3) && FP_SIZE >= 6 void fp_sqr_comba3(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_32.c b/src/sqr/fp_sqr_comba_32.c index 5ce343d..be03f19 100644 --- a/src/sqr/fp_sqr_comba_32.c +++ b/src/sqr/fp_sqr_comba_32.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR32) && FP_SIZE >= 64 void fp_sqr_comba32(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_4.c b/src/sqr/fp_sqr_comba_4.c index 05be36e..b47125e 100644 --- a/src/sqr/fp_sqr_comba_4.c +++ b/src/sqr/fp_sqr_comba_4.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR4) && FP_SIZE >= 8 void fp_sqr_comba4(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_48.c b/src/sqr/fp_sqr_comba_48.c index 406af9b..312906d 100644 --- a/src/sqr/fp_sqr_comba_48.c +++ b/src/sqr/fp_sqr_comba_48.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR48) && FP_SIZE >= 96 void fp_sqr_comba48(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_6.c b/src/sqr/fp_sqr_comba_6.c index e86c144..914daaf 100644 --- a/src/sqr/fp_sqr_comba_6.c +++ b/src/sqr/fp_sqr_comba_6.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR6) && FP_SIZE >= 12 void fp_sqr_comba6(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_64.c b/src/sqr/fp_sqr_comba_64.c index f2a66e6..2aec744 100644 --- a/src/sqr/fp_sqr_comba_64.c +++ b/src/sqr/fp_sqr_comba_64.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR64) && FP_SIZE >= 128 void fp_sqr_comba64(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_7.c b/src/sqr/fp_sqr_comba_7.c index e9fd421..99aca36 100644 --- a/src/sqr/fp_sqr_comba_7.c +++ b/src/sqr/fp_sqr_comba_7.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR7) && FP_SIZE >= 14 void fp_sqr_comba7(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_8.c b/src/sqr/fp_sqr_comba_8.c index d6c3189..7a72b8a 100644 --- a/src/sqr/fp_sqr_comba_8.c +++ b/src/sqr/fp_sqr_comba_8.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR8) && FP_SIZE >= 16 void fp_sqr_comba8(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_9.c b/src/sqr/fp_sqr_comba_9.c index 87fabbb..1669ef2 100644 --- a/src/sqr/fp_sqr_comba_9.c +++ b/src/sqr/fp_sqr_comba_9.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SQR9) && FP_SIZE >= 18 void fp_sqr_comba9(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_generic.c b/src/sqr/fp_sqr_comba_generic.c index 168bd9d..d522d58 100644 --- a/src/sqr/fp_sqr_comba_generic.c +++ b/src/sqr/fp_sqr_comba_generic.c @@ -8,8 +8,10 @@ * Tom St Denis, tomstdenis@gmail.com */ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif /* generic comba squarer */ void fp_sqr_comba(fp_int *A, fp_int *B) diff --git a/src/sqr/fp_sqr_comba_small_set.c b/src/sqr/fp_sqr_comba_small_set.c index 86ba037..f0b4563 100644 --- a/src/sqr/fp_sqr_comba_small_set.c +++ b/src/sqr/fp_sqr_comba_small_set.c @@ -1,5 +1,7 @@ +#ifndef TFM_PRE_GEN_MPI_C #define TFM_DEFINES #include "fp_sqr_comba.c" +#endif #if defined(TFM_SMALL_SET) void fp_sqr_comba_small(fp_int *A, fp_int *B)