protect include of c-files

the way it was before, pre_gen/mpi.c couldn't be built
This commit is contained in:
Steffen Jaeckel 2018-02-01 01:53:00 +01:00
parent b460616547
commit 3bfaf74033
36 changed files with 71 additions and 0 deletions

1
gen.pl
View File

@ -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: $!";

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)