]> granicus.if.org Git - strace/commitdiff
tests: add widen_to_ull macro to tests.h
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 10 Jun 2016 09:13:32 +0000 (09:13 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 10 Jun 2016 09:14:20 +0000 (09:14 +0000)
* tests.h (widen_to_ull): New macro, copied from defs.h

tests/tests.h

index 0205ea039b46eb68b74dec786de022066a3b7e72..9f556ae4fa97254f7702cff33c9a7055ffbf7dc3 100644 (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); }