diff --git a/mpint_i.h b/mpint_i.h index 70fdc6e1..23f6dc9d 100644 --- a/mpint_i.h +++ b/mpint_i.h @@ -59,7 +59,11 @@ /* You can lower the BignumInt size by defining BIGNUM_OVERRIDE on the * command line to be your chosen max value of BIGNUM_INT_BITS_BITS */ -#define BB_OK(b) (!defined BIGNUM_OVERRIDE || BIGNUM_OVERRIDE >= b) +#if defined BIGNUM_OVERRIDE +#define BB_OK(b) ((b) <= BIGNUM_OVERRIDE) +#else +#define BB_OK(b) (1) +#endif #if defined __SIZEOF_INT128__ && BB_OK(6) diff --git a/testcrypt.c b/testcrypt.c index 30ee49ea..10481167 100644 --- a/testcrypt.c +++ b/testcrypt.c @@ -1172,30 +1172,28 @@ static void process_line(BinarySource *in, strbuf *out) { ptrlen id = get_word(in); -#define DISPATCH_COMMAND(cmd) \ - if (ptrlen_eq_string(id, #cmd)) { \ - handle_##cmd(in, out); \ - return; \ - } +#define DISPATCH_INTERNAL(cmdname, handler) do { \ + if (ptrlen_eq_string(id, cmdname)) { \ + handler(in, out); \ + return; \ + } \ + } while (0) + +#define DISPATCH_COMMAND(cmd) DISPATCH_INTERNAL(#cmd, handle_##cmd) DISPATCH_COMMAND(hello); DISPATCH_COMMAND(free); DISPATCH_COMMAND(newstring); DISPATCH_COMMAND(getstring); DISPATCH_COMMAND(mp_literal); DISPATCH_COMMAND(mp_dump); +#undef DISPATCH_COMMAND -#define FUNC(rettype, function, ...) \ - if (ptrlen_eq_string(id, #function)) { \ - handle_##function(in, out); \ - return; \ - } - -#define FUNC0 FUNC -#define FUNC1 FUNC -#define FUNC2 FUNC -#define FUNC3 FUNC -#define FUNC4 FUNC -#define FUNC5 FUNC +#define FUNC0(ret,func) DISPATCH_INTERNAL(#func, handle_##func); +#define FUNC1(ret,func,x) DISPATCH_INTERNAL(#func, handle_##func); +#define FUNC2(ret,func,x,y) DISPATCH_INTERNAL(#func, handle_##func); +#define FUNC3(ret,func,x,y,z) DISPATCH_INTERNAL(#func, handle_##func); +#define FUNC4(ret,func,x,y,z,v) DISPATCH_INTERNAL(#func, handle_##func); +#define FUNC5(ret,func,x,y,z,v,w) DISPATCH_INTERNAL(#func, handle_##func); #include "testcrypt.h" @@ -1206,6 +1204,8 @@ static void process_line(BinarySource *in, strbuf *out) #undef FUNC1 #undef FUNC0 +#undef DISPATCH_INTERNAL + fatal_error("command '%.*s': unrecognised", PTRLEN_PRINTF(id)); }