]> granicus.if.org Git - strace/commitdiff
Introduce ANY_WORDSIZE_LESS_THAN_KERNEL_LONG macro
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 26 Dec 2016 20:12:23 +0000 (20:12 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 27 Dec 2016 01:08:58 +0000 (01:08 +0000)
* defs.h (ANY_WORDSIZE_LESS_THAN_KERNEL_LONG): New macro.
(truncate_klong_to_current_wordsize,
truncate_kulong_to_current_wordsize): Use it.
* mem.c (SYS_FUNC(old_mmap)): Likewise.
* util.c (umoven, umovestr, dumpiov_upto): Likewise.
* syscall.c (trace_syscall_exiting): Likewise.

defs.h
mem.c
syscall.c
util.c

diff --git a/defs.h b/defs.h
index fbf0d40e778f7fdf2634e7928a56e66754804422..81d26d5ca61bfe58f305d9011479ab569beb981e 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -796,6 +796,10 @@ extern unsigned current_klongsize;
 # endif
 #endif
 
+#define ANY_WORDSIZE_LESS_THAN_KERNEL_LONG     \
+       (SIZEOF_KERNEL_LONG_T > 4               \
+        && (SIZEOF_LONG < SIZEOF_KERNEL_LONG_T || !defined(current_wordsize)))
+
 #define DECL_PRINTNUM(name)                                            \
 extern bool                                                            \
 printnum_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt)  \
@@ -864,8 +868,7 @@ DECL_PRINTPAIR(int64);
 static inline kernel_long_t
 truncate_klong_to_current_wordsize(const kernel_long_t v)
 {
-#if SIZEOF_KERNEL_LONG_T > 4 \
- && (SIZEOF_LONG < SIZEOF_KERNEL_LONG_T || !defined current_wordsize)
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
        if (current_wordsize < sizeof(v)) {
                return (int) v;
        } else
@@ -878,8 +881,7 @@ truncate_klong_to_current_wordsize(const kernel_long_t v)
 static inline kernel_ulong_t
 truncate_kulong_to_current_wordsize(const kernel_ulong_t v)
 {
-#if SIZEOF_KERNEL_LONG_T > 4 \
- && (SIZEOF_LONG < SIZEOF_KERNEL_LONG_T || !defined current_wordsize)
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
        if (current_wordsize < sizeof(v)) {
                return (unsigned int) v;
        } else
diff --git a/mem.c b/mem.c
index 6a541cfb6b39afc0406c643364c1b784eb023d30..40ed707af075f9bbb3dbc22df6b259e2612f1229 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -94,7 +94,7 @@ print_mmap(struct tcb *tcp, kernel_ulong_t *u_arg, unsigned long long offset)
 SYS_FUNC(old_mmap)
 {
        kernel_ulong_t u_arg[6];
-# ifndef current_klongsize
+# if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
        /* We are here only in a 32-bit personality. */
        unsigned int narrow_arg[6];
        if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg))
index 6178fdab3958d052795336d94d4b8b524ee241df..e696b25f1c4d65b379756f3b28ff0f660cd29a82 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -901,26 +901,30 @@ trace_syscall_exiting(struct tcb *tcp)
                else {
                        switch (sys_res & RVAL_MASK) {
                        case RVAL_HEX:
-#if SUPPORTED_PERSONALITIES > 1
-                               if (current_wordsize < sizeof(tcp->u_rval))
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
+                               if (current_wordsize < sizeof(tcp->u_rval)) {
                                        tprintf("= %#x",
                                                (unsigned int) tcp->u_rval);
-                               else
+                               else
 #endif
+                               {
                                        tprintf("= %#" PRI_klx, tcp->u_rval);
+                               }
                                break;
                        case RVAL_OCTAL:
                                tprints("= ");
                                print_numeric_long_umask(tcp->u_rval);
                                break;
                        case RVAL_UDECIMAL:
-#if SUPPORTED_PERSONALITIES > 1
-                               if (current_wordsize < sizeof(tcp->u_rval))
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
+                               if (current_wordsize < sizeof(tcp->u_rval)) {
                                        tprintf("= %u",
                                                (unsigned int) tcp->u_rval);
-                               else
+                               else
 #endif
+                               {
                                        tprintf("= %" PRI_klu, tcp->u_rval);
+                               }
                                break;
                        case RVAL_DECIMAL:
                                tprintf("= %" PRI_kld, tcp->u_rval);
diff --git a/util.c b/util.c
index 71ee4f9f100a8da8102d5cff2f4f71b3fd6b18df..67a847f781f00c0719bb71633c3b1ffcda518c3e 100644 (file)
--- a/util.c
+++ b/util.c
@@ -942,7 +942,7 @@ void
 dumpiov_upto(struct tcb *const tcp, const int len, const kernel_ulong_t addr,
             kernel_ulong_t data_size)
 {
-#if SUPPORTED_PERSONALITIES > 1
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
        union {
                struct { uint32_t base; uint32_t len; } *iov32;
                struct { uint64_t base; uint64_t len; } *iov64;
@@ -1141,8 +1141,7 @@ umoven(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len,
                char x[sizeof(long)];
        } u;
 
-#if SIZEOF_KERNEL_LONG_T > 4 \
- && (SIZEOF_LONG < SIZEOF_KERNEL_LONG_T || !defined current_wordsize)
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
        if (current_wordsize < sizeof(addr)
            && (addr & (~ (kernel_ulong_t) -1U))) {
                return -1;
@@ -1290,8 +1289,7 @@ umovestr(struct tcb *const tcp, kernel_ulong_t addr, unsigned int len, char *lad
                char x[sizeof(long)];
        } u;
 
-#if SIZEOF_KERNEL_LONG_T > 4 \
- && (SIZEOF_LONG < SIZEOF_KERNEL_LONG_T || !defined current_wordsize)
+#if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
        if (current_wordsize < sizeof(addr)
            && (addr & (~ (kernel_ulong_t) -1U))) {
                return -1;