diff --git a/configure.ac b/configure.ac index f5260a2..77f0ab5 100644 --- a/configure.ac +++ b/configure.ac @@ -117,6 +117,44 @@ then CFLAGS="$CFLAGS -msse2" fi +AC_ARG_ENABLE([intfilter], + [AS_HELP_STRING([--enable-intfilter@<:@=(32|64|128|native)@:>@], + [use integers of specific size @<:@default=64@:>@ for filtering. faster but limits filter length to: 6 for 32-bit, 12 for 64-bit, 24 for 128-bit @<:@default=no@:>@])], + [], [enable_intfilter=no] +) +AC_ARG_ENABLE([intfilter32], + [AS_HELP_STRING([--enable-intfilter32], [deprecated. use --enable-intfilter=32 instead])], + [enable_intfilter=32] + [AC_MSG_WARN([--enable-intfilter32 option is deprecated. use --enable-intfilter=32 instead])], + [] +) +case "$enable_intfilter" in +32) + intfiltertype="u32" + ;; +64|yes) + intfiltertype="u64" + ;; +128) + intfiltertype="unsigned __int128" + ;; +native) + intfiltertype="size_t" + ;; +no) + intfiltertype="" + ;; +*) + AC_MSG_WARN([unrecognised intfilter type: $enable_intfilter]) + intfiltertype="" + ;; +esac + +if test -n "$intfiltertype" +then + MYDEFS="$MYDEFS -DINTFILTER -DIFT='$intfiltertype'" +fi + cstd="" c99="" oldcflags="$CFLAGS" @@ -135,7 +173,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [cstd="$cstd -Wall"], [AC_MSG_RESULT([no])] ) -if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" +if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" -a "x$enable_intfilter" != "x128" then CFLAGS="$cstd -Wpedantic" AC_MSG_CHECKING([whether CC supports -Wpedantic]) @@ -157,31 +195,6 @@ then fi CFLAGS="$oldcflags" - -AC_ARG_ENABLE([intfilter], - [AS_HELP_STRING([--enable-intfilter], - [use 64-bit integers for filtering. faster but limits filter length to 12 @<:@default=no@:>@])], - [], [enable_intfilter=no] -) -AC_ARG_ENABLE([intfilter32], - [AS_HELP_STRING([--enable-intfilter32], - [use 32-bit integers for filtering. even faster on 32-bit machines but limits filter length to 6 @<:@default=no@:>@])], - [], [enable_intfilter32=no] -) -if test "x$enable_intfilter32" = "xyes" -then - if test "x$enable_intfilter" = "xyes" - then - AC_MSG_WARN([both intfilter and intfilter32 specified; using intfilter32]) - fi - MYDEFS="$MYDEFS -DINTFILTER -DIFT=u32" -else - if test "x$enable_intfilter" = "xyes" - then - MYDEFS="$MYDEFS -DINTFILTER" - fi -fi - AC_ARG_ENABLE([binfilterlen], [AS_HELP_STRING([--enable-binfilterlen=VAL], [set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])], diff --git a/main.c b/main.c index f6ac23f..23f9657 100644 --- a/main.c +++ b/main.c @@ -76,9 +76,6 @@ struct binfilter { } ; #ifdef INTFILTER -#ifndef IFT -#define IFT u64 -#endif struct intfilter { IFT f; #ifndef BINSEARCH diff --git a/types.h b/types.h index fe76142..10c6c70 100644 --- a/types.h +++ b/types.h @@ -1,16 +1,16 @@ -#define U64_MAX UINT64_MAX -#define I64_MIN INT64_MIN -#define I64_MAX INT64_MAX -#define U32_MAX UINT32_MAX -#define I32_MIN INT32_MIN -#define I32_MAX INT32_MAX -#define U16_MAX UINT16_MAX -#define I16_MIN INT16_MIN -#define I16_MAX INT16_MAX #define U8_MAX UINT8_MAX #define I8_MIN INT8_MIN #define I8_MAX INT8_MAX +#define U16_MAX UINT16_MAX +#define I16_MIN INT16_MIN +#define I16_MAX INT16_MAX +#define U32_MAX UINT32_MAX +#define I32_MIN INT32_MIN +#define I32_MAX INT32_MAX +#define U64_MAX UINT64_MAX +#define I64_MIN INT64_MIN +#define I64_MAX INT64_MAX typedef uint8_t u8; typedef int8_t i8;