tests: add widen_to_ull macro to tests.h

* tests.h (widen_to_ull): New macro, copied from defs.h
This commit is contained in:
Дмитрий Левин 2016-06-10 09:13:32 +00:00
parent 70ea46756e
commit af0d066dc2

View File

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