From af0d066dc2c09d9a50b9d5dce612ddb273c8c68c Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 10 Jun 2016 09:13:32 +0000 Subject: [PATCH] tests: add widen_to_ull macro to tests.h * tests.h (widen_to_ull): New macro, copied from defs.h --- tests/tests.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/tests.h b/tests/tests.h index 0205ea03..9f556ae4 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -104,6 +104,14 @@ int printxval(const struct xlat *, const unsigned long long, const char *); # define ARRAY_SIZE(arg) ((unsigned int) (sizeof(arg) / sizeof((arg)[0]))) # define LENGTH_OF(arg) ((unsigned int) sizeof(arg) - 1) +/* + * Widen without sign-extension a signed integer type to unsigned long long. + */ +#define widen_to_ull(v) \ + (sizeof(v) == sizeof(int) ? (unsigned long long) (unsigned int) (v) : \ + sizeof(v) == sizeof(long) ? (unsigned long long) (unsigned long) (v) : \ + (unsigned long long) (v)) + # define SKIP_MAIN_UNDEFINED(arg) \ int main(void) { error_msg_and_skip("undefined: %s", arg); } -- 2.40.0