From f649eedb70540a39dcb5da979071d762c33a63bf Mon Sep 17 00:00:00 2001 From: cathugger Date: Sun, 22 Oct 2017 00:40:23 +0000 Subject: [PATCH] more autism --- Makefile.in | 10 +++++++++- configure.ac | 51 ++++++++++++++++++++++++++++++++++++++++----------- cpucount.c | 3 +-- main.c | 34 ++++++++++++++++++++-------------- 4 files changed, 70 insertions(+), 28 deletions(-) diff --git a/Makefile.in b/Makefile.in index 2b04b6d..6342acc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ CC= @CC@ -CSTD= @CSTD@ -Wall +CSTD= @CSTD@ CFLAGS= $(CSTD) @CFLAGS@ @CPPFLAGS@ -DED25519_@ED25519IMPL@ @MYDEFS@ ASFLAGS= LDFLAGS= @NOPIE@ @LDFLAGS@ @@ -84,6 +84,13 @@ clean: $(RM) $(CLEANO) $(RM) $(EXE) +distclean: + $(RM) $(CLEANO) + $(RM) $(EXE) + $(RM) -r autom4te.cache + $(RM) configure config.status config.log + $(RM) Makefile + depend: makedepend -Y -fMakefile.in -o.c.o -- $(CSTD) $(ED25519_DEFS) -- $(ALLC) @@ -390,3 +397,4 @@ test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-basepoint-table.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-64bit-tables.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-64bit-x86.h test_ed25519.c.o: ed25519/ed25519-donna/ed25519-donna-impl-base.h +vec.c.o: vec.h diff --git a/configure.ac b/configure.ac index 0c054f0..f5260a2 100644 --- a/configure.ac +++ b/configure.ac @@ -25,17 +25,6 @@ then CFLAGS="$oldcflags" fi -cstd="" -oldcflags="$CFLAGS" -CFLAGS="-std=c99" -AC_MSG_CHECKING([whether CC supports -std=c99]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], - [AC_MSG_RESULT([yes])] - [cstd="-std=c99"], - [AC_MSG_RESULT([no])] -) -CFLAGS="$oldcflags" - nopie="" oldcflags="$CFLAGS" @@ -128,6 +117,46 @@ then CFLAGS="$CFLAGS -msse2" fi +cstd="" +c99="" +oldcflags="$CFLAGS" +CFLAGS="-std=c99" +AC_MSG_CHECKING([whether CC supports -std=c99]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [c99="yes"] + [cstd="-std=c99"], + [AC_MSG_RESULT([no])] +) +CFLAGS="$cstd -Wall" +AC_MSG_CHECKING([whether CC supports -Wall]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wall"], + [AC_MSG_RESULT([no])] +) +if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" +then + CFLAGS="$cstd -Wpedantic" + AC_MSG_CHECKING([whether CC supports -Wpedantic]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wpedantic"], + [AC_MSG_RESULT([no])] + ) +fi +if test "x$ed25519impl" = "xdonna" +then + CFLAGS="$cstd -Wno-unused-function" + AC_MSG_CHECKING([whether CC supports -Wno-unused-function]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [cstd="$cstd -Wno-unused-function"], + [AC_MSG_RESULT([no])] + ) +fi +CFLAGS="$oldcflags" + AC_ARG_ENABLE([intfilter], [AS_HELP_STRING([--enable-intfilter], diff --git a/cpucount.c b/cpucount.c index 11fef4d..16982a8 100644 --- a/cpucount.c +++ b/cpucount.c @@ -1,3 +1,4 @@ +#include "cpucount.h" #ifndef BSD # ifndef __linux__ @@ -108,8 +109,6 @@ static int parsecpuinfo() } #endif -#include "cpucount.h" - int cpucount() { int ncpu; diff --git a/main.c b/main.c index 87f94fa..f6ac23f 100644 --- a/main.c +++ b/main.c @@ -345,7 +345,7 @@ static void filters_prepare() { if (!quietflag) fprintf(stderr,"sorting filters..."); - filter_sort(filter_compare); + filter_sort(&filter_compare); if (!quietflag) fprintf(stderr," done.\n"); // TODO remove duplicates @@ -369,9 +369,15 @@ static size_t filters_count() #endif } +#ifdef STATISTICS +#define ADDNUMSUCCESS ++st->numsuccess.v +#else +#define ADDNUMSUCCESS do {} while (0) +#endif + #ifdef INTFILTER -#ifndef BINSEARCH +# ifndef BINSEARCH #define MATCHFILTER(it,pk) \ ((*(IFT *)(pk) & VEC_BUF(ifilters,it).m) == VEC_BUF(ifilters,it).f) @@ -385,7 +391,7 @@ static size_t filters_count() } \ } -#else // BINSEARCH +# else // BINSEARCH #define DOFILTER(it,pk,code) { \ register IFT maskedpk = *(IFT *)(pk) & ifiltermask; \ @@ -402,11 +408,11 @@ static size_t filters_count() } \ } -#endif // BINSEARCH +# endif // BINSEARCH #else // INTFILTER -#ifndef BINSEARCH +# ifndef BINSEARCH #define MATCHFILTER(it,pk) ( \ memcmp(pk,VEC_BUF(bfilters,it).f,VEC_BUF(bfilters,it).len) == 0 && \ @@ -421,7 +427,7 @@ static size_t filters_count() } \ } -#else // BINSEARCH +# else // BINSEARCH #define DOFILTER(it,pk,code) { \ for (size_t down = 0,up = VEC_LENGTH(bfilters);down < up;) { \ @@ -456,7 +462,7 @@ static size_t filters_count() } \ } -#endif // BINSEARCH +# endif // BINSEARCH #endif // INTFILTER @@ -680,9 +686,8 @@ again: #endif DOFILTER(i,pk,{ -#ifdef STATISTICS - ++st->numsuccess.v; -#endif + ADDNUMSUCCESS; + // calc checksum memcpy(&hashsrc[checksumstrlen],pk,PUBLIC_LEN); FIPS202_SHA3_256(hashsrc,sizeof(hashsrc),&pk[PUBLIC_LEN]); @@ -774,10 +779,11 @@ initseed: sk[31] &= 63; sk[31] |= 64; } - else goto initseed; -#ifdef STATISTICS - ++st->numsuccess.v; -#endif + else + goto initseed; + + ADDNUMSUCCESS; + // calc checksum memcpy(&hashsrc[checksumstrlen],pk,PUBLIC_LEN); FIPS202_SHA3_256(hashsrc,sizeof(hashsrc),&pk[PUBLIC_LEN]);