]> granicus.if.org Git - strace/commitdiff
Do not define printnum_long_int on systems with constant current_wordsize
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 26 Dec 2016 13:50:14 +0000 (13:50 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 26 Dec 2016 13:50:14 +0000 (13:50 +0000)
* defs.h: Check [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] to select
definitions of printnum_slong, printnum_ulong, and printnum_ptr.
* util.c: Check [!current_wordsize] instead
of [SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] to decide
whether to compile printnum_long_int.

defs.h
util.c

diff --git a/defs.h b/defs.h
index 61a5e1200232c676cd4aab78c5f48ed6a6f8881c..96fe4050fd58cdf3ddbb0226306515d6c1b0e943 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -597,51 +597,6 @@ extern void
 printstr_ex(struct tcb *, kernel_ulong_t addr, kernel_ulong_t len,
            unsigned int user_style);
 
-#define DECL_PRINTNUM(name)                                            \
-extern bool                                                            \
-printnum_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt)  \
-       ATTRIBUTE_FORMAT((printf, 3, 0))
-DECL_PRINTNUM(short);
-DECL_PRINTNUM(int);
-DECL_PRINTNUM(int64);
-#undef DECL_PRINTNUM
-
-#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
-extern bool
-printnum_long_int(struct tcb *, kernel_ulong_t addr,
-                 const char *fmt_long, const char *fmt_int)
-       ATTRIBUTE_FORMAT((printf, 3, 0))
-       ATTRIBUTE_FORMAT((printf, 4, 0));
-# define printnum_slong(tcp, addr) \
-       printnum_long_int((tcp), (addr), "%" PRId64, "%d")
-# define printnum_ulong(tcp, addr) \
-       printnum_long_int((tcp), (addr), "%" PRIu64, "%u")
-# define printnum_ptr(tcp, addr) \
-       printnum_long_int((tcp), (addr), "%#" PRIx64, "%#x")
-#elif SIZEOF_LONG > 4
-# define printnum_slong(tcp, addr) \
-       printnum_int64((tcp), (addr), "%" PRId64)
-# define printnum_ulong(tcp, addr) \
-       printnum_int64((tcp), (addr), "%" PRIu64)
-# define printnum_ptr(tcp, addr) \
-       printnum_int64((tcp), (addr), "%#" PRIx64)
-#else
-# define printnum_slong(tcp, addr) \
-       printnum_int((tcp), (addr), "%d")
-# define printnum_ulong(tcp, addr) \
-       printnum_int((tcp), (addr), "%u")
-# define printnum_ptr(tcp, addr) \
-       printnum_int((tcp), (addr), "%#x")
-#endif
-
-#define DECL_PRINTPAIR(name)                                           \
-extern bool                                                            \
-printpair_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt) \
-       ATTRIBUTE_FORMAT((printf, 3, 0))
-DECL_PRINTPAIR(int);
-DECL_PRINTPAIR(int64);
-#undef DECL_PRINTPAIR
-
 extern void
 printpathn(struct tcb *, kernel_ulong_t addr, unsigned int n);
 
@@ -841,6 +796,51 @@ extern unsigned current_klongsize;
 # endif
 #endif
 
+#define DECL_PRINTNUM(name)                                            \
+extern bool                                                            \
+printnum_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt)  \
+       ATTRIBUTE_FORMAT((printf, 3, 0))
+DECL_PRINTNUM(short);
+DECL_PRINTNUM(int);
+DECL_PRINTNUM(int64);
+#undef DECL_PRINTNUM
+
+#ifndef current_wordsize
+extern bool
+printnum_long_int(struct tcb *, kernel_ulong_t addr,
+                 const char *fmt_long, const char *fmt_int)
+       ATTRIBUTE_FORMAT((printf, 3, 0))
+       ATTRIBUTE_FORMAT((printf, 4, 0));
+# define printnum_slong(tcp, addr) \
+       printnum_long_int((tcp), (addr), "%" PRId64, "%d")
+# define printnum_ulong(tcp, addr) \
+       printnum_long_int((tcp), (addr), "%" PRIu64, "%u")
+# define printnum_ptr(tcp, addr) \
+       printnum_long_int((tcp), (addr), "%#" PRIx64, "%#x")
+#elif current_wordsize > 4
+# define printnum_slong(tcp, addr) \
+       printnum_int64((tcp), (addr), "%" PRId64)
+# define printnum_ulong(tcp, addr) \
+       printnum_int64((tcp), (addr), "%" PRIu64)
+# define printnum_ptr(tcp, addr) \
+       printnum_int64((tcp), (addr), "%#" PRIx64)
+#else /* current_wordsize == 4 */
+# define printnum_slong(tcp, addr) \
+       printnum_int((tcp), (addr), "%d")
+# define printnum_ulong(tcp, addr) \
+       printnum_int((tcp), (addr), "%u")
+# define printnum_ptr(tcp, addr) \
+       printnum_int((tcp), (addr), "%#x")
+#endif
+
+#define DECL_PRINTPAIR(name)                                           \
+extern bool                                                            \
+printpair_ ## name(struct tcb *, kernel_ulong_t addr, const char *fmt) \
+       ATTRIBUTE_FORMAT((printf, 3, 0))
+DECL_PRINTPAIR(int);
+DECL_PRINTPAIR(int64);
+#undef DECL_PRINTPAIR
+
 /* In many, many places we play fast and loose and use
  * tprintf("%d", (int) tcp->u_arg[N]) to print fds, pids etc.
  * We probably need to use widen_to_long() instead:
diff --git a/util.c b/util.c
index c1d404380e26e852ebbce2e1107c3450936b1e7d..3fbe2dbc1819ef3994280c9e1e0b59201fa9b8dd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -506,7 +506,7 @@ DEF_PRINTNUM(short, short)
 DEF_PRINTNUM(int64, uint64_t)
 DEF_PRINTPAIR(int64, uint64_t)
 
-#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+#ifndef current_wordsize
 bool
 printnum_long_int(struct tcb *const tcp, const kernel_ulong_t addr,
                  const char *const fmt_long, const char *const fmt_int)
@@ -517,7 +517,7 @@ printnum_long_int(struct tcb *const tcp, const kernel_ulong_t addr,
                return printnum_int(tcp, addr, fmt_int);
        }
 }
-#endif
+#endif /* !current_wordsize */
 
 const char *
 sprinttime(time_t t)