]> granicus.if.org Git - strace/commitdiff
Add sign_extend_unsigned_to_ll macro
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 23 Aug 2016 00:24:22 +0000 (00:24 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 23 Aug 2016 00:24:22 +0000 (00:24 +0000)
* defs.h (sign_extend_unsigned_to_ll): New macro, mirrors
zero_extend_signed_to_ull.

defs.h

diff --git a/defs.h b/defs.h
index b17368be2b17b20e26ed136a5446324c4123e0b6..c76c98ce909e6546ca3fc307c63f9ec31c6dd67e 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -755,6 +755,15 @@ extern unsigned current_wordsize;
         sizeof(v) == sizeof(long) ? (unsigned long long) (unsigned long) (v) : \
         (unsigned long long) (v))
 
+/*
+ * Sign-extend an unsigned integer type to long long.
+ */
+#define sign_extend_unsigned_to_ll(v) \
+       (sizeof(v) == sizeof(short) ? (long long) (short) (v) : \
+        sizeof(v) == sizeof(int) ? (long long) (int) (v) : \
+        sizeof(v) == sizeof(long) ? (long long) (long) (v) : \
+        (long long) (v))
+
 extern const struct_sysent sysent0[];
 extern const char *const errnoent0[];
 extern const char *const signalent0[];